summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Attwell <brianattwell@google.com>2014-09-02 23:37:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-02 23:37:56 +0000
commit3c8a09988f454a78bbfaf490f6565d4a1d0321f6 (patch)
treed49e6cb5f8d51a8b1bebc6f334abce17b0f2f349 /src
parentac57338b0dbe5eb29f326fa1587e5d1fa98558a3 (diff)
parent30e1ef1927a1a21370b6b5dedd73540152062475 (diff)
downloadpackages_apps_Contacts-3c8a09988f454a78bbfaf490f6565d4a1d0321f6.tar.gz
packages_apps_Contacts-3c8a09988f454a78bbfaf490f6565d4a1d0321f6.tar.bz2
packages_apps_Contacts-3c8a09988f454a78bbfaf490f6565d4a1d0321f6.zip
Merge "Move contactInteractionsToEntries() off UI thread" into lmp-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/contacts/quickcontact/QuickContactActivity.java86
1 files changed, 57 insertions, 29 deletions
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 1707a3cdc..eb69f7ea1 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -83,7 +83,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.view.WindowManager;
-import android.widget.ImageView;
import android.widget.Toast;
import android.widget.Toolbar;
@@ -213,6 +212,7 @@ public class QuickContactActivity extends ContactsActivity {
private MultiShrinkScroller mScroller;
private SelectAccountDialogFragmentListener mSelectAccountFragmentListener;
private AsyncTask<Void, Void, Cp2DataCardModel> mEntriesAndActionsTask;
+ private AsyncTask<Void, Void, Void> mRecentDataTask;
/**
* The last copy of Cp2DataCardModel that was passed to {@link #populateContactAndAboutCard}.
*/
@@ -1774,41 +1774,66 @@ public class QuickContactActivity extends ContactsActivity {
private void bindRecentData() {
final List<ContactInteraction> allInteractions = new ArrayList<>();
- for (List<ContactInteraction> loaderInteractions : mRecentLoaderResults.values()) {
- allInteractions.addAll(loaderInteractions);
- }
+ final List<List<Entry>> interactionsWrapper = new ArrayList<>();
- // Sort the interactions by most recent
- Collections.sort(allInteractions, new Comparator<ContactInteraction>() {
+ mRecentDataTask = new AsyncTask<Void, Void, Void>() {
@Override
- public int compare(ContactInteraction a, ContactInteraction b) {
- return a.getInteractionDate() >= b.getInteractionDate() ? -1 : 1;
+ protected Void doInBackground(Void... params) {
+ Trace.beginSection("sort recent loader results");
+
+ for (List<ContactInteraction> loaderInteractions : mRecentLoaderResults.values()) {
+ allInteractions.addAll(loaderInteractions);
+ }
+
+ // Sort the interactions by most recent
+ Collections.sort(allInteractions, new Comparator<ContactInteraction>() {
+ @Override
+ public int compare(ContactInteraction a, ContactInteraction b) {
+ return a.getInteractionDate() >= b.getInteractionDate() ? -1 : 1;
+ }
+ });
+
+ Trace.endSection();
+ Trace.beginSection("contactInteractionsToEntries");
+
+ // Wrap each interaction in its own list so that an icon is displayed for each entry
+ for (Entry contactInteraction : contactInteractionsToEntries(allInteractions)) {
+ List<Entry> entryListWrapper = new ArrayList<>(1);
+ entryListWrapper.add(contactInteraction);
+ interactionsWrapper.add(entryListWrapper);
+ }
+
+ Trace.endSection();
+ return null;
}
- });
- // Wrap each interaction in its own list so that an icon is displayed for each entry
- List<List<Entry>> interactionsWrapper = new ArrayList<>();
- for (Entry contactInteraction : contactInteractionsToEntries(allInteractions)) {
- List<Entry> entryListWrapper = new ArrayList<>(1);
- entryListWrapper.add(contactInteraction);
- interactionsWrapper.add(entryListWrapper);
- }
- if (allInteractions.size() > 0) {
- mRecentCard.initialize(interactionsWrapper,
+ @Override
+ protected void onPostExecute(Void aVoid) {
+ super.onPostExecute(aVoid);
+ Trace.beginSection("initialize recents card");
+
+ if (allInteractions.size() > 0) {
+ mRecentCard.initialize(interactionsWrapper,
/* numInitialVisibleEntries = */ MIN_NUM_COLLAPSED_RECENT_ENTRIES_SHOWN,
/* isExpanded = */ mRecentCard.isExpanded(), /* isAlwaysExpanded = */ false,
- mExpandingEntryCardViewListener, mScroller);
- mRecentCard.setVisibility(View.VISIBLE);
- }
+ mExpandingEntryCardViewListener, mScroller);
+ mRecentCard.setVisibility(View.VISIBLE);
+ }
- // About card is initialized along with the contact card, but since it appears after
- // the recent card in the UI, we hold off until making it visible until the recent card
- // is also ready to avoid stuttering.
- if (mAboutCard.shouldShow()) {
- mAboutCard.setVisibility(View.VISIBLE);
- } else {
- mAboutCard.setVisibility(View.GONE);
- }
+ Trace.endSection();
+
+ // About card is initialized along with the contact card, but since it appears after
+ // the recent card in the UI, we hold off until making it visible until the recent
+ // card is also ready to avoid stuttering.
+ if (mAboutCard.shouldShow()) {
+ mAboutCard.setVisibility(View.VISIBLE);
+ } else {
+ mAboutCard.setVisibility(View.GONE);
+ }
+ mRecentDataTask = null;
+ }
+ };
+ mRecentDataTask.execute();
}
@Override
@@ -1822,6 +1847,9 @@ public class QuickContactActivity extends ContactsActivity {
// the entire process will be killed.
mEntriesAndActionsTask.cancel(/* mayInterruptIfRunning = */ false);
}
+ if (mRecentDataTask != null) {
+ mRecentDataTask.cancel(/* mayInterruptIfRunning = */ false);
+ }
}
/**