use of org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus in project fdroidclient by f-droid.
the class AppListItemController method bindModel.
public void bindModel(@NonNull App app) {
currentApp = app;
if (actionButton != null)
actionButton.setEnabled(true);
Utils.setIconFromRepoOrPM(app, icon, activity);
// Figures out the current install/update/download/etc status for the app we are viewing.
// Then, asks the view to update itself to reflect this status.
Iterator<AppUpdateStatus> statuses = AppUpdateStatusManager.getInstance(activity).getByPackageName(app.packageName).iterator();
if (statuses.hasNext()) {
AppUpdateStatus status = statuses.next();
updateAppStatus(app, status);
} else {
updateAppStatus(app, null);
}
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(activity.getApplicationContext());
broadcastManager.unregisterReceiver(onStatusChanged);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED);
intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
intentFilter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED);
broadcastManager.registerReceiver(onStatusChanged, intentFilter);
}
use of org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus in project fdroidclient by f-droid.
the class AppStatusListItemController method onDismissApp.
@NonNull
@Override
protected DismissResult onDismissApp(@NonNull App app) {
AppUpdateStatus status = getCurrentStatus();
CharSequence message = null;
if (status != null) {
AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(activity);
manager.removeApk(status.getUniqueKey());
switch(status.status) {
case ReadyToInstall:
manager.markAsNoLongerPendingInstall(status);
// of a "Ready to install" app being dismissed.
break;
case Downloading:
cancelDownload();
message = activity.getString(R.string.app_list__dismiss_downloading_app);
break;
}
}
return new DismissResult(message, true);
}
use of org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus in project fdroidclient by f-droid.
the class AppStatusListItemController method onDismissApp.
@Override
protected void onDismissApp(@NonNull final App app, final UpdatesAdapter adapter) {
AppUpdateStatus status = getCurrentStatus();
if (status != null) {
final AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(activity);
final AppUpdateStatus appUpdateStatus = manager.get(status.getCanonicalUrl());
manager.removeApk(status.getCanonicalUrl());
switch(status.status) {
case Downloading:
cancelDownload();
Snackbar.make(itemView, R.string.app_list__dismiss_downloading_app, Snackbar.LENGTH_SHORT).show();
break;
case ReadyToInstall:
if (appUpdateStatus != null) {
Snackbar.make(itemView, R.string.app_list__dismiss_installing_app, Snackbar.LENGTH_LONG).setAction(R.string.undo, new View.OnClickListener() {
@Override
public void onClick(View view) {
manager.addApk(appUpdateStatus.apk, appUpdateStatus.status, appUpdateStatus.intent);
adapter.refreshStatuses();
}
}).show();
break;
}
}
}
adapter.refreshStatuses();
}
Aggregations