Skip to content

Commit

Permalink
Change AnimatorEndListener to an abstract class, because default meth…
Browse files Browse the repository at this point in the history
…ods on an interface result in an unexpected opcode 00f8 message from dalvikvm on devices API <21.

Could be related to luontola/retrolambda#42
This means I can't use lambdas with animationEndListeners. Oh well.
(The brokenness of default methods on interfaces could also be the cause of the absurdities discovered in 98e0d2e).
  • Loading branch information
aphexcx committed Nov 14, 2015
1 parent defeae7 commit 40cfb77
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,14 @@ public Observable<Void> showConfirmAddress() {
Animator fade_in = AnimatorInflater.loadAnimator(getActivity(), R.animator.fade_in);

fade_in.setTarget(adaptableGradientRectView);
fade_in.addListener((AnimatorEndListener) animation -> {
subscriber.onNext(null);
subscriber.onCompleted();
fade_in.addListener(new AnimatorEndListener() {
@Override
public void onAnimationEnd(Animator animation) {
subscriber.onNext(null);
subscriber.onCompleted();
}
});

fade_in.start();
});
}
Expand Down Expand Up @@ -469,10 +473,13 @@ private Observable<Void> hideConfirmAddress() {

Animator fade_out = AnimatorInflater.loadAnimator(getActivity(), R.animator.fade_out);
fade_out.setTarget(adaptableGradientRectView);
fade_out.addListener((AnimatorEndListener) animation -> {
mConfirmAddressShowing = false;
subscriber.onNext(null);
subscriber.onCompleted();
fade_out.addListener(new AnimatorEndListener() {
@Override
public void onAnimationEnd(Animator animation) {
mConfirmAddressShowing = false;
subscriber.onNext(null);
subscriber.onCompleted();
}
});
fade_out.start();
});
Expand All @@ -488,10 +495,13 @@ private Observable<Void> showCategoryLayout() {
slidingRLContainer.setVisibility(View.VISIBLE);
Animator slideDownFromTop = AnimatorInflater.loadAnimator(getActivity(), R.animator.slide_down_from_top);
slideDownFromTop.setTarget(slidingRLContainer);
slideDownFromTop.addListener((AnimatorEndListener) animation -> {
buildCategoryGrid();
subscriber.onNext(null);
subscriber.onCompleted();
slideDownFromTop.addListener(new AnimatorEndListener() {
@Override
public void onAnimationEnd(Animator animation) {
buildCategoryGrid();
subscriber.onNext(null);
subscriber.onCompleted();
}
});
slideDownFromTop.start();
});
Expand All @@ -518,11 +528,14 @@ private Observable<Void> hideCategoryLayout() {

Animator slideUpToTop = AnimatorInflater.loadAnimator(getActivity(), R.animator.slide_up_to_top);
slideUpToTop.setTarget(slidingRLContainer);
slideUpToTop.addListener((AnimatorEndListener) animation -> {
slidingRLContainer.setVisibility(View.INVISIBLE);
mCategoryLayoutShowing = false;
subscriber.onNext(null);
subscriber.onCompleted();
slideUpToTop.addListener(new AnimatorEndListener() {
@Override
public void onAnimationEnd(Animator animation) {
slidingRLContainer.setVisibility(View.INVISIBLE);
mCategoryLayoutShowing = false;
subscriber.onNext(null);
subscriber.onCompleted();
}
});
slideUpToTop.start();
});
Expand Down Expand Up @@ -559,20 +572,23 @@ private Observable<Void> showCurrentRequestLayout() {

AnimatorSet set = new AnimatorSet();
set.play(slideDown).before(slideUp).with(fade_in);
set.addListener((AnimatorEndListener) animation -> {
btnBottomSubmit.setVisibility(View.GONE);
//LISTENER GETS CALLED TWICE.
animation.getListeners(); //THE FIX?!?!?!?!?!?!?
//(OR CALL ANY OTHER METHOD THAT ACCESSES A MEMBER VARIABLE OF animation
set.addListener(new AnimatorEndListener() {
@Override
public void onAnimationEnd(Animator animation) {
btnBottomSubmit.setVisibility(View.GONE);
//LISTENER GETS CALLED TWICE.
// animation.getListeners(); //THE FIX?!?!?!?!?!?!?
//(OR CALL ANY OTHER METHOD THAT ACCESSES A MEMBER VARIABLE OF animation

// Log.e(logTag(), "Adding items!!!!!" + animation.isStarted());
for (DonationCategory item : items) {
item.setSelected(true);
item.setClickable(false);
mCurrentRequestCategoriesAdapter.addItem(item);
for (DonationCategory item : items) {
item.setSelected(true);
item.setClickable(false);
mCurrentRequestCategoriesAdapter.addItem(item);
}
subscriber.onNext(null);
subscriber.onCompleted();
}
subscriber.onNext(null);
subscriber.onCompleted();
});
set.start();
});
Expand Down Expand Up @@ -614,14 +630,17 @@ private Observable<Void> hideCurrentRequestLayout() {

AnimatorSet set = new AnimatorSet();
set.play(fade_out).with(slideDown).before(slideUp);
set.addListener((AnimatorEndListener) animation -> {
set.addListener(new AnimatorEndListener() {
@Override
public void onAnimationEnd(Animator animation) {
// Log.e(logTag(), "Hiding currentREquestLayout!");
adaptableGradientRectView.setGradientColorTo(getResources().getColor(R.color.colorPrimaryLight));
rlCurrentRequestContainer.setVisibility(View.GONE);
btnBottomSubmit.setEnabled(true);
tsInfo.setText(getString(R.string.request_pickup_choose_location));
subscriber.onNext(null);
subscriber.onCompleted();
adaptableGradientRectView.setGradientColorTo(getResources().getColor(R.color.colorPrimaryLight));
rlCurrentRequestContainer.setVisibility(View.GONE);
btnBottomSubmit.setEnabled(true);
tsInfo.setText(getString(R.string.request_pickup_choose_location));
subscriber.onNext(null);
subscriber.onCompleted();
}
});
set.start();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@
/**
* Created by aphex on 11/10/15.
*/
public interface AnimatorEndListener extends Animator.AnimatorListener {
public abstract class AnimatorEndListener implements Animator.AnimatorListener {
@Override
default void onAnimationStart(Animator animation) {
public void onAnimationStart(Animator animation) {
Log.e("AEL", "STARTED" + animation);
}

@Override
void onAnimationEnd(Animator animation);

@Override
default void onAnimationCancel(Animator animation) {
public void onAnimationCancel(Animator animation) {
Log.e("AEL", "CANCELED" + animation);
}

@Override
default void onAnimationRepeat(Animator animation) {
public void onAnimationRepeat(Animator animation) {

}
}

0 comments on commit 40cfb77

Please sign in to comment.