diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-28 02:35:07 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-28 02:35:07 +0000 |
commit | 281998c825ad48d842bb653e2f462719fdb0c1d9 (patch) | |
tree | bc8bfcce809257b3ddbb423a9808082292b9f6a3 /java/com/android/dialer/app/calllog/GroupingListAdapter.java | |
parent | fc81a030a7b4f6d4a497f71aed593d398795e7da (diff) | |
parent | 183cb71663320f16149d83eeebaff7795a4b55f2 (diff) |
Merge "Remove field prefixes."
Diffstat (limited to 'java/com/android/dialer/app/calllog/GroupingListAdapter.java')
-rw-r--r-- | java/com/android/dialer/app/calllog/GroupingListAdapter.java | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/java/com/android/dialer/app/calllog/GroupingListAdapter.java b/java/com/android/dialer/app/calllog/GroupingListAdapter.java index d1157206f..29a4d4e4a 100644 --- a/java/com/android/dialer/app/calllog/GroupingListAdapter.java +++ b/java/com/android/dialer/app/calllog/GroupingListAdapter.java @@ -32,7 +32,7 @@ import android.util.SparseIntArray; */ abstract class GroupingListAdapter extends RecyclerView.Adapter { - protected ContentObserver mChangeObserver = + protected ContentObserver changeObserver = new ContentObserver(new Handler()) { @Override public boolean deliverSelfNotifications() { @@ -44,21 +44,21 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { onContentChanged(); } }; - protected DataSetObserver mDataSetObserver = + protected DataSetObserver dataSetObserver = new DataSetObserver() { @Override public void onChanged() { notifyDataSetChanged(); } }; - private Cursor mCursor; + private Cursor cursor; /** * SparseIntArray, which maps the cursor position of the first element of a group to the size of * the group. The index of a key in this map corresponds to the list position of that group. */ - private SparseIntArray mGroupMetadata; + private SparseIntArray groupMetadata; - private int mItemCount; + private int itemCount; public GroupingListAdapter() { reset(); @@ -72,28 +72,28 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { protected abstract void onContentChanged(); public void changeCursor(Cursor cursor) { - if (cursor == mCursor) { + if (cursor == this.cursor) { return; } - if (mCursor != null) { - mCursor.unregisterContentObserver(mChangeObserver); - mCursor.unregisterDataSetObserver(mDataSetObserver); - mCursor.close(); + if (this.cursor != null) { + this.cursor.unregisterContentObserver(changeObserver); + this.cursor.unregisterDataSetObserver(dataSetObserver); + this.cursor.close(); } // Reset whenever the cursor is changed. reset(); - mCursor = cursor; + this.cursor = cursor; if (cursor != null) { - addGroups(mCursor); + addGroups(this.cursor); // Calculate the item count by subtracting group child counts from the cursor count. - mItemCount = mGroupMetadata.size(); + itemCount = groupMetadata.size(); - cursor.registerContentObserver(mChangeObserver); - cursor.registerDataSetObserver(mDataSetObserver); + cursor.registerContentObserver(changeObserver); + cursor.registerDataSetObserver(dataSetObserver); notifyDataSetChanged(); } } @@ -103,18 +103,18 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { * #addGroups} method. */ public void addGroup(int cursorPosition, int groupSize) { - int lastIndex = mGroupMetadata.size() - 1; - if (lastIndex < 0 || cursorPosition <= mGroupMetadata.keyAt(lastIndex)) { - mGroupMetadata.put(cursorPosition, groupSize); + int lastIndex = groupMetadata.size() - 1; + if (lastIndex < 0 || cursorPosition <= groupMetadata.keyAt(lastIndex)) { + groupMetadata.put(cursorPosition, groupSize); } else { // Optimization to avoid binary search if adding groups in ascending cursor position. - mGroupMetadata.append(cursorPosition, groupSize); + groupMetadata.append(cursorPosition, groupSize); } } @Override public int getItemCount() { - return mItemCount; + return itemCount; } /** @@ -122,11 +122,11 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { * position. */ public int getGroupSize(int listPosition) { - if (listPosition < 0 || listPosition >= mGroupMetadata.size()) { + if (listPosition < 0 || listPosition >= groupMetadata.size()) { return 0; } - return mGroupMetadata.valueAt(listPosition); + return groupMetadata.valueAt(listPosition); } /** @@ -134,20 +134,20 @@ abstract class GroupingListAdapter extends RecyclerView.Adapter { * corresponding to that position. */ public Object getItem(int listPosition) { - if (mCursor == null || listPosition < 0 || listPosition >= mGroupMetadata.size()) { + if (cursor == null || listPosition < 0 || listPosition >= groupMetadata.size()) { return null; } - int cursorPosition = mGroupMetadata.keyAt(listPosition); - if (mCursor.moveToPosition(cursorPosition)) { - return mCursor; + int cursorPosition = groupMetadata.keyAt(listPosition); + if (cursor.moveToPosition(cursorPosition)) { + return cursor; } else { return null; } } private void reset() { - mItemCount = 0; - mGroupMetadata = new SparseIntArray(); + itemCount = 0; + groupMetadata = new SparseIntArray(); } } |