mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Make sure onSwitchComplete() is also called when animations are disabled
This commit is contained in:
parent
0febc8c312
commit
1244cc864a
@ -53,7 +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 com.fsck.k9.view.ViewSwitcher.OnSwitchCompleteListener;
|
||||||
|
|
||||||
import de.cketti.library.changelog.ChangeLog;
|
import de.cketti.library.changelog.ChangeLog;
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ import de.cketti.library.changelog.ChangeLog;
|
|||||||
*/
|
*/
|
||||||
public class MessageList extends K9FragmentActivity implements MessageListFragmentListener,
|
public class MessageList extends K9FragmentActivity implements MessageListFragmentListener,
|
||||||
MessageViewFragmentListener, OnBackStackChangedListener, OnSwipeGestureListener,
|
MessageViewFragmentListener, OnBackStackChangedListener, OnSwipeGestureListener,
|
||||||
OnAnimationEndListener {
|
OnSwitchCompleteListener {
|
||||||
|
|
||||||
// for this activity
|
// for this activity
|
||||||
private static final String EXTRA_SEARCH = "search";
|
private static final String EXTRA_SEARCH = "search";
|
||||||
@ -206,7 +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);
|
mViewSwitcher.setOnSwitchCompleteListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeActionBar();
|
initializeActionBar();
|
||||||
@ -1436,7 +1436,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(int displayedChild) {
|
public void onSwitchComplete(int displayedChild) {
|
||||||
if (displayedChild == 0) {
|
if (displayedChild == 0) {
|
||||||
removeMessageViewFragment();
|
removeMessageViewFragment();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class ViewSwitcher extends ViewAnimator implements AnimationListener {
|
|||||||
private Animation mFirstOutAnimation;
|
private Animation mFirstOutAnimation;
|
||||||
private Animation mSecondInAnimation;
|
private Animation mSecondInAnimation;
|
||||||
private Animation mSecondOutAnimation;
|
private Animation mSecondOutAnimation;
|
||||||
private OnAnimationEndListener mListener;
|
private OnSwitchCompleteListener mListener;
|
||||||
|
|
||||||
|
|
||||||
public ViewSwitcher(Context context) {
|
public ViewSwitcher(Context context) {
|
||||||
@ -35,6 +35,7 @@ public class ViewSwitcher extends ViewAnimator implements AnimationListener {
|
|||||||
|
|
||||||
setupAnimations(mFirstInAnimation, mFirstOutAnimation);
|
setupAnimations(mFirstInAnimation, mFirstOutAnimation);
|
||||||
setDisplayedChild(0);
|
setDisplayedChild(0);
|
||||||
|
handleSwitchCompleteCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showSecondView() {
|
public void showSecondView() {
|
||||||
@ -44,18 +45,26 @@ public class ViewSwitcher extends ViewAnimator implements AnimationListener {
|
|||||||
|
|
||||||
setupAnimations(mSecondInAnimation, mSecondOutAnimation);
|
setupAnimations(mSecondInAnimation, mSecondOutAnimation);
|
||||||
setDisplayedChild(1);
|
setDisplayedChild(1);
|
||||||
|
handleSwitchCompleteCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupAnimations(Animation in, Animation out) {
|
private void setupAnimations(Animation in, Animation out) {
|
||||||
if (K9.showAnimations()) {
|
if (K9.showAnimations()) {
|
||||||
setInAnimation(in);
|
setInAnimation(in);
|
||||||
setOutAnimation(out);
|
setOutAnimation(out);
|
||||||
|
out.setAnimationListener(this);
|
||||||
} else {
|
} else {
|
||||||
setInAnimation(null);
|
setInAnimation(null);
|
||||||
setOutAnimation(null);
|
setOutAnimation(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleSwitchCompleteCallback() {
|
||||||
|
if (!K9.showAnimations()) {
|
||||||
|
onAnimationEnd(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Animation getFirstInAnimation() {
|
public Animation getFirstInAnimation() {
|
||||||
return mFirstInAnimation;
|
return mFirstInAnimation;
|
||||||
}
|
}
|
||||||
@ -88,14 +97,14 @@ public class ViewSwitcher extends ViewAnimator implements AnimationListener {
|
|||||||
mSecondOutAnimation = outAnimation;
|
mSecondOutAnimation = outAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnAnimationEndListener(OnAnimationEndListener listener) {
|
public void setOnSwitchCompleteListener(OnSwitchCompleteListener listener) {
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animation animation) {
|
public void onAnimationEnd(Animation animation) {
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onAnimationEnd(getDisplayedChild());
|
mListener.onSwitchComplete(getDisplayedChild());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,13 +118,13 @@ public class ViewSwitcher extends ViewAnimator implements AnimationListener {
|
|||||||
// unused
|
// unused
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnAnimationEndListener {
|
public interface OnSwitchCompleteListener {
|
||||||
/**
|
/**
|
||||||
* This method will be called after the switch animation has ended.
|
* This method will be called after the switch (including animation) has ended.
|
||||||
*
|
*
|
||||||
* @param displayedChild
|
* @param displayedChild
|
||||||
* Contains the zero-based index of the child view that is now displayed.
|
* Contains the zero-based index of the child view that is now displayed.
|
||||||
*/
|
*/
|
||||||
void onAnimationEnd(int displayedChild);
|
void onSwitchComplete(int displayedChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user