Skip to content

Commit 67ae691

Browse files
Remove the header fixed text "channels", as I think it to be not very informational.Replace with show information like title and season/episode numbers.
Also some refactors for performance (decreasing debounce and deferring until debounce occurs, i.e. user stops scrolling).
1 parent 74ebe07 commit 67ae691

1 file changed

Lines changed: 54 additions & 19 deletions

File tree

app/src/main/java/org/jellyfin/androidtv/ui/playback/CustomPlaybackOverlayFragment.java

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ public class CustomPlaybackOverlayFragment extends Fragment implements LiveTvGui
9595
private PositionableListRowPresenter mPopupRowPresenter;
9696
private CircularObjectAdapter mCircularChannelAdapter;
9797
private CircularObjectAdapter mCircularChapterAdapter;
98-
private Runnable mDescriptionUpdateTask;
98+
private Runnable mProgramInfoUpdateTask;
9999
private boolean mQuickChannelChangerVisible = false;
100100

101-
private static final int OVERLAY_GUIDE_TEXT_DEBOUNCE_MS = 400;
101+
private static final int OVERLAY_GUIDE_TEXT_DEBOUNCE_MS = 200;
102102
private static final long TICKS_PER_MS = 10_000;
103103

104104
//Live guide items
@@ -201,24 +201,24 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
201201
mPopupRowsFragment.setOnItemViewSelectedListener((itemViewHolder, item, rowViewHolder, row) -> {
202202
if (!mQuickChannelChangerVisible) return;
203203

204-
// Cancel any pending description update (user is still scrolling)
205-
if (mDescriptionUpdateTask != null) {
206-
mHandler.removeCallbacks(mDescriptionUpdateTask);
204+
if (mProgramInfoUpdateTask != null) {
205+
mHandler.removeCallbacks(mProgramInfoUpdateTask);
207206
}
208-
// Clear text immediately while scrolling (space stays reserved)
209207
binding.popupDescription.setText("");
208+
binding.popupHeader.setText("");
210209

211210
if (item instanceof BaseItemDto) {
212211
BaseItemDto channel = (BaseItemDto) item;
213212
BaseItemDto program = channel.getCurrentProgram();
214213
String overview = (program != null) ? program.getOverview() : null;
215-
if (overview != null && !overview.isEmpty()) {
216-
mDescriptionUpdateTask = () -> {
217-
if (binding == null) return;
218-
binding.popupDescription.setText(overview);
219-
};
220-
mHandler.postDelayed(mDescriptionUpdateTask, OVERLAY_GUIDE_TEXT_DEBOUNCE_MS);
221-
}
214+
String headerText = getProgramHeaderText(program);
215+
216+
mProgramInfoUpdateTask = () -> {
217+
if (binding == null) return;
218+
binding.popupHeader.setText(headerText);
219+
binding.popupDescription.setText(overview != null ? overview : "");
220+
};
221+
mHandler.postDelayed(mProgramInfoUpdateTask, OVERLAY_GUIDE_TEXT_DEBOUNCE_MS);
222222
}
223223
});
224224

@@ -259,9 +259,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
259259
public void onDestroyView() {
260260
super.onDestroyView();
261261

262-
if (mDescriptionUpdateTask != null) {
263-
mHandler.removeCallbacks(mDescriptionUpdateTask);
264-
mDescriptionUpdateTask = null;
262+
if (mProgramInfoUpdateTask != null) {
263+
mHandler.removeCallbacks(mProgramInfoUpdateTask);
264+
mProgramInfoUpdateTask = null;
265265
}
266266
binding = null;
267267
// To fix race condition in hide timer
@@ -380,6 +380,7 @@ public void onAnimationStart(Animation animation) {
380380
public void onAnimationEnd(Animation animation) {
381381
if (binding == null || mPopupPanelVisible) return;
382382
binding.popupHeader.setVisibility(View.GONE);
383+
binding.popupHeader.setText("");
383384
binding.popupDescription.setVisibility(View.GONE);
384385
binding.popupDescription.setText("");
385386
binding.popupArea.setVisibility(View.GONE);
@@ -772,8 +773,8 @@ private void showChapterPanel() {
772773

773774
private void hidePopupPanel() {
774775
startFadeTimer();
775-
if (mDescriptionUpdateTask != null) {
776-
mHandler.removeCallbacks(mDescriptionUpdateTask);
776+
if (mProgramInfoUpdateTask != null) {
777+
mHandler.removeCallbacks(mProgramInfoUpdateTask);
777778
}
778779
// Don't change visibility before the animation — let the whole panel fade out together.
779780
// Header/description are reset in hidePopup's onAnimationEnd (which sets popupArea GONE).
@@ -1172,7 +1173,7 @@ public void onAnimationRepeat(Animation animation) {
11721173
public void showQuickChannelChanger() {
11731174
mQuickChannelChangerVisible = true;
11741175
// Show header and reserve description space for channels
1175-
binding.popupHeader.setText(R.string.channels);
1176+
binding.popupHeader.setText("");
11761177
binding.popupHeader.setVisibility(View.VISIBLE);
11771178
binding.popupDescription.setText("");
11781179
binding.popupDescription.setVisibility(View.VISIBLE);
@@ -1210,6 +1211,33 @@ private void positionQuickChannelIfReady() {
12101211
if (overview != null && !overview.isEmpty()) {
12111212
binding.popupDescription.setText(overview);
12121213
}
1214+
binding.popupHeader.setText(getProgramHeaderText(program));
1215+
}
1216+
1217+
private String getProgramHeaderText(BaseItemDto program) {
1218+
if (program == null) return "";
1219+
1220+
Integer season = program.getParentIndexNumber();
1221+
Integer episode = program.getIndexNumber();
1222+
Integer episodeEnd = program.getIndexNumberEnd();
1223+
1224+
String seFragment = null;
1225+
if (episode != null) {
1226+
String ePart = (episodeEnd != null)
1227+
? getString(R.string.lbl_episode_range, episode, episodeEnd)
1228+
: getString(R.string.lbl_episode_number, episode);
1229+
seFragment = (season != null)
1230+
? getString(R.string.lbl_season_number, season) + ":" + ePart
1231+
: ePart;
1232+
}
1233+
1234+
String episodeTitle = program.getEpisodeTitle();
1235+
String title = (episodeTitle != null && !episodeTitle.isEmpty()) ? episodeTitle : program.getName();
1236+
if (title == null) title = "";
1237+
1238+
if (seFragment == null) return title;
1239+
if (title.isEmpty()) return seFragment;
1240+
return title + " (" + seFragment + ")";
12131241
}
12141242

12151243
public void showChapterSelector() {
@@ -1416,6 +1444,13 @@ private void prepareChannelAdapter() {
14161444
int pos = mCircularChannelAdapter.centerPosition(focusIndex);
14171445
if (pos >= 0) {
14181446
mPopupRowPresenter.setPosition(pos);
1447+
Object focusedItem = mCircularChannelAdapter.get(pos);
1448+
if (focusedItem instanceof BaseItemDto) {
1449+
BaseItemDto program = ((BaseItemDto) focusedItem).getCurrentProgram();
1450+
String overview = (program != null) ? program.getOverview() : null;
1451+
binding.popupDescription.setText(overview != null ? overview : "");
1452+
binding.popupHeader.setText(getProgramHeaderText(program));
1453+
}
14191454
}
14201455
}
14211456
return null;

0 commit comments

Comments
 (0)