summaryrefslogtreecommitdiff
path: root/src/com/android
diff options
context:
space:
mode:
authorHongwei Wang <hwwang@google.com>2013-09-04 21:58:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-04 21:58:55 +0000
commit6bf6d90f35f5245b844d685e58ae132e9a32bc03 (patch)
tree16e9ddf8ed3eebc8509c73794134ff2e810cf64b /src/com/android
parentf1f0df7120069399417a64f03cd4d38de05446bc (diff)
parentd954cd76c610e8fafd91aec857f4232ab49ef2cd (diff)
Merge "Restrict the cap # of frequents on home screen to 20" into klp-dev
Diffstat (limited to 'src/com/android')
-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;