diff options
Diffstat (limited to 'src/com/android/contacts/common/list/ContactTileAdapter.java')
-rw-r--r-- | src/com/android/contacts/common/list/ContactTileAdapter.java | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/com/android/contacts/common/list/ContactTileAdapter.java b/src/com/android/contacts/common/list/ContactTileAdapter.java index 789ca026..35f9f185 100644 --- a/src/com/android/contacts/common/list/ContactTileAdapter.java +++ b/src/com/android/contacts/common/list/ContactTileAdapter.java @@ -15,6 +15,7 @@ */ package com.android.contacts.common.list; +import android.accounts.Account; import android.content.ContentUris; import android.content.Context; import android.content.res.Resources; @@ -53,6 +54,11 @@ public class ContactTileAdapter extends BaseAdapter { protected int mNumFrequents; /** + * Get the layout width. + */ + private int nRTLWidth = 0; + + /** * Index of the first NON starred contact in the {@link Cursor} * Only valid when {@link DisplayType#STREQUENT} is true */ @@ -66,6 +72,8 @@ public class ContactTileAdapter extends BaseAdapter { protected int mNameIndex; protected int mPresenceIndex; protected int mStatusIndex; + private int mAccountTypeIndex; + private int mAccountNameIndex; private boolean mIsQuickContactEnabled = false; private final int mPaddingInPixels; @@ -148,6 +156,8 @@ public class ContactTileAdapter extends BaseAdapter { mStarredIndex = ContactTileLoaderFactory.STARRED; mPresenceIndex = ContactTileLoaderFactory.CONTACT_PRESENCE; mStatusIndex = ContactTileLoaderFactory.CONTACT_STATUS; + mAccountTypeIndex = ContactTileLoaderFactory.ACCOUNT_TYPE; + mAccountNameIndex = ContactTileLoaderFactory.ACCOUNT_NAME; } private static boolean cursorIsValid(Cursor cursor) { @@ -186,6 +196,9 @@ public class ContactTileAdapter extends BaseAdapter { * Else use {@link ContactTileLoaderFactory} */ public void setContactCursor(Cursor cursor) { + if (cursor == null || cursor.isClosed()) { + return; + } mContactCursor = cursor; mDividerPosition = getDividerPosition(cursor); @@ -270,6 +283,13 @@ public class ContactTileAdapter extends BaseAdapter { } contact.status = statusMessage; + if (!cursor.isNull(mAccountTypeIndex) && !cursor.isNull(mAccountTypeIndex)) { + final String accountType = cursor.getString(mAccountTypeIndex); + final String accountName = cursor.getString(mAccountNameIndex); + contact.account = new Account(accountName, accountType); + } else { + contact.account = null; + } return contact; } @@ -546,6 +566,7 @@ public class ContactTileAdapter extends BaseAdapter { protected void onLayout(boolean changed, int left, int top, int right, int bottom) { switch (mItemViewType) { case ViewTypes.STARRED: + nRTLWidth = right -left; onLayoutForTiles(); return; default: @@ -567,8 +588,15 @@ public class ContactTileAdapter extends BaseAdapter { // Note MeasuredWidth includes the padding. final int childWidth = child.getMeasuredWidth(); - child.layout(childLeft, 0, childLeft + childWidth, child.getMeasuredHeight()); - childLeft += childWidth; + + // Layout for RTL + if (child.isLayoutRtl()) { + child.layout(nRTLWidth -childWidth, 0, nRTLWidth, child.getMeasuredHeight()); + nRTLWidth -= childWidth; + }else{ + child.layout(childLeft, 0, childLeft + childWidth, child.getMeasuredHeight()); + childLeft += childWidth; + } } } |