History log of /frameworks/support/v17/leanback/src/android/support/v17/leanback/widget/ViewsStateBundle.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
3bd331ac6fe8ef25a2deb3559b0b5958573c231b 26-Mar-2015 Dake Gu <dake@google.com> GridLayoutManager Fix child state restoring bug

A regression of ag/630154: detached and reattached child is
assigned with obsolete state saved at opening activity.

The (correct) logic is now:
1. Child state is saved when child is unbound (onViewRecycled)
2. When being asked for onSaveInstanceState(), copy the states
saved in (1) and save current onscreen views state into bundle.

Bug in ag/630154 is that in (2) we saved onscreen views state in
the GridView offscreen states and that information can be invalidated
after a while (e.g. selection of a row can change) and it's later
incorrectly used when a view is detached/re-attached.

added test case.

Bug 19937291

Change-Id: Iac6bd849fdd9755471bce6c7763316d0264cc7a2
/frameworks/support/v17/leanback/src/android/support/v17/leanback/widget/ViewsStateBundle.java
6e96b9d46e7af6bedf6213ecc2ba0ad7b8050778 18-Dec-2014 Dake Gu <dake@google.com> Refactoring grid algorithm

The current interface between GridLayoutManager and StaggeredGrid is
too complicated: GridLayoutManager updates rows min/max edge and Grid
is responsible for fill items according to row min/max edge.

This CL moved most of the grid code into Grid class family and make
interface between GridLayoutManager and Grid much simpler.
GridLayoutManager no longer updates row min/max.

Refactoring made it possible to write efficient Grid class for single
row or non staggered grid. A base Grid class is abstracted out.
StaggeredGrid implemented it using a complicated data strurcture (a
CircularArray) to cache stagger layout result. A single row Grid will
cost less memory allocations: a TODO in the near future.

fastRelayout() was rewriten slightly differently, it will relayout
(using detachFromParent and attachToParent) next children once detects
child size change, previously we push children away on the same row
which might cause a bad alignment at end.

Regular layout now starts with detachAndScrapAttachedViews(), this
is lighter than removeAndRecycleAllViews() which may lose some views
due to cache limit.

Prepend/append during scroll now also detects if child size changed,
then invalidate cached staggered result before/after the child.

Improvement during adapter notifyChange or structure change, now we
no longer discard grid information in a non-fast relayout case. We
still keeps the same cached staggered result, until we really find
size of a child has changed then we invalidate part of the cache.

Tested with BrowseFragment/HorizontalGridTestActivity/
VerticalGridActivity/BrowseAnimationActivity and with rtl=true/false.

Issue: 18946733

Change-Id: Ia0cfa34ad8d09c124dbffe51680a89f177bfef31
/frameworks/support/v17/leanback/src/android/support/v17/leanback/widget/ViewsStateBundle.java
1102fc6fafe721522f2b67f86d89feda87096265 28-Aug-2014 Dake Gu <dake@google.com> GridLayoutManager: Multiple fixes to state saving

1. Implemented a LruCache based child states to limit the memory used.
2. When adding/removing child happens, clean up all cache (will lose all offscreen
child view state). This is because we use index as key, which will be changed.
3. Evict item cache when item is changed.
4. Make saveChildren policy API of BaseGridView, only the vertical list
which has nested horizontal list turned on this feature. This is quite
reasonable assumption: only save the nested horizontal list's focus
index but no more deeper children states: less expensive and avoid
potential unknown problems.
5. load children states inline instead of requesting layout, fixed bug
that requestLayout gets eaten by a top level scrolling layoutmanager.

b/17212513

Change-Id: Ic60c7ac216fa265b64646c3072767983eeb02653
/frameworks/support/v17/leanback/src/android/support/v17/leanback/widget/ViewsStateBundle.java
81a36a4dd93bf2f14c2eb88ae01464f85ddb0706 27-Aug-2014 Dake Gu <dake@google.com> GridLayoutManager: forget child view state when there is a change

b/17212513

Change-Id: I6bd73fab467d109fcdcb1d9664fe6c1a5fdf8acd
/frameworks/support/v17/leanback/src/android/support/v17/leanback/widget/ViewsStateBundle.java
906659fc65e7b8b1bc9f0c7cc3dabf7e64e8b9bf 22-Aug-2014 Dake Gu <dake@google.com> GridLayoutManager: support nested onSaveInstance()

This goes beyond just saving selected position, in order to support
dynamic 2D list view (list view of list view), LayoutManager needs
maintain a position/id to View state Bundle mapping for children.
Child view will be saved when they are offscreen and restored when
showing on screen.

b/15702302

Change-Id: Ie48300684945ee3adacc042e73d06a411287e6d1
/frameworks/support/v17/leanback/src/android/support/v17/leanback/widget/ViewsStateBundle.java