am 9eeb535f: Merge "Make message items aware of the various modes." into ics-mr1

* commit '9eeb535f6f8d940447755a0a31f7b0cc805b1028':
  Make message items aware of the various modes.
This commit is contained in:
Mindy Pereira 2011-11-18 15:23:08 -08:00 committed by Android Git Automerger
commit 7a7f544c0c
5 changed files with 26 additions and 5 deletions

View File

@ -372,6 +372,12 @@ public class MessageListFragment extends ListFragment
return root;
}
public void setLayout(ThreePaneLayout layout) {
if (UiUtilities.useTwoPane(mActivity)) {
mListAdapter.setLayout(layout);
}
}
private void initSearchHeader() {
if (mSearchHeader == null) {
ViewGroup root = (ViewGroup) getView();

View File

@ -56,6 +56,7 @@ public class MessageListItem extends View {
/* package */ long mMailboxId;
/* package */ long mAccountId;
private ThreePaneLayout mLayout;
private MessagesAdapter mAdapter;
private MessageListItemCoordinates mCoordinates;
private Context mContext;
@ -272,8 +273,9 @@ public class MessageListItem extends View {
private void updateBackground() {
final Drawable newBackground;
boolean isMultiPane = MessageListItemCoordinates.isMultiPane(mContext);
if (mRead) {
if (mMode == MODE_WIDE) {
if (isMultiPane && mLayout.isLeftPaneVisible()) {
if (mWideReadSelector == null) {
mWideReadSelector = getContext().getResources()
.getDrawable(R.drawable.conversation_wide_read_selector);
@ -287,7 +289,7 @@ public class MessageListItem extends View {
newBackground = mReadSelector;
}
} else {
if (mMode == MODE_WIDE) {
if (isMultiPane && mLayout.isLeftPaneVisible()) {
if (mWideUnreadSelector == null) {
mWideUnreadSelector = getContext().getResources().getDrawable(
R.drawable.conversation_wide_unread_selector);
@ -496,13 +498,15 @@ public class MessageListItem extends View {
* Called by the adapter at bindView() time
*
* @param adapter the adapter that creates this view
* @param layout If this is a three pane implementation, the
* ThreePaneLayout. Otherwise, null.
*/
public void bindViewInit(MessagesAdapter adapter) {
public void bindViewInit(MessagesAdapter adapter, ThreePaneLayout layout) {
mLayout = layout;
mAdapter = adapter;
requestLayout();
}
private static final int TOUCH_SLOP = 24;
private static int sScaledTouchSlop = -1;

View File

@ -123,6 +123,10 @@ public class MessageListItemCoordinates {
return mode;
}
public static boolean isMultiPane(Context context) {
return UiUtilities.useTwoPane(context);
}
/**
* Returns the layout id to be inflated in this mode.
*/

View File

@ -98,6 +98,8 @@ import java.util.Set;
private final Callback mCallback;
private ThreePaneLayout mLayout;
/**
* The actual return type from the loader.
*/
@ -134,6 +136,10 @@ import java.util.Set;
mCallback = callback;
}
public void setLayout(ThreePaneLayout layout) {
mLayout = layout;
}
public void onSaveInstanceState(Bundle outState) {
outState.putLongArray(STATE_CHECKED_ITEMS, Utility.toPrimitiveLongArray(getSelectedSet()));
}
@ -182,7 +188,7 @@ import java.util.Set;
public void bindView(View view, Context context, Cursor cursor) {
// Reset the view (in case it was recycled) and prepare for binding
MessageListItem itemView = (MessageListItem) view;
itemView.bindViewInit(this);
itemView.bindViewInit(this, mLayout);
// TODO: just move thise all to a MessageListItem.bindTo(cursor) so that the fields can
// be private, and their inter-dependence when they change can be abstracted away.

View File

@ -311,6 +311,7 @@ class UIControllerTwoPane extends UIControllerBase implements ThreePaneLayout.Ca
if (isMailboxListInstalled()) {
getMailboxListFragment().setHighlightedMailbox(fragment.getMailboxId());
}
getMessageListFragment().setLayout(mThreePane);
}
@Override