Add helper to simplify animation end listeners

This commit is contained in:
Alexander Bakker 2022-10-12 17:36:46 +02:00
parent 41eba76b05
commit 84e179f9d3
2 changed files with 40 additions and 33 deletions

View file

@ -0,0 +1,32 @@
package com.beemdevelopment.aegis.helpers;
import android.view.animation.Animation;
public class SimpleAnimationEndListener implements Animation.AnimationListener {
private final Listener _listener;
public SimpleAnimationEndListener(Listener listener) {
_listener = listener;
}
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (_listener != null) {
_listener.onAnimationEnd(animation);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
public interface Listener {
void onAnimationEnd(Animation animation);
}
}

View file

@ -37,6 +37,7 @@ import com.beemdevelopment.aegis.helpers.DropdownHelper;
import com.beemdevelopment.aegis.helpers.EditTextHelper;
import com.beemdevelopment.aegis.helpers.IconViewHelper;
import com.beemdevelopment.aegis.helpers.SafHelper;
import com.beemdevelopment.aegis.helpers.SimpleAnimationEndListener;
import com.beemdevelopment.aegis.helpers.SimpleTextWatcher;
import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
import com.beemdevelopment.aegis.icons.IconPack;
@ -380,40 +381,14 @@ public class EditEntryActivity extends AegisActivity {
fadeIn.setInterpolator(new AccelerateInterpolator());
fadeIn.setDuration(250);
fadeOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
fadeOut.setAnimationListener(new SimpleAnimationEndListener((a) -> {
_advancedSettingsHeader.setVisibility(View.GONE);
_advancedSettings.startAnimation(fadeIn);
}));
}
@Override
public void onAnimationEnd(Animation animation) {
_advancedSettingsHeader.setVisibility(View.GONE);
_advancedSettings.startAnimation(fadeIn);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
fadeIn.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
_advancedSettings.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
fadeIn.setAnimationListener(new SimpleAnimationEndListener((a) -> {
_advancedSettings.setVisibility(View.VISIBLE);
}));
}
private void updateGroupDropdownList() {