-Fixed playlist bookmark button not showing out when activity / playlist fragment is created by external share.

This commit is contained in:
John Zhen Mo 2018-02-08 15:58:48 -08:00
parent 490b250db6
commit c5ec8d04c1
1 changed files with 11 additions and 4 deletions

View File

@ -111,6 +111,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
headerPopupButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_popup_button); headerPopupButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_popup_button);
headerBackgroundButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_bg_button); headerBackgroundButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_bg_button);
return headerRootLayout; return headerRootLayout;
} }
@ -175,6 +176,8 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
playlistBookmarkButton = menu.findItem(R.id.menu_item_bookmark); playlistBookmarkButton = menu.findItem(R.id.menu_item_bookmark);
playlistUnbookmarkButton = menu.findItem(R.id.menu_item_unbookmark); playlistUnbookmarkButton = menu.findItem(R.id.menu_item_unbookmark);
updateBookmarkButtonsVisibility();
} }
@Override @Override
@ -338,11 +341,8 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
@Override @Override
public void onNext(List<PlaylistRemoteEntity> playlist) { public void onNext(List<PlaylistRemoteEntity> playlist) {
if (playlistBookmarkButton == null || playlistUnbookmarkButton == null) return;
playlistBookmarkButton.setVisible(playlist.isEmpty());
playlistUnbookmarkButton.setVisible(!playlist.isEmpty());
playlistEntity = playlist.isEmpty() ? null : playlist.get(0); playlistEntity = playlist.isEmpty() ? null : playlist.get(0);
updateBookmarkButtonsVisibility();
if (bookmarkReactor != null) bookmarkReactor.request(1); if (bookmarkReactor != null) bookmarkReactor.request(1);
} }
@ -387,4 +387,11 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
.doFinally(() -> playlistEntity = null) .doFinally(() -> playlistEntity = null)
.subscribe(ignored -> {/* Do nothing */}, this::onError); .subscribe(ignored -> {/* Do nothing */}, this::onError);
} }
private void updateBookmarkButtonsVisibility() {
if (playlistBookmarkButton == null || playlistUnbookmarkButton == null) return;
playlistBookmarkButton.setVisible(playlistEntity == null);
playlistUnbookmarkButton.setVisible(playlistEntity != null);
}
} }