@@ -191,6 +191,10 @@ public class MainActivity extends AppCompatActivity
191
191
192
192
private boolean userIsInteracting ;
193
193
194
+ // This will be set to true if wear support is purchased immediately upon launch before
195
+ // initial setup has been done, to delay the wear purchase popup until after that has finished
196
+ private boolean showWearPurchase = false ;
197
+
194
198
// First time setup
195
199
private boolean doingFirstTimeSetup = false ;
196
200
// The next two booleans will be set to true when their respective scans are finished. This will ensure
@@ -444,6 +448,11 @@ private void init() {
444
448
445
449
setupNavigationDrawer ();
446
450
451
+ //
452
+ if (showWearPurchase ) {
453
+ showWearPurchase = false ;
454
+ showWearPurchase ();
455
+ }
447
456
Logger .d ("[MainActivity] Intent action: %s" , getIntent ().getAction ());
448
457
if (getIntent ().getAction () != null && getIntent ().getAction ().equals (ACTION_SHOW_NOW_PLAYING )) {
449
458
handleShowNowPlayingIntent (getIntent ());
@@ -840,7 +849,7 @@ public void onDrawerClosed(View drawerView) {
840
849
841
850
842
851
};
843
- mDrawer .setDrawerListener (drawerToggle );
852
+ mDrawer .addDrawerListener (drawerToggle );
844
853
// Find our drawer view
845
854
if (navigationViewMain == null )
846
855
navigationViewMain = (NavigationView ) findViewById (R .id .navigationViewMain );
@@ -1013,8 +1022,16 @@ protected void onNewIntent(Intent intent) {
1013
1022
if (VoiceControlForPlexApplication .getInstance ().hasWear ()) {
1014
1023
hidePurchaseWearMenuItem ();
1015
1024
} else {
1016
- if (prefs .get (Preferences .HAS_SHOWN_WEAR_PURCHASE_POPUP , false ) == false )
1017
- showWearPurchase ();
1025
+ if (prefs .get (Preferences .HAS_SHOWN_WEAR_PURCHASE_POPUP , false ) == false ) {
1026
+ // If wear support has been purchased before initial setup has been done, the navigation drawer
1027
+ // won't have been setup yet, so let's delay showing the popup until after that is done
1028
+ // (since it's bad UI to show that popup so soon, and because upon successful purchase, the
1029
+ // wear options navigation item isn't even showing yet
1030
+ if (navigationViewMain == null )
1031
+ showWearPurchase = true ;
1032
+ else
1033
+ showWearPurchase ();
1034
+ }
1018
1035
}
1019
1036
} else if (intent .getAction () != null && intent .getAction ().equals (com .atomjack .shared .Intent .SHOW_WEAR_PURCHASE_REQUIRED )) {
1020
1037
showWearPurchaseRequired ();
@@ -1079,7 +1096,9 @@ private void handleShowNowPlayingIntent(Intent intent) {
1079
1096
1080
1097
private void switchToPlayerFragment () {
1081
1098
FragmentTransaction transaction = getSupportFragmentManager ().beginTransaction ();
1082
- transaction .setCustomAnimations (R .anim .slide_in_up , R .anim .slide_out_up );
1099
+ if (getMainFragment ().isVisible ()) {
1100
+ transaction .setCustomAnimations (R .anim .slide_in_up , R .anim .slide_out_up );
1101
+ }
1083
1102
transaction .replace (R .id .flContent , playerFragment );
1084
1103
transaction .commit ();
1085
1104
}
@@ -2129,11 +2148,14 @@ public void onUserInteraction() {
2129
2148
}
2130
2149
2131
2150
public void hidePurchaseWearMenuItem () {
2132
- MenuItem wearItem = navigationViewMain .getMenu ().findItem (R .id .menu_purchase_wear );
2133
- wearItem .setVisible (false );
2134
- MenuItem wearOptionsItem = navigationViewMain .getMenu ().findItem (R .id .menu_wear_options );
2135
- wearOptionsItem .setVisible (true );
2136
-
2151
+ if (navigationViewMain != null ) {
2152
+ MenuItem wearItem = navigationViewMain .getMenu ().findItem (R .id .menu_purchase_wear );
2153
+ if (wearItem != null )
2154
+ wearItem .setVisible (false );
2155
+ MenuItem wearOptionsItem = navigationViewMain .getMenu ().findItem (R .id .menu_wear_options );
2156
+ if (wearOptionsItem != null )
2157
+ wearOptionsItem .setVisible (true );
2158
+ }
2137
2159
}
2138
2160
2139
2161
private boolean hasValidAutoVoice () {
0 commit comments