From 5b1e5b18f93bad367e9c57b8548184998d9cab0d Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Thu, 12 Nov 2015 10:47:42 -0800 Subject: [PATCH] reset contact selection after batch invite fixes #4452 Closes #4498 // FREEBIE --- .../securesms/InviteActivity.java | 13 ++++++- .../thoughtcrime/securesms/util/ViewUtil.java | 38 ++++++++++++------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/org/thoughtcrime/securesms/InviteActivity.java b/src/org/thoughtcrime/securesms/InviteActivity.java index ccb0873b2b..ff7efa04fc 100644 --- a/src/org/thoughtcrime/securesms/InviteActivity.java +++ b/src/org/thoughtcrime/securesms/InviteActivity.java @@ -34,6 +34,9 @@ import org.thoughtcrime.securesms.sms.MessageSender; import org.thoughtcrime.securesms.sms.OutgoingTextMessage; import org.thoughtcrime.securesms.util.ProgressDialogAsyncTask; import org.thoughtcrime.securesms.util.ViewUtil; +import org.thoughtcrime.securesms.util.concurrent.ListenableFuture.Listener; + +import java.util.concurrent.ExecutionException; public class InviteActivity extends PassphraseRequiredActionBarActivity implements ContactSelectionListFragment.OnContactSelectedListener { @@ -241,7 +244,15 @@ public class InviteActivity extends PassphraseRequiredActionBarActivity implemen final Context context = getContext(); if (context == null) return; - ViewUtil.animateOut(smsSendFrame, slideOutAnimation); + ViewUtil.animateOut(smsSendFrame, slideOutAnimation).addListener(new Listener() { + @Override + public void onSuccess(Boolean result) { + contactsFragment.reset(); + } + + @Override + public void onFailure(ExecutionException e) {} + }); Toast.makeText(context, R.string.InviteActivity_invitations_sent, Toast.LENGTH_LONG).show(); } } diff --git a/src/org/thoughtcrime/securesms/util/ViewUtil.java b/src/org/thoughtcrime/securesms/util/ViewUtil.java index fdfbfa943d..8c2016a43b 100644 --- a/src/org/thoughtcrime/securesms/util/ViewUtil.java +++ b/src/org/thoughtcrime/securesms/util/ViewUtil.java @@ -37,6 +37,9 @@ import android.view.animation.Animation; import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; +import org.thoughtcrime.securesms.util.concurrent.ListenableFuture; +import org.thoughtcrime.securesms.util.concurrent.SettableFuture; + public class ViewUtil { @SuppressWarnings("deprecation") public static void setBackground(final @NonNull View v, final @Nullable Drawable drawable) { @@ -130,21 +133,30 @@ public class ViewUtil { animateOut(view, getAlphaAnimation(1f, 0f, duration)); } - public static void animateOut(final @NonNull View view, final @NonNull Animation animation) { - if (view.getVisibility() == View.GONE) return; + public static ListenableFuture animateOut(final @NonNull View view, final @NonNull Animation animation) { + final SettableFuture future = new SettableFuture(); + if (view.getVisibility() == View.GONE) { + future.set(true); + } else { + view.clearAnimation(); + animation.reset(); + animation.setStartTime(0); + animation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) {} - view.clearAnimation(); - animation.reset(); - animation.setStartTime(0); - animation.setAnimationListener(new Animation.AnimationListener() { - @Override public void onAnimationStart(Animation animation) {} - @Override public void onAnimationRepeat(Animation animation) {} - @Override public void onAnimationEnd(Animation animation) { - view.setVisibility(View.GONE); - } - }); + @Override + public void onAnimationRepeat(Animation animation) {} - view.startAnimation(animation); + @Override + public void onAnimationEnd(Animation animation) { + view.setVisibility(View.GONE); + future.set(true); + } + }); + view.startAnimation(animation); + } + return future; } public static void animateIn(final @NonNull View view, final @NonNull Animation animation) {