Fix PhoneFavoritesTileAdapter.getCount()

getCount() was reporting an incorrect length when the number of
entries is less than mColumnCount * mMaxTiledRows

Change-Id: I4504b200c938f4bf1a230fc4c2f1bf06ebc5128c
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 91ad110..992cb1f 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -276,13 +276,16 @@
 
     @Override
     public int getCount() {
-        if (mContactEntries == null) {
+        if (mContactEntries == null || mContactEntries.isEmpty()) {
             return 0;
         }
 
         int total = mContactEntries.size();
-
-        return total - (mMaxTiledRows * (mColumnCount - 1));
+        // The number of contacts that don't show up as tiles
+        final int nonTiledRows = Math.max(0, total - getMaxContactsInTiles());
+        // The number of tiled rows
+        final int tiledRows = getRowCount(total - nonTiledRows);
+        return nonTiledRows + tiledRows;
     }
 
     public int getMaxTiledRows() {