Search in sources :

Example 6 with AppUpdateStatusManager

use of org.fdroid.fdroid.AppUpdateStatusManager 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();
}
Also used : AppUpdateStatus(org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus) AppUpdateStatusManager(org.fdroid.fdroid.AppUpdateStatusManager) View(android.view.View)

Aggregations

AppUpdateStatusManager (org.fdroid.fdroid.AppUpdateStatusManager)6 AppUpdateStatus (org.fdroid.fdroid.AppUpdateStatusManager.AppUpdateStatus)2 PackageInfo (android.content.pm.PackageInfo)1 NonNull (android.support.annotation.NonNull)1 View (android.view.View)1 File (java.io.File)1 DismissResult (org.fdroid.fdroid.views.updates.DismissResult)1 AppStatus (org.fdroid.fdroid.views.updates.items.AppStatus)1