mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47:29 +00:00
Stop notification checker when app in background
This commit is contained in:
parent
b8278c0f99
commit
0fc2fe2faf
@ -70,6 +70,7 @@ import static awais.instagrabber.utils.Utils.notificationManager;
|
|||||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||||
|
|
||||||
public final class Main extends BaseLanguageActivity {
|
public final class Main extends BaseLanguageActivity {
|
||||||
|
private static final int INITIAL_DELAY_MILLIS = 200;
|
||||||
public static FetchListener<String> scanHack;
|
public static FetchListener<String> scanHack;
|
||||||
public static ItemGetter itemGetter;
|
public static ItemGetter itemGetter;
|
||||||
// -------- items --------
|
// -------- items --------
|
||||||
@ -117,6 +118,7 @@ public final class Main extends BaseLanguageActivity {
|
|||||||
private Stack<String> queriesStack;
|
private Stack<String> queriesStack;
|
||||||
private DataBox.CookieModel cookieModel;
|
private DataBox.CookieModel cookieModel;
|
||||||
private Runnable runnable;
|
private Runnable runnable;
|
||||||
|
private Handler handler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable final Bundle bundle) {
|
protected void onCreate(@Nullable final Bundle bundle) {
|
||||||
@ -257,7 +259,7 @@ public final class Main extends BaseLanguageActivity {
|
|||||||
|
|
||||||
mainHelper.onIntent(getIntent());
|
mainHelper.onIntent(getIntent());
|
||||||
|
|
||||||
final Handler handler = new Handler();
|
handler = new Handler();
|
||||||
runnable = () -> {
|
runnable = () -> {
|
||||||
final GetActivityAsyncTask activityAsyncTask = new GetActivityAsyncTask(uid, cookie, result -> {
|
final GetActivityAsyncTask activityAsyncTask = new GetActivityAsyncTask(uid, cookie, result -> {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -305,7 +307,7 @@ public final class Main extends BaseLanguageActivity {
|
|||||||
activityAsyncTask.execute();
|
activityAsyncTask.execute();
|
||||||
handler.postDelayed(runnable, 60000);
|
handler.postDelayed(runnable, 60000);
|
||||||
};
|
};
|
||||||
handler.postDelayed(runnable, 200);
|
handler.postDelayed(runnable, INITIAL_DELAY_MILLIS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadSelectedItems() {
|
private void downloadSelectedItems() {
|
||||||
@ -559,12 +561,18 @@ public final class Main extends BaseLanguageActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
if (mainHelper != null) mainHelper.onPause();
|
if (mainHelper != null) mainHelper.onPause();
|
||||||
|
if (handler != null && runnable != null) {
|
||||||
|
handler.removeCallbacks(runnable);
|
||||||
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
if (mainHelper != null) mainHelper.onResume();
|
if (mainHelper != null) mainHelper.onResume();
|
||||||
|
if (handler != null && runnable != null) {
|
||||||
|
handler.postDelayed(runnable, INITIAL_DELAY_MILLIS);
|
||||||
|
}
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user