summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongwei Wang <hwwang@google.com>2013-09-04 14:01:28 -0700
committerHongwei Wang <hwwang@google.com>2013-09-04 14:45:49 -0700
commitd954cd76c610e8fafd91aec857f4232ab49ef2cd (patch)
treeff2afd9f54a3cdc45dcb7b6cb018b2c6fcf051dd
parent8c91efc5091f077d07e6a38fafa0076789e6eb07 (diff)
Restrict the cap # of frequents on home screen to 20
Bug: 10365481 - If the counter of starred contacts is less than 20, show maximum 20 starred + frequents - If the counter of starred contacts is no less than 20, show all the starred contacts only (no frequents) Change-Id: If2b9533446671f37e64caffd85e8db330b857ecd
-rw-r--r--src/com/android/dialer/list/PhoneFavoritesTileAdapter.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 263794f67..1c6ffde38 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -121,6 +121,15 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
private static final int PIN_LIMIT = 20;
+ /**
+ * The soft limit on how many contact tiles to show.
+ * NOTE This soft limit would not restrict the number of starred contacts to show, rather
+ * 1. If the count of starred contacts is less than this limit, show 20 tiles total.
+ * 2. If the count of starred contacts is more than or equal to this limit,
+ * show all starred tiles and no frequents.
+ */
+ private static final int TILES_SOFT_LIMIT = 20;
+
final Comparator<ContactEntry> mContactEntryComparator = new Comparator<ContactEntry>() {
@Override
public int compare(ContactEntry lhs, ContactEntry rhs) {
@@ -254,6 +263,9 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
final Object dummy = new Object();
+ // Track the length of {@link #mContactEntries} and compare to {@link #TILES_SOFT_LIMIT}.
+ int counter = 0;
+
while (cursor.moveToNext()) {
final int starred = cursor.getInt(mStarredIndex);
@@ -261,6 +273,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
if (starred > 0) {
id = cursor.getLong(mIdIndex);
+ } else if (counter >= TILES_SOFT_LIMIT) {
+ break;
} else {
// The contact id for frequent contacts is stored in the .contact_id field rather
// than the _id field
@@ -305,6 +319,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
contact.pinned = pinned;
mContactEntries.add(contact);
+
+ counter++;
}
mAwaitingRemove = false;