Prevent crash

pull/171/head
M66B 5 years ago
parent 567681c08f
commit b478bebf58

@ -1288,7 +1288,7 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
protected void onExecuted(final Bundle args, EntityIdentity identity) { protected void onExecuted(final Bundle args, EntityIdentity identity) {
Helper.selectKeyAlias(getActivity(), identity.sign_key_alias, new Helper.IKeyAlias() { Helper.selectKeyAlias(getActivity(), getViewLifecycleOwner(), identity.sign_key_alias, new Helper.IKeyAlias() {
@Override @Override
public void onSelected(String alias) { public void onSelected(String alias) {
args.putString("alias", alias); args.putString("alias", alias);

@ -4062,7 +4062,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (auto && identity == null) if (auto && identity == null)
return; return;
Helper.selectKeyAlias(getActivity(), identity == null ? null : identity.sign_key_alias, new Helper.IKeyAlias() { String alias = (identity == null ? null : identity.sign_key_alias);
Helper.selectKeyAlias(getActivity(), getViewLifecycleOwner(), alias, new Helper.IKeyAlias() {
@Override @Override
public void onSelected(String alias) { public void onSelected(String alias) {
args.putString("alias", alias); args.putString("alias", alias);

@ -80,6 +80,8 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -845,7 +847,7 @@ public class Helper {
prefs.edit().remove("last_authentication").apply(); prefs.edit().remove("last_authentication").apply();
} }
static void selectKeyAlias(final Activity activity, final String email, final IKeyAlias intf) { static void selectKeyAlias(final Activity activity, final LifecycleOwner owner, final String email, final IKeyAlias intf) {
final Context context = activity.getApplicationContext(); final Context context = activity.getApplicationContext();
final Handler handler = new Handler(); final Handler handler = new Handler();
@ -859,6 +861,7 @@ public class Helper {
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
intf.onSelected(email); intf.onSelected(email);
} }
}); });
@ -880,6 +883,7 @@ public class Helper {
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
if (alias == null) if (alias == null)
intf.onNothingSelected(); intf.onNothingSelected();
else else

Loading…
Cancel
Save