mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 02:53:09 +01:00
Fix new version check still occassionally started in background
This commit is contained in:
parent
5fcc3b4dab
commit
28c72e7f63
@ -65,6 +65,7 @@ public class App extends MultiDexApplication {
|
||||
public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID;
|
||||
private static final String TAG = App.class.toString();
|
||||
private static App app;
|
||||
private static boolean wasAppInForeground = false;
|
||||
|
||||
@NonNull
|
||||
public static App getApp() {
|
||||
@ -254,4 +255,12 @@ public class App extends MultiDexApplication {
|
||||
protected boolean isDisposedRxExceptionsReported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean wasAppInForeground() {
|
||||
return wasAppInForeground;
|
||||
}
|
||||
|
||||
public static void setWasAppInForeground(final boolean wasAppInForeground) {
|
||||
App.wasAppInForeground = wasAppInForeground;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
package org.schabi.newpipe;
|
||||
|
||||
import static org.schabi.newpipe.CheckForNewAppVersion.startNewVersionCheckService;
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@ -93,8 +94,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private static final String TAG = "MainActivity";
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@ -165,9 +164,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
FocusOverlayView.setupFocusObserver(this);
|
||||
}
|
||||
openMiniPlayerUponPlayerStarted();
|
||||
|
||||
// Check for new version
|
||||
startNewVersionCheckService();
|
||||
}
|
||||
|
||||
private void setupDrawer() throws Exception {
|
||||
@ -520,6 +516,19 @@ public class MainActivity extends AppCompatActivity {
|
||||
getString(R.string.enable_watch_history_key), true);
|
||||
drawerLayoutBinding.navigation.getMenu().findItem(ITEM_ID_HISTORY)
|
||||
.setVisible(isHistoryEnabled);
|
||||
|
||||
if (!App.wasAppInForeground()) {
|
||||
// Check for new app version
|
||||
// The service searching for a new NewPipe version must not be started in background
|
||||
// and therefore needs to be placed in onResume().
|
||||
// Only start the service once when app is started
|
||||
// and not everytime onResume() is called.
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "App is in foreground for the first time");
|
||||
}
|
||||
App.setWasAppInForeground(true);
|
||||
startNewVersionCheckService();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user