diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-10-09 19:19:21 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-10-09 19:19:21 +0000 |
commit | 411c4a576a92253a386784dddb646a2671b5d6f9 (patch) | |
tree | d31e2adc1f9cce4f27ca07d30bee921032e33a3c /src/com/android/tv/guide/ProgramRow.java | |
parent | bc7f430decab0bc34a533811efe457d4615f28aa (diff) | |
parent | bb2e798ef4d546dd54cd9e95796403062b860c15 (diff) | |
download | TV-411c4a576a92253a386784dddb646a2671b5d6f9.tar.gz |
Snap for 4384531 from bb2e798ef4d546dd54cd9e95796403062b860c15 to oc-m2-releaseandroid-8.1.0_r8android-8.1.0_r52android-8.1.0_r50android-8.1.0_r47android-8.1.0_r46android-8.1.0_r43android-8.1.0_r41android-8.1.0_r36android-8.1.0_r35android-8.1.0_r33android-8.1.0_r30android-8.1.0_r26android-8.1.0_r25android-8.1.0_r20android-8.1.0_r2oreo-m7-releaseoreo-m6-s4-releaseoreo-m6-s3-releaseoreo-m6-s2-releaseoreo-m2-s5-releaseoreo-m2-s4-releaseoreo-m2-s3-releaseoreo-m2-s2-releaseoreo-m2-s1-releaseoreo-m2-release
Change-Id: I06099c50eb5f4c5791fab1e6055cca20fb367c6d
Diffstat (limited to 'src/com/android/tv/guide/ProgramRow.java')
-rw-r--r-- | src/com/android/tv/guide/ProgramRow.java | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/com/android/tv/guide/ProgramRow.java b/src/com/android/tv/guide/ProgramRow.java index 2c98ab2d..fefc724c 100644 --- a/src/com/android/tv/guide/ProgramRow.java +++ b/src/com/android/tv/guide/ProgramRow.java @@ -21,9 +21,11 @@ import android.graphics.Rect; import android.support.v7.widget.LinearLayoutManager; import android.util.AttributeSet; import android.util.Log; +import android.util.Range; import android.view.View; import android.view.ViewTreeObserver.OnGlobalLayoutListener; +import com.android.tv.MainActivity; import com.android.tv.data.Channel; import com.android.tv.guide.ProgramManager.TableEntry; import com.android.tv.util.Utils; @@ -37,6 +39,7 @@ public class ProgramRow extends TimelineGridView { private static final long ONE_HOUR_MILLIS = TimeUnit.HOURS.toMillis(1); private static final long HALF_HOUR_MILLIS = ONE_HOUR_MILLIS / 2; + private ProgramGuide mProgramGuide; private ProgramManager mProgramManager; private boolean mKeepFocusToCurrentProgram; @@ -44,8 +47,8 @@ public class ProgramRow extends TimelineGridView { interface ChildFocusListener { /** - * Is called after focus is moved. It used {@link ChildFocusListener#isChild} to decide if - * old and new focuses are listener's children. + * Is called after focus is moved. Caller should check if old and new focuses are + * listener's children. * See {@code ProgramRow#setChildFocusListener(ChildFocusListener)}. */ void onChildFocus(View oldFocus, View newFocus); @@ -213,7 +216,6 @@ public class ProgramRow extends TimelineGridView { // so give focus back in onChildAttachedToWindow(). mKeepFocusToCurrentProgram = true; } - // TODO: Try to keep focus for non-current program. } super.onChildDetachedFromWindow(child); } @@ -237,16 +239,18 @@ public class ProgramRow extends TimelineGridView { @Override public boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { - // Give focus to the current program by default. - // Note that this logic is used only if requestFocus() is called to the ProgramRow, - // so focus finding logic will not be blocked by this. - View currentProgram = getCurrentProgramView(); - if (currentProgram != null) { - return currentProgram.requestFocus(); + ProgramGrid programGrid = mProgramGuide.getProgramGrid(); + + // Give focus according to the previous focused range + Range<Integer> focusRange = programGrid.getFocusRange(); + View nextFocus = GuideUtils.findNextFocusedProgram(this, focusRange.getLower(), + focusRange.getUpper(), programGrid.isKeepCurrentProgramFocused()); + + if (nextFocus != null) { + return nextFocus.requestFocus(); } if (DEBUG) Log.d(TAG, "onRequestFocusInDescendants"); - boolean result = super.onRequestFocusInDescendants(direction, previouslyFocusedRect); if (!result) { // The default focus search logic of LeanbackLibrary is sometimes failed. @@ -276,10 +280,11 @@ public class ProgramRow extends TimelineGridView { } /** - * Sets the instance of {@link ProgramManager} + * Sets the instance of {@link ProgramGuide} */ - public void setProgramManager(ProgramManager programManager) { - mProgramManager = programManager; + public void setProgramGuide(ProgramGuide programGuide) { + mProgramGuide = programGuide; + mProgramManager = programGuide.getProgramManager(); } /** @@ -300,7 +305,7 @@ public class ProgramRow extends TimelineGridView { .scrollToPositionWithOffset(position, offset); // Workaround to b/31598505. When a program's duration is too long, // RecyclerView.onScrolled() will not be called after scrollToPositionWithOffset(). - // Therefore we have to update children's visible areas by ourselves in theis case. + // Therefore we have to update children's visible areas by ourselves in this case. // Since scrollToPositionWithOffset() will call requestLayout(), we can listen to this // behavior to ensure program items' visible areas are correctly updated after layouts // are adjusted, i.e., scrolling is over. |