99e222d5b14544bbb89d402eb704829c642f8abf |
26-Oct-2017 |
Dake Gu <dake@google.com> |
leanback: fix duplicated fragment in BrowseFragment.setAdapter() When calling BrowseFragment.setAdapter() with a list of rows, a fragment will be created, then later initial row selection will create another copy of fragment. This also breaks slide-in entrance transition that was launched on first fragment and immediately was wiped off by second fragment replacement. The fix removes replaceMainFragment() call from setAdapter(). Also some minor fix to allow setAdapter(null). Currently sample app call setAdapter() with empty list first. So it does not show the problem of duplicated fragment. This fix enables sample code to call setAdapter() with loaded data which is very important in restoring view state. Gridview needs to get list of data in first layout pass in order to restore focus index and children states. For example if there is only 1 item in the first layout pass after restoring, GridView is unable to restore focus index to 3. Added lots of BrowseFragment tests for checking savedInstance gets restored properly. Fixed generatev4.py script for demo app after new directory sturcture. Bug: 68273047 Test: browseFragmentSetNullAdapter browseFragmentRestore mixedBrowseFragmentRestoreToListRow mixedBrowseFragmentRestoreToSampleRowsFragmentHideFastLane mixedBrowseFragmentRestoreToSampleRowsFragmentShowFastLane mixedBrowseFragmentRestoreToSampleFragmentHideFastLane mixedBrowseFragmentRestoreToSampleFragmentShowFastLane Manual test, turn on "dont keep activity", start BrowseActivity, click card to open DetailsActivity, hit BACK, BrowseActivity is recreated, focus is restored to exact same row and item. Change-Id: I2e2a703b142e6f9573ee961042ed92792bf8c9a5
/frameworks/support/samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/BrowseFragment.java
/frameworks/support/samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/BrowseSupportFragment.java
/frameworks/support/samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/DetailsSupportFragment.java
/frameworks/support/samples/SupportLeanbackDemos/src/main/java/com/example/android/leanback/NewDetailsSupportFragment.java
|