26
26
import android .support .design .widget .NavigationView ;
27
27
import android .support .v4 .app .ActivityCompat ;
28
28
import android .support .v4 .app .Fragment ;
29
+ import android .support .v4 .app .FragmentTransaction ;
29
30
import android .support .v4 .content .ContextCompat ;
30
31
import android .support .v4 .view .GravityCompat ;
31
32
import android .support .v4 .widget .DrawerLayout ;
@@ -365,7 +366,7 @@ public void onPlayStarted(PlexMedia media, PlayerState state) {
365
366
366
367
if (layout != -1 ) {
367
368
playerFragment .init (layout , client , media , false , plexSubscriptionListener );
368
- switchToFragment ( playerFragment );
369
+ switchToPlayerFragment ( );
369
370
}
370
371
sendWearPlaybackChange (state , media );
371
372
}
@@ -376,7 +377,7 @@ public void onStateChanged(PlexMedia media, PlayerState state) {
376
377
if (playerFragment != null && playerFragment .isVisible ()) {
377
378
if (state == PlayerState .STOPPED ) {
378
379
Logger .d ("[MainActivity] onStopped" );
379
- switchToFragment ( getMainFragment () );
380
+ switchToMainFragment ( );
380
381
} else {
381
382
playerFragment .setState (state );
382
383
}
@@ -399,7 +400,7 @@ public void onUnsubscribed() {
399
400
Logger .d ("[MainActivity] unsubscribed" );
400
401
setCastIconInactive ();
401
402
prefs .remove (Preferences .SUBSCRIBED_CLIENT );
402
- switchToFragment ( getMainFragment () );
403
+ switchToMainFragment ( );
403
404
if (VoiceControlForPlexApplication .getInstance ().hasWear ()) {
404
405
new SendToDataLayerThread (WearConstants .DISCONNECTED , MainActivity .this ).start ();
405
406
}
@@ -443,7 +444,7 @@ private void init() {
443
444
444
445
setupNavigationDrawer ();
445
446
446
- Logger .d ("Intent action: %s" , getIntent ().getAction ());
447
+ Logger .d ("[MainActivity] Intent action: %s" , getIntent ().getAction ());
447
448
if (getIntent ().getAction () != null && getIntent ().getAction ().equals (ACTION_SHOW_NOW_PLAYING )) {
448
449
handleShowNowPlayingIntent (getIntent ());
449
450
} else {
@@ -518,7 +519,7 @@ public void run() {
518
519
Logger .d ("Auto disconnecting player" );
519
520
if (playerFragment .isVisible ()) {
520
521
VoiceControlForPlexApplication .getInstance ().cancelNotification ();
521
- switchToFragment ( mainFragment );
522
+ switchToMainFragment ( );
522
523
}
523
524
}
524
525
};
@@ -1066,13 +1067,27 @@ private void handleShowNowPlayingIntent(Intent intent) {
1066
1067
if (playerFragment .isVisible ())
1067
1068
playerFragment .mediaChanged (media );
1068
1069
else
1069
- switchToFragment ( playerFragment );
1070
+ switchToPlayerFragment ( );
1070
1071
int seconds = intent .getBooleanExtra (com .atomjack .shared .Intent .EXTRA_STARTING_PLAYBACK , false ) ? 10 : 3 ;
1071
1072
Logger .d ("Setting auto disconnect for %d seconds" , seconds );
1072
1073
handler .postDelayed (autoDisconnectPlayerTimer , seconds *1000 );
1073
1074
}
1074
1075
}
1075
1076
1077
+ private void switchToPlayerFragment () {
1078
+ FragmentTransaction transaction = getSupportFragmentManager ().beginTransaction ();
1079
+ transaction .setCustomAnimations (R .anim .slide_in_up , R .anim .slide_out_up );
1080
+ transaction .replace (R .id .flContent , playerFragment );
1081
+ transaction .commit ();
1082
+ }
1083
+
1084
+ private void switchToMainFragment () {
1085
+ FragmentTransaction transaction = getSupportFragmentManager ().beginTransaction ();
1086
+ transaction .setCustomAnimations (R .anim .slide_in_down , R .anim .slide_out_down );
1087
+ transaction .replace (R .id .flContent , getMainFragment ());
1088
+ transaction .commit ();
1089
+ }
1090
+
1076
1091
private Runnable refreshServers = new Runnable () {
1077
1092
@ Override
1078
1093
public void run () {
@@ -1345,8 +1360,8 @@ protected void setClient(PlexClient _client) {
1345
1360
Logger .d ("[MainActivity] setClient" );
1346
1361
client = _client ;
1347
1362
prefs .put (Preferences .CLIENT , gsonWrite .toJson (_client ));
1348
- if (mainFragment .isVisible ())
1349
- mainFragment .setClient (_client );
1363
+ if (getMainFragment () .isVisible ())
1364
+ getMainFragment () .setClient (_client );
1350
1365
}
1351
1366
1352
1367
private boolean isSubscribed () {
@@ -2243,7 +2258,7 @@ else if(connectionType == ConnectivityManager.TYPE_WIFI)
2243
2258
@ Override
2244
2259
public void onLayoutNotFound () {
2245
2260
// This is passed by PlayerFragment in the case where it is not able to tell which layout (tv/movie/music) to use. We should switch back to the main fragment
2246
- switchToFragment ( getMainFragment () );
2261
+ switchToMainFragment ( );
2247
2262
}
2248
2263
2249
2264
private MainFragment getMainFragment () {
0 commit comments