OSDN Git Service

CMFM: improved search performance
authorRoman Birg <roman@cyngn.com>
Wed, 29 Jul 2015 00:24:15 +0000 (17:24 -0700)
committerRoman Birg <roman@cyngn.com>
Thu, 13 Aug 2015 16:44:47 +0000 (09:44 -0700)
commit21560d809d52fbba94d55b1e6b8eb091c885b9fa
treeedcb344d7f90244fe99a3f7b986ff60f779a977f
parentbd79d582be84824e3a5cc519ef6d9cc8d4518aa9
CMFM: improved search performance

Search was usable with a small number of results, but when the result
list grows to something > 1000, it can get really laggy.

A few improvemnts:
- The adapter was chunking items and adding them in bulk to the adapter,
  but it was doing all the work in the main thread. Now it will process
  one item at a time, doing all the rough work in an AsyncTask, and
  passing the final objects to the adapter.

- We don't need to do any chunking of items to add them, but sorting
  the list as soon as they are added is expensive too, so re-use the
  streaming mechanism that was used to add items in chunks, and just
  sort the list during that time.

- Cache common variables to not look them up on every result

- Use a List instead of generating a new DataHolder array _every time_ a
  new object was added. It would end up GCing thousands of items
  every time a new result was added.

- Make the adapter be as simple as possible and just display DataHolder
  objects so it doesn't have to do any processing.

Ref: QRDL-950

Change-Id: I17dd606246556cdf2701bbf2b06933f138588d74
Signed-off-by: Roman Birg <roman@cyngn.com>
src/com/cyanogenmod/filemanager/activities/NavigationActivity.java
src/com/cyanogenmod/filemanager/activities/SearchActivity.java
src/com/cyanogenmod/filemanager/adapters/SearchResultAdapter.java