1 /* 2 * Copyright (C) 2012 Google Inc. 3 * Licensed to The Android Open Source Project. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.mail.browse; 19 20 import android.animation.Animator; 21 import android.animation.Animator.AnimatorListener; 22 import android.content.Context; 23 import android.widget.FrameLayout; 24 import android.widget.ListView; 25 26 import com.android.mail.providers.Account; 27 import com.android.mail.providers.Conversation; 28 import com.android.mail.providers.Folder; 29 import com.android.mail.ui.AnimatedAdapter; 30 import com.android.mail.ui.ControllableActivity; 31 import com.android.mail.ui.ConversationCheckedSet; 32 33 public class SwipeableConversationItemView extends FrameLayout implements ToggleableItem { 34 35 private final ConversationItemView mConversationItemView; 36 SwipeableConversationItemView(Context context, Account account)37 public SwipeableConversationItemView(Context context, Account account) { 38 super(context); 39 mConversationItemView = new ConversationItemView(context, account); 40 addView(mConversationItemView); 41 } 42 getListView()43 public ListView getListView() { 44 return (ListView) getParent(); 45 } 46 reset()47 public void reset() { 48 mConversationItemView.reset(); 49 } 50 getSwipeableItemView()51 public ConversationItemView getSwipeableItemView() { 52 return mConversationItemView; 53 } 54 bind(final Conversation conversation, final ControllableActivity activity, final ConversationCheckedSet set, final Folder folder, final int checkboxOrSenderImage, boolean swipeEnabled, final boolean importanceMarkersEnabled, final boolean showChevronsEnabled, final AnimatedAdapter animatedAdapter)55 public void bind(final Conversation conversation, final ControllableActivity activity, 56 final ConversationCheckedSet set, final Folder folder, 57 final int checkboxOrSenderImage, boolean swipeEnabled, 58 final boolean importanceMarkersEnabled, final boolean showChevronsEnabled, 59 final AnimatedAdapter animatedAdapter) { 60 mConversationItemView.bind(conversation, activity, set, folder, checkboxOrSenderImage, 61 swipeEnabled, importanceMarkersEnabled, showChevronsEnabled, animatedAdapter); 62 } 63 startUndoAnimation(AnimatorListener listener, boolean swipe)64 public void startUndoAnimation(AnimatorListener listener, boolean swipe) { 65 final Animator a = (swipe) ? mConversationItemView.createSwipeUndoAnimation() 66 : mConversationItemView.createUndoAnimation(); 67 a.addListener(listener); 68 a.start(); 69 } 70 startDeleteAnimation(AnimatorListener listener, boolean swipe)71 public void startDeleteAnimation(AnimatorListener listener, boolean swipe) { 72 final Animator a = (swipe) ? mConversationItemView.createDestroyWithSwipeAnimation() 73 : mConversationItemView.createDestroyAnimation(); 74 a.addListener(listener); 75 a.start(); 76 } 77 78 @Override toggleCheckedState(String sourceForAnalytics)79 public boolean toggleCheckedState(String sourceForAnalytics) { 80 return mConversationItemView.toggleCheckedState(sourceForAnalytics); 81 } 82 83 @Override toggleCheckedState()84 public boolean toggleCheckedState() { 85 return mConversationItemView.toggleCheckedState(); 86 } 87 } 88