diff options
author | Eric Erfanian <erfanian@google.com> | 2017-08-31 06:57:16 -0700 |
---|---|---|
committer | Roland Levillain <rpl@google.com> | 2017-09-04 18:05:19 +0100 |
commit | fc0eb8ccebcc7846db5e8b5c5430070055679bfa (patch) | |
tree | a8a23c3202e4161ffd57a71095a404db1bcf5735 /java/com/android/dialer/app/list/RegularSearchFragment.java | |
parent | ea7b4dc89590ffa3332766a531e0eab6ffb9aebd (diff) |
Update Dialer source to latest internal Google revision.
Previously, Android's Dialer app was developed in an internal Google
source control system and only exported to public during AOSP drops.
The Dialer team is now switching to a public development model similar
to the telephony team.
This CL represents all internal Google changes that were committed to
Dialer between the public O release and today's tip of tree on internal
master. This CL squashes those changes into a single commit.
In subsequent changes, changes will be exported on a per-commit basis.
(cherry picked from commit 2ca4318cc1ee57dda907ba2069bd61d162b1baef
and amended to match paths of dependencies under
prebuilts/maven_repo/bumptech/com/github/bumptech/glide/.)
This CL was generated using these commands from a repository at
stage-stage-master at revision ea7b4dc89590ffa3332766a531e0eab6ffb9aebd
("Merge "Update Dialer source to latest internal Google revision." am: c39ea3c55f -s ours"):
git diff --binary 2ca4318cc1ee57dda907ba2069bd61d162b1baef | git apply -R --index
git commit -c 2ca4318cc1ee57dda907ba2069bd61d162b1baef
Test: make, flash install, run
Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8
PiperOrigin-RevId: 167068436
Diffstat (limited to 'java/com/android/dialer/app/list/RegularSearchFragment.java')
-rw-r--r-- | java/com/android/dialer/app/list/RegularSearchFragment.java | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/java/com/android/dialer/app/list/RegularSearchFragment.java b/java/com/android/dialer/app/list/RegularSearchFragment.java index 728948bfc..73120c547 100644 --- a/java/com/android/dialer/app/list/RegularSearchFragment.java +++ b/java/com/android/dialer/app/list/RegularSearchFragment.java @@ -18,7 +18,10 @@ package com.android.dialer.app.list; import static android.Manifest.permission.READ_CONTACTS; import android.app.Activity; +import android.content.Context; import android.content.pm.PackageManager; +import android.os.Bundle; +import android.support.annotation.Nullable; import android.support.v13.app.FragmentCompat; import android.view.LayoutInflater; import android.view.ViewGroup; @@ -27,7 +30,11 @@ import com.android.contacts.common.list.PinnedHeaderListView; import com.android.dialer.app.R; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DialerExecutor; +import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DialerExecutors; import com.android.dialer.phonenumbercache.CachedNumberLookupService; +import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo; import com.android.dialer.phonenumbercache.PhoneNumberCache; import com.android.dialer.util.PermissionsUtil; import com.android.dialer.widget.EmptyContentView; @@ -43,6 +50,8 @@ public class RegularSearchFragment extends SearchFragment private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5; protected String mPermissionToRequest; + private DialerExecutor<CachedContactInfo> addContactTask; + public RegularSearchFragment() { configureDirectorySearch(); } @@ -53,6 +62,18 @@ public class RegularSearchFragment extends SearchFragment } @Override + public void onCreate(Bundle savedState) { + super.onCreate(savedState); + + addContactTask = + DialerExecutors.createUiTaskBuilder( + getFragmentManager(), + "RegularSearchFragment.addContact", + new AddContactWorker(getContext().getApplicationContext())) + .build(); + } + + @Override protected void onCreateView(LayoutInflater inflater, ViewGroup container) { super.onCreateView(inflater, container); ((PinnedHeaderListView) getListView()).setScrollToSectionOnHeaderTouch(true); @@ -73,8 +94,9 @@ public class RegularSearchFragment extends SearchFragment PhoneNumberCache.get(getContext()).getCachedNumberLookupService(); if (cachedNumberLookupService != null) { final RegularSearchListAdapter adapter = (RegularSearchListAdapter) getAdapter(); - cachedNumberLookupService.addContact( - getContext(), adapter.getContactInfo(cachedNumberLookupService, position)); + CachedContactInfo cachedContactInfo = + adapter.getContactInfo(cachedNumberLookupService, position); + addContactTask.executeSerial(cachedContactInfo); } } @@ -152,4 +174,24 @@ public class RegularSearchFragment extends SearchFragment boolean isNearbyPlacesSearchEnabled(); } + + private static class AddContactWorker implements Worker<CachedContactInfo, Void> { + + private final Context appContext; + + private AddContactWorker(Context appContext) { + this.appContext = appContext; + } + + @Nullable + @Override + public Void doInBackground(@Nullable CachedContactInfo contactInfo) throws Throwable { + CachedNumberLookupService cachedNumberLookupService = + PhoneNumberCache.get(appContext).getCachedNumberLookupService(); + if (cachedNumberLookupService != null) { + cachedNumberLookupService.addContact(appContext, contactInfo); + } + return null; + } + } } |