Easier and faster isInCategory
This commit is contained in:
parent
c7ace4ff8e
commit
be5dbbfc55
@ -147,31 +147,28 @@ public class AppListManager {
|
|||||||
// isn't an instance variable is because the preferences may change, and
|
// isn't an instance variable is because the preferences may change, and
|
||||||
// we wouldn't know.
|
// we wouldn't know.
|
||||||
private boolean isInCategory(DB.App app, String category, Date recentDate) {
|
private boolean isInCategory(DB.App app, String category, Date recentDate) {
|
||||||
boolean isInCategory;
|
|
||||||
if (category.equals(categoryAll)) {
|
if (category.equals(categoryAll)) {
|
||||||
isInCategory = true;
|
return true;
|
||||||
} else if (category.equals(categoryWhatsNew)) {
|
}
|
||||||
|
if (category.equals(categoryWhatsNew)) {
|
||||||
if (app.added == null)
|
if (app.added == null)
|
||||||
isInCategory = false;
|
return false;
|
||||||
else if (app.added.compareTo(recentDate) < 0)
|
if (app.added.compareTo(recentDate) < 0)
|
||||||
isInCategory = false;
|
return false;
|
||||||
else
|
return true;
|
||||||
isInCategory = true;
|
}
|
||||||
} else if (category.equals(categoryRecentlyUpdated)) {
|
if (category.equals(categoryRecentlyUpdated)) {
|
||||||
if (app.lastUpdated == null)
|
if (app.lastUpdated == null)
|
||||||
isInCategory = false;
|
return false;
|
||||||
// Don't include in the recently updated category if the
|
// Don't include in the recently updated category if the
|
||||||
// 'update' was actually it being added.
|
// 'update' was actually it being added.
|
||||||
else if (app.lastUpdated.compareTo(app.added) == 0)
|
if (app.lastUpdated.compareTo(app.added) == 0)
|
||||||
isInCategory = false;
|
return false;
|
||||||
else if (app.lastUpdated.compareTo(recentDate) < 0)
|
if (app.lastUpdated.compareTo(recentDate) < 0)
|
||||||
isInCategory = false;
|
return false;
|
||||||
else
|
return true;
|
||||||
isInCategory = true;
|
|
||||||
} else {
|
|
||||||
isInCategory = category.equals(app.category);
|
|
||||||
}
|
}
|
||||||
return isInCategory;
|
return app.categories.contains(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns false if the app list is empty and the fdroid activity decided
|
// Returns false if the app list is empty and the fdroid activity decided
|
||||||
@ -194,12 +191,10 @@ public class AppListManager {
|
|||||||
List<DB.App> availApps = new ArrayList<DB.App>();
|
List<DB.App> availApps = new ArrayList<DB.App>();
|
||||||
for (DB.App app : allApps) {
|
for (DB.App app : allApps) {
|
||||||
|
|
||||||
boolean isInCategory = isInCategory(app, currentCategory, recentDate);
|
|
||||||
|
|
||||||
// Add it to the list(s). Always to installed and updates, but
|
// Add it to the list(s). Always to installed and updates, but
|
||||||
// only to available if it's not filtered.
|
// only to available if it's not filtered.
|
||||||
if (!app.filtered && isInCategory
|
if (!app.filtered && (showIncompatible || app.compatible)
|
||||||
&& (showIncompatible || app.compatible)) {
|
&& isInCategory(app, currentCategory, recentDate)) {
|
||||||
availApps.add(app);
|
availApps.add(app);
|
||||||
}
|
}
|
||||||
if (app.installedVersion != null) {
|
if (app.installedVersion != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user