diff options
author | Anne Rong <annerong@google.com> | 2015-09-18 18:54:40 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-09-18 18:54:40 +0000 |
commit | fbb709bc08fb999760b94adfa1bcbc956532a4e2 (patch) | |
tree | 4b2ebfd3013fde4713e8d256b93acbac39672d4a | |
parent | 6399be26ac76454bb879283e742188f504965b19 (diff) | |
parent | 5d698e185f3a9afeda2c71a96c2ccd0be94f23d8 (diff) |
Merge "Refactor FilteredNumberAsyncQueryHandler.isBlocked" into ub-contactsdialer-a-dev
3 files changed, 28 insertions, 28 deletions
diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 7fc62a222..8b2eb6081 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -291,25 +291,22 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder .setOnMenuItemClickListener(this); } - try { - mFilteredNumberAsyncQueryHandler.isBlocked( - new FilteredNumberAsyncQueryHandler.OnCheckBlockedListener() { - @Override - public void onCheckComplete(Integer id) { - blockId = id; - int blockTitleId = blockId == null ? R.string.call_log_block_number - : R.string.call_log_unblock_number; - final MenuItem blockItem = menu.add( - ContextMenu.NONE, - R.id.context_menu_block_number, - ContextMenu.NONE, - blockTitleId); - blockItem.setOnMenuItemClickListener( - CallLogListItemViewHolder.this); - } - }, info.normalizedNumber, number, countryIso); - } catch (IllegalArgumentException e) { - } + mFilteredNumberAsyncQueryHandler.startBlockedQuery( + new FilteredNumberAsyncQueryHandler.OnCheckBlockedListener() { + @Override + public void onCheckComplete(Integer id) { + blockId = id; + int blockTitleId = blockId == null ? R.string.call_log_block_number + : R.string.call_log_unblock_number; + final MenuItem blockItem = menu.add( + ContextMenu.NONE, + R.id.context_menu_block_number, + ContextMenu.NONE, + blockTitleId); + blockItem.setOnMenuItemClickListener( + CallLogListItemViewHolder.this); + } + }, info.normalizedNumber, number, countryIso); } @Override diff --git a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java index 061d62883..0f33aa21c 100644 --- a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java +++ b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java @@ -109,16 +109,19 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { /** * Check if the number + country iso given has been blocked. * This method normalizes the number for the lookup if normalizedNumber is null. + * @return {@code true} if the number was invalid and couldn't be checked, + * {@code false} otherwise, */ - public final void isBlocked(final OnCheckBlockedListener listener, - String normalizedNumber, String number, String countryIso) { + public final boolean startBlockedQuery(final OnCheckBlockedListener listener, + String normalizedNumber, String number, String countryIso) { if (normalizedNumber == null) { normalizedNumber = getNormalizedNumber(number, countryIso); if (normalizedNumber == null) { - throw new IllegalArgumentException("Invalid phone number"); + return true; } } - isBlocked(listener, normalizedNumber); + startBlockedQuery(listener, normalizedNumber); + return false; } public static String getNormalizedNumber(String number, String countryIso) { @@ -132,8 +135,8 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { /** * Check if the normalized number given has been blocked. */ - public final void isBlocked(final OnCheckBlockedListener listener, - String normalizedNumber) { + public final void startBlockedQuery(final OnCheckBlockedListener listener, + String normalizedNumber) { startQuery(NO_TOKEN, new Listener() { @Override @@ -192,8 +195,8 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { /** * Removes row from database. - * Caller should call {@link FilteredNumberAsyncQueryHandler#isBlocked} first. - * @param id The ID of row to remove, from {@link FilteredNumberAsyncQueryHandler#isBlocked}. + * Caller should call {@link FilteredNumberAsyncQueryHandler#startBlockedQuery} first. + * @param id The ID of row to remove, from {@link FilteredNumberAsyncQueryHandler#startBlockedQuery}. */ public final void unblock(final OnUnblockNumberListener listener, Integer id) { if (id == null) { diff --git a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java index a65013ac6..69fba34d4 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java +++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java @@ -139,7 +139,7 @@ public class BlockedNumberFragment extends ListFragment implements } } }; - mFilteredNumberAsyncQueryHandler.isBlocked( + mFilteredNumberAsyncQueryHandler.startBlockedQuery( onCheckListener, normalizedNumber, number, countryIso); } } |