summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-10-03 22:19:11 -0700
committerAndrew Lee <anwlee@google.com>2015-10-03 22:25:08 -0700
commitebf615b14a200d87b72629dc40ae19780f1d0bec (patch)
tree9b4b3db33b57a3797796e1afe9d21202dca58092
parent7b127d43de0de29c27a9db19f0a7e792ac678c05 (diff)
Don't set FilteredNumberAsyncQueryHandler.
Rather than creating single instances and setting them or passing them around, create them when we need them. This won't happen too often so instantiating the objects shouldn't be too much of a burden on the system. Instances of AsyncQueryHandler all end up running tasks off the same thread, so there should not be a negative consequence of spinning off more threads. Bug: 24638328 Change-Id: If53ce4f1fd83736c330c1ff02946ed45da575796
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemViewHolder.java1
-rw-r--r--src/com/android/dialer/filterednumber/BlockedNumberAdapter.java7
-rw-r--r--src/com/android/dialer/filterednumber/BlockedNumberFragment.java7
-rw-r--r--src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java3
-rw-r--r--src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java8
-rw-r--r--src/com/android/dialer/list/BlockedListSearchAdapter.java7
-rw-r--r--src/com/android/dialer/list/BlockedListSearchFragment.java12
7 files changed, 17 insertions, 28 deletions
diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
index b90d285db..30aaee087 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java
@@ -316,7 +316,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder
FilterNumberDialogFragment newFragment =
FilterNumberDialogFragment.newInstance(blockId, info.normalizedNumber,
number, countryIso, displayNumber);
- newFragment.setQueryHandler(mFilteredNumberAsyncQueryHandler);
newFragment.setParentView(
((Activity) mContext).findViewById(R.id.floating_action_button_container));
newFragment.show(((Activity) mContext).getFragmentManager(),
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java b/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java
index 5041ed849..ad61a32b6 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberAdapter.java
@@ -35,7 +35,6 @@ import com.android.contacts.common.util.UriUtils;
import com.android.dialer.R;
import com.android.dialer.calllog.ContactInfo;
import com.android.dialer.calllog.ContactInfoHelper;
-import com.android.dialer.database.FilteredNumberAsyncQueryHandler;
import com.android.dialer.database.FilteredNumberContract.FilteredNumberColumns;
import com.android.dialer.util.PhoneNumberUtil;
@@ -46,16 +45,13 @@ public class BlockedNumberAdapter extends SimpleCursorAdapter {
private Resources mResources;
private BidiFormatter mBidiFormatter = BidiFormatter.getInstance();
private ContactPhotoManager mContactPhotoManager;
- private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
- public BlockedNumberAdapter(Context context,
- FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler) {
+ public BlockedNumberAdapter(Context context) {
super(context, R.layout.blocked_number_item, null, new String[]{}, new int[]{}, 0);
mContext = context;
mContactInfoHelper = new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context));
mContactPhotoManager = ContactPhotoManager.getInstance(context);
mResources = context.getResources();
- mFilteredNumberAsyncQueryHandler = filteredNumberAsyncQueryHandler;
}
@Override
@@ -88,7 +84,6 @@ public class BlockedNumberAdapter extends SimpleCursorAdapter {
FilterNumberDialogFragment newFragment =
FilterNumberDialogFragment.newInstance(id, normalizedNumber, number,
countryIso, displayNumber);
- newFragment.setQueryHandler(mFilteredNumberAsyncQueryHandler);
newFragment.setParentView(
((Activity) mContext).findViewById(R.id.blocked_number_fragment));
newFragment.show(((Activity) mContext).getFragmentManager(),
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
index de32fd612..79e5861dc 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java
@@ -34,17 +34,14 @@ public class BlockedNumberFragment extends ListFragment implements
LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener {
private BlockedNumberAdapter mAdapter;
- private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
LayoutInflater inflater = LayoutInflater.from(getContext());
getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null));
- mFilteredNumberAsyncQueryHandler =
- new FilteredNumberAsyncQueryHandler(getActivity().getContentResolver());
if (mAdapter == null) {
- mAdapter = new BlockedNumberAdapter(getContext(), mFilteredNumberAsyncQueryHandler);
+ mAdapter = new BlockedNumberAdapter(getContext());
}
setListAdapter(mAdapter);
getActivity().findViewById(R.id.add_number_button).setOnClickListener(this);
@@ -100,4 +97,4 @@ public class BlockedNumberFragment extends ListFragment implements
public void onClick(final View v) {
startActivity(new Intent(getActivity(), BlockedNumberSearchActivity.class));
}
-} \ No newline at end of file
+}
diff --git a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java b/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java
index 11c0ac4bc..cfa404f05 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java
@@ -126,7 +126,6 @@ public class BlockedNumberSearchActivity extends AppCompatActivity
fragment.setHasOptionsMenu(false);
fragment.setShowEmptyListForNullQuery(true);
fragment.setDirectorySearchEnabled(false);
- fragment.setFilteredNumberAsyncQueryHandler(mFilteredNumberAsyncQueryHandler);
transaction.commit();
}
@@ -161,4 +160,4 @@ public class BlockedNumberSearchActivity extends AppCompatActivity
public int getActionBarHeight() {
return getResources().getDimensionPixelSize(R.dimen.action_bar_height_large);
}
-} \ No newline at end of file
+}
diff --git a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
index 1b953875c..ce2a0da06 100644
--- a/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
+++ b/src/com/android/dialer/filterednumber/FilterNumberDialogFragment.java
@@ -61,10 +61,6 @@ public class FilterNumberDialogFragment extends DialogFragment {
public void onUndoBlockComplete();
}
- public void setQueryHandler (FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler) {
- mHandler = filteredNumberAsyncQueryHandler;
- }
-
public void setParentView(View view) {
mParentView = view;
}
@@ -98,6 +94,8 @@ public class FilterNumberDialogFragment extends DialogFragment {
final boolean isBlocked = getArguments().containsKey(ARG_BLOCK_ID);
final String displayNumber = getArguments().getString(ARG_DISPLAY_NUMBER);
+ mHandler = new FilteredNumberAsyncQueryHandler(getContext().getContentResolver());
+
String message;
String okText;
if (isBlocked) {
@@ -194,4 +192,4 @@ public class FilterNumberDialogFragment extends DialogFragment {
}
}, getArguments().getInt(ARG_BLOCK_ID));
}
-} \ No newline at end of file
+}
diff --git a/src/com/android/dialer/list/BlockedListSearchAdapter.java b/src/com/android/dialer/list/BlockedListSearchAdapter.java
index 7ae24e468..8f7971fcd 100644
--- a/src/com/android/dialer/list/BlockedListSearchAdapter.java
+++ b/src/com/android/dialer/list/BlockedListSearchAdapter.java
@@ -39,10 +39,9 @@ public class BlockedListSearchAdapter extends RegularSearchListAdapter {
mResources = context.getResources();
disableAllShortcuts();
setShortcutEnabled(SHORTCUT_BLOCK_NUMBER, true);
- }
- public void setFilteredNumberAsyncQueryHandler(FilteredNumberAsyncQueryHandler handler) {
- mFilteredNumberAsyncQueryHandler = handler;
+ mFilteredNumberAsyncQueryHandler =
+ new FilteredNumberAsyncQueryHandler(context.getContentResolver());
}
@Override
@@ -86,4 +85,4 @@ public class BlockedListSearchAdapter extends RegularSearchListAdapter {
mFilteredNumberAsyncQueryHandler.startBlockedQuery(
onCheckListener, normalizedNumber, number, countryIso);
}
-} \ No newline at end of file
+}
diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java
index 7494372fb..675081254 100644
--- a/src/com/android/dialer/list/BlockedListSearchFragment.java
+++ b/src/com/android/dialer/list/BlockedListSearchFragment.java
@@ -18,6 +18,7 @@ package com.android.dialer.list;
import android.content.ContentUris;
import android.content.ContentValues;
import android.net.Uri;
+import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
@@ -37,16 +38,19 @@ public class BlockedListSearchFragment extends RegularSearchFragment {
private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler;
- public void setFilteredNumberAsyncQueryHandler(FilteredNumberAsyncQueryHandler handler) {
- mFilteredNumberAsyncQueryHandler = handler;
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mFilteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(
+ getContext().getContentResolver());
}
+
@Override
protected ContactEntryListAdapter createListAdapter() {
BlockedListSearchAdapter adapter = new BlockedListSearchAdapter(getActivity());
adapter.setDisplayPhotos(true);
adapter.setUseCallableUri(usesCallableUri());
- adapter.setFilteredNumberAsyncQueryHandler(mFilteredNumberAsyncQueryHandler);
return adapter;
}
@@ -100,7 +104,6 @@ public class BlockedListSearchFragment extends RegularSearchFragment {
if (id == null) {
final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment
.newInstance(id, normalizedNumber, number, countryIso, number);
- newFragment.setQueryHandler(mFilteredNumberAsyncQueryHandler);
newFragment.setParentView(
getActivity().findViewById(R.id.search_activity_container));
newFragment.show(
@@ -133,7 +136,6 @@ public class BlockedListSearchFragment extends RegularSearchFragment {
}
final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment
.newInstance(blockId, normalizedNumber, number, countryIso, number);
- newFragment.setQueryHandler(mFilteredNumberAsyncQueryHandler);
newFragment.setParentView(getActivity().findViewById(R.id.search_activity_container));
newFragment.setOnUndoBlockListener(new FilterNumberDialogFragment.OnUndoBlockListener() {
@Override