Search in sources :

Example 91 with TargetApi

use of android.annotation.TargetApi in project RxPermissions by tbruyelle.

the class RxPermissionsTest method subscription_preM.

@Test
@TargetApi(Build.VERSION_CODES.M)
public void subscription_preM() {
    TestSubscriber<Boolean> sub = new TestSubscriber<>();
    String permission = Manifest.permission.READ_PHONE_STATE;
    when(mRxPermissions.isGranted(permission)).thenReturn(true);
    trigger().compose(mRxPermissions.ensure(permission)).subscribe(sub);
    sub.assertNoErrors();
    sub.assertTerminalEvent();
    sub.assertUnsubscribed();
    sub.assertReceivedOnNext(singletonList(true));
}
Also used : TestSubscriber(rx.observers.TestSubscriber) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test) TargetApi(android.annotation.TargetApi)

Example 92 with TargetApi

use of android.annotation.TargetApi in project RxPermissions by tbruyelle.

the class RxPermissionsTest method eachSubscription_preM.

@Test
@TargetApi(Build.VERSION_CODES.M)
public void eachSubscription_preM() {
    TestSubscriber<Permission> sub = new TestSubscriber<>();
    String permission = Manifest.permission.READ_PHONE_STATE;
    when(mRxPermissions.isGranted(permission)).thenReturn(true);
    trigger().compose(mRxPermissions.ensureEach(permission)).subscribe(sub);
    sub.assertNoErrors();
    sub.assertTerminalEvent();
    sub.assertUnsubscribed();
    sub.assertReceivedOnNext(singletonList(new Permission(permission, true)));
}
Also used : TestSubscriber(rx.observers.TestSubscriber) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test) TargetApi(android.annotation.TargetApi)

Example 93 with TargetApi

use of android.annotation.TargetApi in project Shuttle by timusus.

the class VideoCastManager method updateMediaSession.

/*
     * Updates the playback status of the Media Session
     */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateMediaSession(boolean playing) {
    if (!isFeatureEnabled(CastConfiguration.FEATURE_LOCKSCREEN)) {
        return;
    }
    if (!isConnected()) {
        return;
    }
    try {
        if ((mMediaSessionCompat == null) && playing) {
            setUpMediaSession(getRemoteMediaInformation());
        }
        if (mMediaSessionCompat != null) {
            int playState = isRemoteStreamLive() ? PlaybackStateCompat.STATE_BUFFERING : PlaybackStateCompat.STATE_PLAYING;
            int state = playing ? playState : PlaybackStateCompat.STATE_PAUSED;
            PendingIntent pi = getCastControllerPendingIntent();
            if (pi != null) {
                mMediaSessionCompat.setSessionActivity(pi);
            }
            mMediaSessionCompat.setPlaybackState(new PlaybackStateCompat.Builder().setState(state, 0, 1.0f).setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE).build());
        }
    } catch (TransientNetworkDisconnectionException | NoConnectionException e) {
        LOGE(TAG, "Failed to set up MediaSessionCompat due to network issues", e);
    }
}
Also used : NoConnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.NoConnectionException) Builder(com.google.android.gms.cast.Cast.CastOptions.Builder) PendingIntent(android.app.PendingIntent) TransientNetworkDisconnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

Example 94 with TargetApi

use of android.annotation.TargetApi in project Shuttle by timusus.

the class IntroductoryOverlay method fadeOut.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void fadeOut(long duration) {
    ObjectAnimator oa = ObjectAnimator.ofFloat(this, ALPHA_PROPERTY, INVISIBLE_VALUE);
    oa.setDuration(duration).addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animator) {
            setFtuShown();
            if (mListener != null) {
                mListener.onOverlayDismissed();
                mListener = null;
            }
            remove();
        }
    });
    oa.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) TargetApi(android.annotation.TargetApi)

Example 95 with TargetApi

use of android.annotation.TargetApi in project Conversations by siacs.

the class DNSHelper method getDnsServers.

@TargetApi(21)
private static List<InetAddress> getDnsServers(Context context) {
    List<InetAddress> servers = new ArrayList<>();
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    Network[] networks = connectivityManager == null ? null : connectivityManager.getAllNetworks();
    if (networks == null) {
        return getDnsServersPreLollipop();
    }
    for (int i = 0; i < networks.length; ++i) {
        LinkProperties linkProperties = connectivityManager.getLinkProperties(networks[i]);
        if (linkProperties != null) {
            if (hasDefaultRoute(linkProperties)) {
                servers.addAll(0, getIPv4First(linkProperties.getDnsServers()));
            } else {
                servers.addAll(getIPv4First(linkProperties.getDnsServers()));
            }
        }
    }
    if (servers.size() > 0) {
        Log.d(Config.LOGTAG, "used lollipop variant to discover dns servers in " + networks.length + " networks");
    }
    return servers.size() > 0 ? servers : getDnsServersPreLollipop();
}
Also used : ConnectivityManager(android.net.ConnectivityManager) Network(android.net.Network) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress) LinkProperties(android.net.LinkProperties) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)1365 Intent (android.content.Intent)153 View (android.view.View)147 Test (org.junit.Test)119 SuppressLint (android.annotation.SuppressLint)115 Uri (android.net.Uri)70 ArrayList (java.util.ArrayList)68 Animator (android.animation.Animator)67 Point (android.graphics.Point)64 Window (android.view.Window)56 TextView (android.widget.TextView)56 IOException (java.io.IOException)56 ViewGroup (android.view.ViewGroup)53 Matchers.anyString (org.mockito.Matchers.anyString)53 SharedPreferences (android.content.SharedPreferences)44 File (java.io.File)44 Field (java.lang.reflect.Field)44 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)43 Bitmap (android.graphics.Bitmap)42 ImageView (android.widget.ImageView)40