Don't crash if a repo has zero apps/apks

Also, a couple of typo fixes
This commit is contained in:
Daniel Martí 2014-04-29 23:56:06 +02:00
parent f4539b3803
commit 663a95c7a9
2 changed files with 8 additions and 3 deletions

View File

@ -305,7 +305,7 @@ public class UpdateService extends IntentService implements ProgressListener {
}
if (!changes) {
Log.d("FDroid", "Not checking app details or compatibility, ecause all repos were up to date.");
Log.d("FDroid", "Not checking app details or compatibility, because all repos were up to date.");
} else {
sendStatus(STATUS_INFO, getString(R.string.status_checking_compatibility));
@ -399,7 +399,7 @@ public class UpdateService extends IntentService implements ProgressListener {
List<App> appsToIgnore = AppProvider.Helper.findIgnored(this, projection);
for (App app : apps) {
boolean ignored = false;
for(App appIgnored : appsToIgnore) {
for (App appIgnored : appsToIgnore) {
if (appIgnored.id.equals(app.id)) {
ignored = true;
break;
@ -444,7 +444,9 @@ public class UpdateService extends IntentService implements ProgressListener {
private List<String> getKnownAppIds(List<App> apps) {
List<String> knownAppIds = new ArrayList<String>();
if (apps.size() > AppProvider.MAX_APPS_TO_QUERY) {
if (apps.size() == 0) {
// Do nothing
} else if (apps.size() > AppProvider.MAX_APPS_TO_QUERY) {
int middle = apps.size() / 2;
List<App> apps1 = apps.subList(0, middle);
List<App> apps2 = apps.subList(middle, apps.size());

View File

@ -103,6 +103,9 @@ public class ApkProvider extends FDroidProvider {
*/
public static List<Apk> knownApks(Context context,
List<Apk> apks, String[] fields) {
if (apks.size() == 0) {
return new ArrayList<Apk>();
}
ContentResolver resolver = context.getContentResolver();
Uri uri = getContentUri(apks);
Cursor cursor = resolver.query(uri, fields, null, null, null);