diff --git a/MediaServiceCore b/MediaServiceCore index d13337422b..9755e1ecb0 160000 --- a/MediaServiceCore +++ b/MediaServiceCore @@ -1 +1 @@ -Subproject commit d13337422bddcb005f16279e775212961dfe2a18 +Subproject commit 9755e1ecb0de37b7237741ecd676ea4bec8d9d73 diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/AccountSettingsPresenter.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/AccountSettingsPresenter.java index 2ace43f200..b11b307802 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/AccountSettingsPresenter.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/AccountSettingsPresenter.java @@ -60,7 +60,7 @@ private void createAndShowDialog(List accounts) { createSelectAccountSection(accounts, settingsPresenter); createRemoveAccountSection(accounts, settingsPresenter); - createAddAccountSection(settingsPresenter); + createAddAccountButton(settingsPresenter); settingsPresenter.showDialog(mContext.getString(R.string.settings_accounts), () -> { for (Account account : mPendingRemove) { @@ -86,7 +86,7 @@ private void createSelectAccountSection(List accounts, AppSettingsPrese } optionItems.add(UiOptionItem.from( - account.getName(), option -> mSelectedAccount = account, account.isSelected() + formatAccount(account), option -> mSelectedAccount = account, account.isSelected() )); } @@ -98,7 +98,7 @@ private void createRemoveAccountSection(List accounts, AppSettingsPrese for (Account account : accounts) { optionItems.add(UiOptionItem.from( - account.getName(), option -> { + formatAccount(account), option -> { if (option.isSelected()) { mPendingRemove.add(account); } else { @@ -111,8 +111,20 @@ private void createRemoveAccountSection(List accounts, AppSettingsPrese settingsPresenter.appendCheckedCategory(mContext.getString(R.string.dialog_remove_account), optionItems); } - private void createAddAccountSection(AppSettingsPresenter settingsPresenter) { + private void createAddAccountButton(AppSettingsPresenter settingsPresenter) { settingsPresenter.appendSingleButton(UiOptionItem.from( mContext.getString(R.string.dialog_add_account), option -> SignInPresenter.instance(mContext).start())); } + + private String formatAccount(Account account) { + String format; + + if (account.getEmail() != null) { + format = String.format("%s (%s)", account.getName(), account.getEmail()); + } else { + format = account.getName(); + } + + return format; + } } diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/BrowsePresenter.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/BrowsePresenter.java index 67ca4f29a9..c2e13dc6d5 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/BrowsePresenter.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/BrowsePresenter.java @@ -314,7 +314,15 @@ private void updateVideoRows(Category category, Observable> gro .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( - mediaGroups -> updateVideoRows(category, mediaGroups) + mediaGroups -> { + updateView(category, mediaGroups); + updateRefreshTime(); + + // Hide loading as long as first group received + if (!mediaGroups.isEmpty()) { + mView.showProgressBar(false); + } + } , error -> Log.e(TAG, "updateRowsHeader error: " + error) , () -> { mView.showProgressBar(false); @@ -322,19 +330,6 @@ private void updateVideoRows(Category category, Observable> gro }); } - private void updateVideoRows(Category category, List mediaGroups) { - for (MediaGroup mediaGroup : mediaGroups) { - if (mediaGroup.getMediaItems() == null) { - Log.e(TAG, "loadRowsHeader: MediaGroup is empty. Group Name: " + mediaGroup.getTitle()); - continue; - } - - mView.updateCategory(VideoGroup.from(mediaGroup, category)); - - updateRefreshTime(); - } - } - private void updateVideoGrid(Category category, Observable group) { Log.d(TAG, "updateGridHeader: Start loading category: " + category.getTitle()); @@ -345,6 +340,11 @@ private void updateVideoGrid(Category category, Observable group) { mediaGroup -> { mView.updateCategory(VideoGroup.from(mediaGroup, category)); updateRefreshTime(); + + // Hide loading as long as first group received + if (mediaGroup.getMediaItems() != null) { + mView.showProgressBar(false); + } } , error -> Log.e(TAG, "updateGridHeader error: " + error) , () -> { @@ -352,4 +352,15 @@ private void updateVideoGrid(Category category, Observable group) { mView.updateErrorIfEmpty(new CategoryEmptyError(mContext)); }); } + + private void updateView(Category category, List mediaGroups) { + for (MediaGroup mediaGroup : mediaGroups) { + if (mediaGroup.getMediaItems() == null) { + Log.e(TAG, "loadRowsHeader: MediaGroup is empty. Group Name: " + mediaGroup.getTitle()); + continue; + } + + mView.updateCategory(VideoGroup.from(mediaGroup, category)); + } + } } diff --git a/smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/mod/leanback/ProgressBarManager.java b/smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/mod/leanback/ProgressBarManager.java index 9a238b6cb5..7a074f776b 100644 --- a/smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/mod/leanback/ProgressBarManager.java +++ b/smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/mod/leanback/ProgressBarManager.java @@ -151,9 +151,7 @@ public void setPosition(int position) { mPosition = position; } - public static void setup(androidx.leanback.app.ProgressBarManager manager) { - ViewGroup rootView = (ViewGroup) Helpers.getField(manager, "rootView"); - + public static void setup(androidx.leanback.app.ProgressBarManager manager, ViewGroup rootView) { if (rootView != null) { manager.setProgressBarView(createProgressBar(rootView, Gravity.CENTER)); } diff --git a/smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/playback/PlaybackFragment.java b/smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/playback/PlaybackFragment.java index 11ff130524..8a03b8348a 100644 --- a/smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/playback/PlaybackFragment.java +++ b/smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/ui/playback/PlaybackFragment.java @@ -111,7 +111,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View view = super.onCreateView(inflater, container, savedInstanceState); // ProgressBar.setRootView is called in this moment - ProgressBarManager.setup(getProgressBarManager()); + ProgressBarManager.setup(getProgressBarManager(), (ViewGroup) view); return view; }