From 7edb234358d6b2e75dcedf54214fb15303c540ab Mon Sep 17 00:00:00 2001 From: okjack Date: Thu, 14 Mar 2024 15:22:46 +0800 Subject: [PATCH] update --- .../com/fongmi/android/tv/ui/activity/HomeActivity.java | 4 ++-- .../com/fongmi/android/tv/ui/fragment/HomeFragment.java | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/leanback/java/com/fongmi/android/tv/ui/activity/HomeActivity.java b/app/src/leanback/java/com/fongmi/android/tv/ui/activity/HomeActivity.java index b353301984..877e4f846f 100644 --- a/app/src/leanback/java/com/fongmi/android/tv/ui/activity/HomeActivity.java +++ b/app/src/leanback/java/com/fongmi/android/tv/ui/activity/HomeActivity.java @@ -515,8 +515,8 @@ protected void onBackPress() { getHomeFragment().mBinding.progressLayout.showContent(); } else if (mPageAdapter != null && getHomeFragment().mPresenter != null && getHomeFragment().mPresenter.isDelete()) { getHomeFragment().setHistoryDelete(false); - } else if (mBinding.recycler.getSelectedPosition() != 0) { - mBinding.recycler.scrollToPosition(0); + } else if (getHomeFragment().canBack()) { + getHomeFragment().goBack(); } else if (!confirm) { setConfirm(); } else { diff --git a/app/src/leanback/java/com/fongmi/android/tv/ui/fragment/HomeFragment.java b/app/src/leanback/java/com/fongmi/android/tv/ui/fragment/HomeFragment.java index 885340ec23..2dcdbbfad0 100644 --- a/app/src/leanback/java/com/fongmi/android/tv/ui/fragment/HomeFragment.java +++ b/app/src/leanback/java/com/fongmi/android/tv/ui/fragment/HomeFragment.java @@ -274,4 +274,12 @@ public void onResume() { refreshFuncRow(); } + public boolean canBack() { + return mBinding.recycler.getSelectedPosition() != 0; + } + + public void goBack() { + mBinding.recycler.scrollToPosition(0); + } + }