Update menu items after change in settings

This commit is contained in:
Mauricio Colli 2017-05-08 22:23:27 -03:00
parent 58137aadc9
commit 4d0d3c7ead
2 changed files with 10 additions and 0 deletions

View File

@ -40,6 +40,7 @@ import java.util.List;
*/
@SuppressWarnings("WeakerAccess")
class ActionBarHandler {
private static final String TAG = "ActionBarHandler";
@ -103,6 +104,10 @@ class ActionBarHandler {
defaultPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
inflater.inflate(R.menu.video_detail_menu, menu);
updateItemsVisibility();
}
public void updateItemsVisibility(){
showPlayWithKodiAction(defaultPreferences.getBoolean(activity.getString(R.string.show_play_with_kodi_key), false));
}

View File

@ -98,6 +98,7 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
private static final int RELATED_STREAMS_UPDATE_FLAG = 0x1;
private static final int RESOLUTIONS_MENU_UPDATE_FLAG = 0x2;
private static final int TOOLBAR_ITEMS_UPDATE_FLAG = 0x4;
private int updateFlags = 0;
private boolean autoPlayEnabled;
@ -219,6 +220,8 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
if ((updateFlags & RELATED_STREAMS_UPDATE_FLAG) != 0) initRelatedVideos(currentStreamInfo);
if ((updateFlags & RESOLUTIONS_MENU_UPDATE_FLAG) != 0) setupActionBarHandler(currentStreamInfo);
}
if ((updateFlags & TOOLBAR_ITEMS_UPDATE_FLAG) != 0 && actionBarHandler != null) actionBarHandler.updateItemsVisibility();
updateFlags = 0;
}
@ -329,6 +332,8 @@ public class VideoDetailFragment extends BaseFragment implements StreamExtractor
|| key.equals(getString(R.string.default_resolution_key))
|| key.equals(getString(R.string.show_higher_resolutions_key))) {
updateFlags |= RESOLUTIONS_MENU_UPDATE_FLAG;
} else if (key.equals(getString(R.string.show_play_with_kodi_key))) {
updateFlags |= TOOLBAR_ITEMS_UPDATE_FLAG;
}
}