Fix issue where the copy animation continued after view holder rebind

This commit is contained in:
Alexander Bakker 2020-05-25 12:02:21 +02:00
parent 6a2992530e
commit 63f57667ba

View file

@ -68,6 +68,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_buttonRefresh = view.findViewById(R.id.buttonRefresh);
_selected = view.findViewById(R.id.ivSelected);
_selectedHandler = new Handler();
_animationHandler = new Handler();
_progressBar = view.findViewById(R.id.progressBar);
int primaryColorId = view.getContext().getResources().getColor(R.color.colorPrimary);
@ -106,6 +107,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_selected.clearAnimation();
_selected.setVisibility(View.GONE);
_selectedHandler.removeCallbacksAndMessages(null);
_animationHandler.removeCallbacksAndMessages(null);
// only show the progress bar if there is no uniform period and the entry type is TotpInfo
setShowProgress(showProgress);
@ -246,9 +248,8 @@ public class EntryHolder extends RecyclerView.ViewHolder {
}
public void animateCopyText() {
if (_animationHandler != null) {
_animationHandler.removeCallbacksAndMessages(null);
}
Animation slideDownFadeIn = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.slide_down_fade_in);
Animation slideDownFadeOut = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.slide_down_fade_out);
Animation fadeOut = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.fade_out);
@ -257,14 +258,9 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_profileCopied.startAnimation(slideDownFadeIn);
_description.startAnimation(slideDownFadeOut);
_animationHandler = new Handler();
_animationHandler.postDelayed(new Runnable() {
@Override
public void run() {
_animationHandler.postDelayed(() -> {
_profileCopied.startAnimation(fadeOut);
_description.startAnimation(fadeIn);
}
}, 3000);
}