diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-07-21 15:10:06 -0700 |
---|---|---|
committer | Daisuke Miyakawa <dmiyakawa@google.com> | 2011-07-21 15:44:34 -0700 |
commit | 02c844fe158d55837cf1a1c391f26556e337e55b (patch) | |
tree | 9b3970c9016e3c193135e56bd92ac0050ac973ab /chips/src/com/android/ex/chips/BaseRecipientAdapter.java | |
parent | 9160cd5d914d6975a5e72920950bd007d05aa7ba (diff) | |
download | android_frameworks_ex-02c844fe158d55837cf1a1c391f26556e337e55b.tar.gz android_frameworks_ex-02c844fe158d55837cf1a1c391f26556e337e55b.tar.bz2 android_frameworks_ex-02c844fe158d55837cf1a1c391f26556e337e55b.zip |
Stop spawning multiple threads for photo loading
This is not a fundemental fix for the issue but should mitigate
our headache caused by a bunch of phono_handler threads.
Bug: 5057798
Change-Id: I5f81739bf8439f6d3ee726495b23aab4d3e3d0fd
Diffstat (limited to 'chips/src/com/android/ex/chips/BaseRecipientAdapter.java')
-rw-r--r-- | chips/src/com/android/ex/chips/BaseRecipientAdapter.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/chips/src/com/android/ex/chips/BaseRecipientAdapter.java b/chips/src/com/android/ex/chips/BaseRecipientAdapter.java index 6e1f821..b8194d0 100644 --- a/chips/src/com/android/ex/chips/BaseRecipientAdapter.java +++ b/chips/src/com/android/ex/chips/BaseRecipientAdapter.java @@ -471,7 +471,9 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter */ private CharSequence mCurrentConstraint; - private final HandlerThread mPhotoHandlerThread; + // TODO: need to find better way to manage the thread. + private static final HandlerThread sPhotoHandlerThread = + new HandlerThread("photo_handler"); private final Handler mPhotoHandler; private final LruCache<Uri, byte[]> mPhotoCacheMap; @@ -514,9 +516,10 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter mContentResolver = context.getContentResolver(); mInflater = LayoutInflater.from(context); mPreferredMaxResultCount = preferredMaxResultCount; - mPhotoHandlerThread = new HandlerThread("photo_handler"); - mPhotoHandlerThread.start(); - mPhotoHandler = new Handler(mPhotoHandlerThread.getLooper()); + if (!sPhotoHandlerThread.isAlive()) { + sPhotoHandlerThread.start(); + } + mPhotoHandler = new Handler(sPhotoHandlerThread.getLooper()); mPhotoCacheMap = new LruCache<Uri, byte[]>(PHOTO_CACHE_SIZE); } @@ -804,13 +807,14 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter return cursor; } - public void close() { + // TODO: This won't be used at all. We should find better way to quit the thread.. + /*public void close() { mEntries = null; mPhotoCacheMap.evictAll(); - if (!mPhotoHandlerThread.quit()) { + if (!sPhotoHandlerThread.quit()) { Log.w(TAG, "Failed to quit photo handler thread, ignoring it."); } - } + }*/ @Override public int getCount() { |