only first trigger initial repo update if it is not already happening
I was seeing double index updates on first start.
This commit is contained in:
parent
0d386b824f
commit
048d5531be
@ -84,6 +84,7 @@ public class UpdateService extends JobIntentService {
|
|||||||
|
|
||||||
private static final int NOTIFY_ID_UPDATING = 0;
|
private static final int NOTIFY_ID_UPDATING = 0;
|
||||||
|
|
||||||
|
private static UpdateService updateService;
|
||||||
private static Handler toastHandler;
|
private static Handler toastHandler;
|
||||||
|
|
||||||
private NotificationManager notificationManager;
|
private NotificationManager notificationManager;
|
||||||
@ -189,6 +190,8 @@ public class UpdateService extends JobIntentService {
|
|||||||
/**
|
/**
|
||||||
* Whether or not a repo update is currently in progress. Used to show feedback throughout
|
* Whether or not a repo update is currently in progress. Used to show feedback throughout
|
||||||
* the app to users, so they know something is happening.
|
* the app to users, so they know something is happening.
|
||||||
|
*
|
||||||
|
* @see <a href="https://stackoverflow.com/a/608600">set a global variable when it is running that your client can check</a>
|
||||||
*/
|
*/
|
||||||
public static boolean isUpdating() {
|
public static boolean isUpdating() {
|
||||||
return updateService != null;
|
return updateService != null;
|
||||||
@ -240,8 +243,6 @@ public class UpdateService extends JobIntentService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UpdateService updateService;
|
|
||||||
|
|
||||||
public static void stopNow(Context context) {
|
public static void stopNow(Context context) {
|
||||||
if (updateService != null) {
|
if (updateService != null) {
|
||||||
updateService.stopSelf(JOB_ID);
|
updateService.stopSelf(JOB_ID);
|
||||||
|
@ -158,13 +158,8 @@ public class MainActivity extends AppCompatActivity implements BottomNavigationB
|
|||||||
bottomNavigation.selectTab(adapter.adapterPositionFromItemId(selectedMenuId));
|
bottomNavigation.selectTab(adapter.adapterPositionFromItemId(selectedMenuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The first time the app is run, we will have an empty app list. To deal with this, we will
|
|
||||||
* attempt to update with the default repo. However, if we have tried this at least once, then
|
|
||||||
* don't try to do it automatically again.
|
|
||||||
*/
|
|
||||||
private void initialRepoUpdateIfRequired() {
|
private void initialRepoUpdateIfRequired() {
|
||||||
if (!Preferences.get().isIndexNeverUpdated()) {
|
if (Preferences.get().isIndexNeverUpdated() && !UpdateService.isUpdating()) {
|
||||||
Utils.debugLog(TAG, "We haven't done an update yet. Forcing repo update.");
|
Utils.debugLog(TAG, "We haven't done an update yet. Forcing repo update.");
|
||||||
UpdateService.updateNow(this);
|
UpdateService.updateNow(this);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user