From 49447a9859b6f45dd4eb4cb9302931c725257038 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Tue, 5 Aug 2014 19:28:34 -0700 Subject: Fix pinned positions handling in Dialer UI Bug: 16714956 Change-Id: I651056eceb2a10d7228548feedc29c5453230138 --- src/com/android/dialer/list/PhoneFavoritesTileAdapter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java index 7814718c2..382e42e56 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -609,11 +609,15 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements final int upperBound = Math.max(oldPos, newPinPos); for (int i = lowerBound; i <= upperBound; i++) { final ContactEntry entry = list.get(i); - if (entry.pinned == i) continue; + + // Pinned positions in the database start from 1 instead of being zero-indexed like + // arrays, so offset by 1. + final int databasePinnedPosition = i + 1; + if (entry.pinned == databasePinnedPosition) continue; final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(entry.id)); final ContentValues values = new ContentValues(); - values.put(Contacts.PINNED, i); + values.put(Contacts.PINNED, databasePinnedPosition); positions.add(ContentProviderOperation.newUpdate(uri).withValues(values).build()); } return positions; -- cgit v1.2.3