From 45bfb602b93fc706a05dddf8f7074caef6ea02d0 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 30 Nov 2019 12:54:47 +0200 Subject: [PATCH] move AsyncCrasher in its own file avoids implicit reference to parent activity class which may lead to memory leaks --- .../ui/activity/AsyncCrasher.java | 27 +++++++++++++++++++ .../ui/activity/NewTransactionActivity.java | 8 ------ 2 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/net/ktnx/mobileledger/ui/activity/AsyncCrasher.java diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/AsyncCrasher.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/AsyncCrasher.java new file mode 100644 index 00000000..ce02ff51 --- /dev/null +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/AsyncCrasher.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2019 Damyan Ivanov. + * This file is part of MoLe. + * MoLe is free software: you can distribute it and/or modify it + * under the term of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your opinion), any later version. + * + * MoLe is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License terms for details. + * + * You should have received a copy of the GNU General Public License + * along with MoLe. If not, see . + */ + +package net.ktnx.mobileledger.ui.activity; + +import android.os.AsyncTask; + +class AsyncCrasher extends AsyncTask { + @Override + protected Void doInBackground(Void... voids) { + throw new RuntimeException("Simulated crash"); + } +} diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java index 1317c438..d506ac35 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java @@ -17,7 +17,6 @@ package net.ktnx.mobileledger.ui.activity; -import android.os.AsyncTask; import android.os.Bundle; import android.util.TypedValue; import android.view.Menu; @@ -160,11 +159,4 @@ public class NewTransactionActivity extends ProfileThemedActivity implements Tas model.toggleSimulateSave(); } - private class AsyncCrasher extends AsyncTask { - @Override - protected Void doInBackground(Void... voids) { - throw new RuntimeException("Simulated crash"); - } - } - } -- 2.39.5