Merge pull request #437 from alexbakker/fix-copy-anim

Fix issue where the copy animation continued after view holder rebind
This commit is contained in:
Michael Schättgen 2020-06-06 12:24:26 +02:00 committed by GitHub
commit 95d5b4afa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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);
}
_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() {
_profileCopied.startAnimation(fadeOut);
_description.startAnimation(fadeIn);
}
_animationHandler.postDelayed(() -> {
_profileCopied.startAnimation(fadeOut);
_description.startAnimation(fadeIn);
}, 3000);
}