Fix remaining issues with notifications
This commit is contained in:
parent
fa1b53a81c
commit
082802cbba
@ -607,17 +607,6 @@ public class DB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the number of apps that have updates available. This can be a
|
|
||||||
// time consuming operation.
|
|
||||||
public int getNumUpdates(List<DB.App> apps) {
|
|
||||||
int count = 0;
|
|
||||||
for (App app : apps) {
|
|
||||||
if (!app.ignoreUpdates && app.hasUpdates)
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getCategories() {
|
public List<String> getCategories() {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
|
@ -100,6 +100,16 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
return receiver == null;
|
return receiver == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the number of apps that have updates available.
|
||||||
|
public int getNumUpdates(List<DB.App> apps) {
|
||||||
|
int count = 0;
|
||||||
|
for (DB.App app : apps) {
|
||||||
|
if (!app.ignoreUpdates && app.hasUpdates)
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
protected void onHandleIntent(Intent intent) {
|
protected void onHandleIntent(Intent intent) {
|
||||||
|
|
||||||
receiver = intent.getParcelableExtra("receiver");
|
receiver = intent.getParcelableExtra("receiver");
|
||||||
@ -144,6 +154,7 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process each repo...
|
// Process each repo...
|
||||||
|
List<DB.App> apps;
|
||||||
List<DB.App> updatingApps = new ArrayList<DB.App>();
|
List<DB.App> updatingApps = new ArrayList<DB.App>();
|
||||||
List<Integer> keeprepos = new ArrayList<Integer>();
|
List<Integer> keeprepos = new ArrayList<Integer>();
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
@ -184,7 +195,7 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
|
|
||||||
sendStatus(STATUS_INFO,
|
sendStatus(STATUS_INFO,
|
||||||
getString(R.string.status_checking_compatibility));
|
getString(R.string.status_checking_compatibility));
|
||||||
List<DB.App> apps = ((FDroidApp) getApplication()).getApps();
|
apps = ((FDroidApp) getApplication()).getApps();
|
||||||
|
|
||||||
DB db = DB.getDB();
|
DB db = DB.getDB();
|
||||||
try {
|
try {
|
||||||
@ -227,10 +238,6 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
db.updateApplication(app);
|
db.updateApplication(app);
|
||||||
}
|
}
|
||||||
db.endUpdate();
|
db.endUpdate();
|
||||||
if (notify) {
|
|
||||||
apps = ((FDroidApp) getApplication()).getApps();
|
|
||||||
updates = db.getNumUpdates(apps);
|
|
||||||
}
|
|
||||||
for (DB.Repo repo : repos)
|
for (DB.Repo repo : repos)
|
||||||
db.writeLastEtag(repo);
|
db.writeLastEtag(repo);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -245,8 +252,13 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success && changes)
|
if (success && changes) {
|
||||||
((FDroidApp) getApplication()).invalidateAllApps();
|
((FDroidApp) getApplication()).invalidateAllApps();
|
||||||
|
if (notify) {
|
||||||
|
apps = ((FDroidApp) getApplication()).getApps();
|
||||||
|
updates = getNumUpdates(apps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (success && changes && notify && updates > 0) {
|
if (success && changes && notify && updates > 0) {
|
||||||
Log.d("FDroid", "Notifying "+updates+" updates.");
|
Log.d("FDroid", "Notifying "+updates+" updates.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user