Commit Graph

8 Commits

Author SHA1 Message Date
Emily Chuang
18a99faaf1 Add DiffCallback to handle Contextual Cards update.
Use DiffCallback in ContextualCardsAdapter to only update items that
are changed instead of touching those unchanged ones.

Also fix a bug where ConditionContexualCardCard#onStart is incorrectly
skipped.

Fixes: 112245748
Bug: 118165942
Test: robotests
Change-Id: I7989d621764fe40a3fceb8c9f40baced840818ba
2018-10-22 15:38:30 -07:00
Fan Zhang
45fc707474 Fix a bug where custom cards are not refresh when removed
When the last custom card for a specific type is removed,
onContextualCardUpdated should receive the cardtype info so we can
remove it from main data set.

- Reverted onContextualCardUpdated method signature back to before
- Force ConditionContextualCardController to send an empty list if
  everything is removed.

* Note: the update logic is pretty complicated to handle
  add/update/remove all together. In the future we should consider
  spliting the removal logic to simplify this area.

Change-Id: Ied688deb693ec33e0017be02cf5c743a754a6e61
Fixes: 115572494
Test: visual
2018-09-14 12:37:01 -07:00
Fan Zhang
29aaf62410 Only replace updated cards after loading from db.
There are currently 2 ways a list of contextual cards can be updated:
1. through loader onFinishLoading
2. onContextualCardUpdated

We need to make the data handling logic consistent between the 2 paths.

Also changed some loops to stream for simplicity.

Change-Id: I242732e180a14092f5745271e5f63c18a6e482e0
Fixes: 115572494
Test: robotests
2018-09-13 14:04:07 -07:00
Fan Zhang
a93743f9c4 Create custom card controller/render as soon as possible.
Custom cards might need to monitor lifecycle events, waiting for
onFinishLoading is too late.

Also make sure custom cards cannot change card type.

Test: manual
Change-Id: Ib8f8e6e48926a63c9d241ed9e9843c025e3f634a
2018-09-13 09:20:59 -07:00
Fan Zhang
089ed21526 Fix nits in contextual card package.
We missed to catch a few nits in previous CLs. This change cleans up
some of it.

Test: manual
Change-Id: Ibd3466f781952f998e1183a49f56e812cbce99a1
2018-09-12 14:07:12 -07:00
Sunny Shao
a87e4cb227 Implemented the CardContentLoader
- Implemented the CardContentLoader
- Refactored the CardLoader and increased the code readable
- Added try-with-resource
- Removed all custom card codes
- Modified ContextualCardManager to add CardContentLoaderCallbacks

Bug: 112521307
Test: robotest
Change-Id: Ieb9cdeaacdfb8fdae9747c60395206d15af034c1
2018-09-12 10:34:40 -07:00
Fan Zhang
ea0b32d1ed Misc clean up
- Rename a few more things from Homepage* to ContextualCard*
- Fixed a wrong parameter that GridLayoutManager was using

Test: rebuild
Change-Id: I7986b1caf63158e876295de6d31dbbe05581664d
2018-09-07 12:40:47 -07:00
Fan Zhang
a746381401 Rename a bunch of stuff.
For homepage cards, rename Homepage* to ContextualCard*.

Change-Id: I95740f15a1789683fa6c61f03ecf9bc47c367146
Fixes: 113966426
Test: robotests
2018-09-06 18:15:12 -07:00