Fixed temp memory leak

pull/207/head
M66B 3 years ago
parent 0abd3a0d03
commit a04025b8d0

@ -246,9 +246,9 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
if (Helper.shouldAuthenticate(this, false)) if (Helper.shouldAuthenticate(this, false))
Helper.authenticate(ActivityMain.this, ActivityMain.this, null, Helper.authenticate(ActivityMain.this, ActivityMain.this, null,
new Runnable() { new RunnableEx("auth:succeeded") {
@Override @Override
public void run() { public void delegate() {
Intent intent = getIntent(); Intent intent = getIntent();
Bundle args = new Bundle(); Bundle args = new Bundle();
if (intent.hasExtra("intent")) if (intent.hasExtra("intent"))
@ -256,9 +256,9 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
boot.execute(ActivityMain.this, args, "main:accounts"); boot.execute(ActivityMain.this, args, "main:accounts");
} }
}, },
new Runnable() { new RunnableEx("auth:cancelled") {
@Override @Override
public void run() { public void delegate() {
try { try {
finish(); finish();
} catch (Throwable ex) { } catch (Throwable ex) {

@ -259,29 +259,30 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
public void onClick(View v) { public void onClick(View v) {
final boolean biometrics = prefs.getBoolean("biometrics", false); final boolean biometrics = prefs.getBoolean("biometrics", false);
Helper.authenticate(getActivity(), getViewLifecycleOwner(), biometrics, new Runnable() { Helper.authenticate(getActivity(), getViewLifecycleOwner(), biometrics,
@Override new RunnableEx("auth:setup") {
public void run() { @Override
try { public void delegate() {
boolean pro = ActivityBilling.isPro(getContext()); try {
if (pro) { boolean pro = ActivityBilling.isPro(getContext());
SharedPreferences.Editor editor = prefs.edit(); if (pro) {
if (!biometrics) SharedPreferences.Editor editor = prefs.edit();
editor.remove("pin"); if (!biometrics)
editor.putBoolean("biometrics", !biometrics); editor.remove("pin");
editor.apply(); editor.putBoolean("biometrics", !biometrics);
} else editor.apply();
startActivity(new Intent(getContext(), ActivityBilling.class)); } else
} catch (Throwable ex) { startActivity(new Intent(getContext(), ActivityBilling.class));
Log.w(ex); } catch (Throwable ex) {
} Log.w(ex);
} }
}, new Runnable() { }
@Override }, new RunnableEx("auth:nothing") {
public void run() { @Override
// Do nothing public void delegate() {
} // Do nothing
}); }
});
} }
}); });

@ -2293,9 +2293,9 @@ public class Helper {
} }
if (!isCancelled(errorCode)) if (!isCancelled(errorCode))
ApplicationEx.getMainHandler().post(new Runnable() { ApplicationEx.getMainHandler().post(new RunnableEx("auth:error") {
@Override @Override
public void run() { public void delegate() {
ToastEx.makeText(activity, ToastEx.makeText(activity,
"Error " + errorCode + ": " + errString, "Error " + errorCode + ": " + errString,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
@ -2335,9 +2335,9 @@ public class Helper {
prompt.authenticate(info.build()); prompt.authenticate(info.build());
final Runnable cancelPrompt = new Runnable() { final Runnable cancelPrompt = new RunnableEx("auth:cancelprompt") {
@Override @Override
public void run() { public void delegate() {
try { try {
prompt.cancelAuthentication(); prompt.cancelAuthentication();
} catch (Throwable ex) { } catch (Throwable ex) {
@ -2352,7 +2352,12 @@ public class Helper {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroy() { public void onDestroy() {
Log.i("Authenticate destroyed"); Log.i("Authenticate destroyed");
ApplicationEx.getMainHandler().post(cancelPrompt); ApplicationEx.getMainHandler().removeCallbacks(cancelPrompt);
try {
prompt.cancelAuthentication();
} catch (Throwable ex) {
Log.e(ex);
}
owner.getLifecycle().removeObserver(this); owner.getLifecycle().removeObserver(this);
} }
}); });

Loading…
Cancel
Save