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