Search in sources :

Example 1 with AppStatus

use of org.fdroid.fdroid.views.updates.items.AppStatus in project fdroidclient by f-droid.

the class UpdatesAdapter method populateAppStatuses.

/**
 * Adds items from the {@link AppUpdateStatusManager} to {@link UpdatesAdapter#appsToShowStatus}.
 * Note that this will then subsequently rebuild the underlying adapter data structure by
 * invoking {@link UpdatesAdapter#populateItems}. However as per the populateItems method, it
 * does not know how best to notify the recycler view of any changes. That is up to the caller
 * of this method.
 */
private void populateAppStatuses() {
    for (AppUpdateStatusManager.AppUpdateStatus status : AppUpdateStatusManager.getInstance(activity).getAll()) {
        if (shouldShowStatus(status)) {
            appsToShowStatus.add(new AppStatus(activity, status));
        }
    }
    Collections.sort(appsToShowStatus, new Comparator<AppStatus>() {

        @Override
        public int compare(AppStatus o1, AppStatus o2) {
            return o1.status.app.name.compareTo(o2.status.app.name);
        }
    });
    populateItems();
}
Also used : AppStatus(org.fdroid.fdroid.views.updates.items.AppStatus) AppUpdateStatusManager(org.fdroid.fdroid.AppUpdateStatusManager)

Example 2 with AppStatus

use of org.fdroid.fdroid.views.updates.items.AppStatus in project fdroidclient by f-droid.

the class UpdatesAdapter method populateItems.

/**
 * Completely rebuilds the underlying data structure used by this adapter. Note however, that
 * this does not notify the recycler view of any changes. Thus, it is up to other methods which
 * initiate a call to this method to make sure they appropriately notify the recyler view.
 */
private void populateItems() {
    items.clear();
    Set<String> toShowStatusPackageNames = new HashSet<>(appsToShowStatus.size());
    for (AppStatus app : appsToShowStatus) {
        toShowStatusPackageNames.add(app.status.app.packageName);
        items.add(app);
    }
    if (updateableApps != null) {
        // Only count/show apps which are not shown above in the "Apps to show status" list.
        List<UpdateableApp> updateableAppsToShow = new ArrayList<>(updateableApps.size());
        for (UpdateableApp app : updateableApps) {
            if (!toShowStatusPackageNames.contains(app.app.packageName)) {
                updateableAppsToShow.add(app);
            }
        }
        if (updateableAppsToShow.size() > 0) {
            items.add(new UpdateableAppsHeader(activity, this, updateableAppsToShow));
            if (showAllUpdateableApps) {
                items.addAll(updateableAppsToShow);
            }
        }
    }
    items.addAll(knownVulnApps);
}
Also used : AppStatus(org.fdroid.fdroid.views.updates.items.AppStatus) ArrayList(java.util.ArrayList) UpdateableApp(org.fdroid.fdroid.views.updates.items.UpdateableApp) UpdateableAppsHeader(org.fdroid.fdroid.views.updates.items.UpdateableAppsHeader) HashSet(java.util.HashSet)

Aggregations

AppStatus (org.fdroid.fdroid.views.updates.items.AppStatus)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AppUpdateStatusManager (org.fdroid.fdroid.AppUpdateStatusManager)1 UpdateableApp (org.fdroid.fdroid.views.updates.items.UpdateableApp)1 UpdateableAppsHeader (org.fdroid.fdroid.views.updates.items.UpdateableAppsHeader)1