mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-17 07:30:16 -05:00
Only remove message view fragment after animation is complete
This commit is contained in:
parent
473aebefdb
commit
3286cea148
@ -53,6 +53,7 @@ import com.fsck.k9.search.SearchSpecification.SearchCondition;
|
|||||||
import com.fsck.k9.view.MessageHeader;
|
import com.fsck.k9.view.MessageHeader;
|
||||||
import com.fsck.k9.view.MessageTitleView;
|
import com.fsck.k9.view.MessageTitleView;
|
||||||
import com.fsck.k9.view.ViewSwitcher;
|
import com.fsck.k9.view.ViewSwitcher;
|
||||||
|
import com.fsck.k9.view.ViewSwitcher.OnAnimationEndListener;
|
||||||
|
|
||||||
import de.cketti.library.changelog.ChangeLog;
|
import de.cketti.library.changelog.ChangeLog;
|
||||||
|
|
||||||
@ -63,7 +64,8 @@ import de.cketti.library.changelog.ChangeLog;
|
|||||||
* From this Activity the user can perform all standard message operations.
|
* From this Activity the user can perform all standard message operations.
|
||||||
*/
|
*/
|
||||||
public class MessageList extends K9FragmentActivity implements MessageListFragmentListener,
|
public class MessageList extends K9FragmentActivity implements MessageListFragmentListener,
|
||||||
MessageViewFragmentListener, OnBackStackChangedListener, OnSwipeGestureListener {
|
MessageViewFragmentListener, OnBackStackChangedListener, OnSwipeGestureListener,
|
||||||
|
OnAnimationEndListener {
|
||||||
|
|
||||||
// for this activity
|
// for this activity
|
||||||
private static final String EXTRA_SEARCH = "search";
|
private static final String EXTRA_SEARCH = "search";
|
||||||
@ -204,6 +206,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
mViewSwitcher.setFirstOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_right));
|
mViewSwitcher.setFirstOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_right));
|
||||||
mViewSwitcher.setSecondInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right));
|
mViewSwitcher.setSecondInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right));
|
||||||
mViewSwitcher.setSecondOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_left));
|
mViewSwitcher.setSecondOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_left));
|
||||||
|
mViewSwitcher.setOnAnimationEndListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeActionBar();
|
initializeActionBar();
|
||||||
@ -1362,7 +1365,6 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
mMessageListFragment.setActiveMessage(null);
|
mMessageListFragment.setActiveMessage(null);
|
||||||
|
|
||||||
showDefaultTitleView();
|
showDefaultTitleView();
|
||||||
removeMessageViewFragment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMessageView() {
|
private void showMessageView() {
|
||||||
@ -1427,4 +1429,11 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
mMessageViewFragment.updateTitle();
|
mMessageViewFragment.updateTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(int displayedChild) {
|
||||||
|
if (displayedChild == 0) {
|
||||||
|
removeMessageViewFragment();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,19 @@ package com.fsck.k9.view;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.Animation.AnimationListener;
|
||||||
import android.widget.ViewAnimator;
|
import android.widget.ViewAnimator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link ViewAnimator} that animates between two child views using different animations
|
* A {@link ViewAnimator} that animates between two child views using different animations
|
||||||
* depending on which view is displayed.
|
* depending on which view is displayed.
|
||||||
*/
|
*/
|
||||||
public class ViewSwitcher extends ViewAnimator {
|
public class ViewSwitcher extends ViewAnimator implements AnimationListener {
|
||||||
private Animation mFirstInAnimation;
|
private Animation mFirstInAnimation;
|
||||||
private Animation mFirstOutAnimation;
|
private Animation mFirstOutAnimation;
|
||||||
private Animation mSecondInAnimation;
|
private Animation mSecondInAnimation;
|
||||||
private Animation mSecondOutAnimation;
|
private Animation mSecondOutAnimation;
|
||||||
|
private OnAnimationEndListener mListener;
|
||||||
|
|
||||||
|
|
||||||
public ViewSwitcher(Context context) {
|
public ViewSwitcher(Context context) {
|
||||||
@ -75,4 +77,35 @@ public class ViewSwitcher extends ViewAnimator {
|
|||||||
public void setSecondOutAnimation(Animation outAnimation) {
|
public void setSecondOutAnimation(Animation outAnimation) {
|
||||||
mSecondOutAnimation = outAnimation;
|
mSecondOutAnimation = outAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnAnimationEndListener(OnAnimationEndListener listener) {
|
||||||
|
mListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
if (mListener != null) {
|
||||||
|
mListener.onAnimationEnd(getDisplayedChild());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) {
|
||||||
|
// unused
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) {
|
||||||
|
// unused
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnAnimationEndListener {
|
||||||
|
/**
|
||||||
|
* This method will be called after the switch animation has ended.
|
||||||
|
*
|
||||||
|
* @param displayedChild
|
||||||
|
* Contains the zero-based index of the child view that is now displayed.
|
||||||
|
*/
|
||||||
|
void onAnimationEnd(int displayedChild);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user