diff options
author | Rohit Yengisetty <rohit@cyngn.com> | 2016-02-10 14:22:53 -0800 |
---|---|---|
committer | Richard MacGregor <rmacgregor@cyngn.com> | 2016-03-25 11:42:19 -0700 |
commit | 77f642f704c98ef3c41f9f35146c20bd5d347639 (patch) | |
tree | d34b63dbd3a6ec012bef82027e96c57887c239b3 /src | |
parent | 0531541afad86645f003a07df4f0f64a12455ffc (diff) | |
download | android_packages_apps_ContactsCommon-77f642f704c98ef3c41f9f35146c20bd5d347639.tar.gz android_packages_apps_ContactsCommon-77f642f704c98ef3c41f9f35146c20bd5d347639.tar.bz2 android_packages_apps_ContactsCommon-77f642f704c98ef3c41f9f35146c20bd5d347639.zip |
Extend LookupProvider APIs
- Adding blockingFetchInfo method to LookupProvider
- Adding StatusCode
Change-Id: Ifdc8ca04b1493cd3322abb646bfc8fc7b66cf694
Diffstat (limited to 'src')
3 files changed, 56 insertions, 2 deletions
diff --git a/src/com/cyanogen/lookup/phonenumber/contract/LookupProvider.java b/src/com/cyanogen/lookup/phonenumber/contract/LookupProvider.java index badc1bd1..652443f4 100644 --- a/src/com/cyanogen/lookup/phonenumber/contract/LookupProvider.java +++ b/src/com/cyanogen/lookup/phonenumber/contract/LookupProvider.java @@ -1,6 +1,7 @@ package com.cyanogen.lookup.phonenumber.contract; import com.cyanogen.lookup.phonenumber.request.LookupRequest; +import com.cyanogen.lookup.phonenumber.response.LookupResponse; /** * Notion of a phone number lookup provider @@ -25,6 +26,12 @@ public interface LookupProvider { void fetchInfo(LookupRequest request); /** + * Request the Provider for contact info. This call will block the current thread till + * the request completes. + */ + LookupResponse blockingFetchInfo(LookupRequest lookupRequest); + + /** * Explicit call to disable provider and free resources */ void disable(); diff --git a/src/com/cyanogen/lookup/phonenumber/response/LookupResponse.java b/src/com/cyanogen/lookup/phonenumber/response/LookupResponse.java index 1cb51c2b..55791542 100644 --- a/src/com/cyanogen/lookup/phonenumber/response/LookupResponse.java +++ b/src/com/cyanogen/lookup/phonenumber/response/LookupResponse.java @@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable; * ADT to store the result of a phone number lookup */ public class LookupResponse { + public StatusCode mStatusCode = StatusCode.NULL; public String mProviderName; public String mName; public String mNumber; @@ -14,12 +15,14 @@ public class LookupResponse { public String mAddress; public String mPhotoUrl; public int mSpamCount; + public boolean mIsSpam; public Drawable mAttributionLogo; @Override public String toString() { - return String.format("{ providerName = %s, name = %s, number = %s, city = %s, country = %s, address = %s, photo-url : %s, spam-count = %d}", + return String.format("{ statusCode = %s, providerName = %s, name = %s, number = %s, city = %s, country = %s, address = %s, photo-url : %s, spam-count = %d, isSpam = %b}", + mStatusCode, mProviderName != null ? mProviderName : "null" , mName != null ? mName : "null" , mNumber != null ? mNumber : "null" , @@ -27,6 +30,7 @@ public class LookupResponse { mCountry != null ? mCountry : "null" , mAddress != null ? mAddress : "null" , mPhotoUrl != null ? mPhotoUrl : "null" , - mSpamCount ); + mSpamCount, + mIsSpam); } }
\ No newline at end of file diff --git a/src/com/cyanogen/lookup/phonenumber/response/StatusCode.java b/src/com/cyanogen/lookup/phonenumber/response/StatusCode.java new file mode 100644 index 00000000..42a1c254 --- /dev/null +++ b/src/com/cyanogen/lookup/phonenumber/response/StatusCode.java @@ -0,0 +1,43 @@ +package com.cyanogen.lookup.phonenumber.response; + +/** + * Status code indicating the result of a lookup query + */ +public enum StatusCode { + + /** + * Default value + */ + NULL ("null - default value"), + + /** + * Error state wherein the lookup provider isn't configured properly + */ + CONFIG_ERROR ("configuration error"), + + /** + * Lookup request failed, maybe due to a network error + */ + FAIL ("request failed"), + + /** + * Lookup provider didn't find any results + */ + NO_RESULT ("no results found"), + + /** + * Lookup request succeeded + */ + SUCCESS ("request succeeded"); + + private final String mDescription; + + StatusCode(String description) { + mDescription = description; + } + + @Override + public String toString() { + return mDescription; + } +} |