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));
}
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)));
}
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);
}
}
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();
}
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();
}
Aggregations