Remove PendingDownload in favour of Downloading
The response to receiving PendingDownload was always a more specific case of the Downloading event. By removing it, the code which was listening for Downloading events is capable of doing everything that the PendingDownloading listeners were doing.
This commit is contained in:
parent
a656e8e133
commit
f617402f32
@ -480,14 +480,10 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
}
|
||||
|
||||
switch (newStatus.status) {
|
||||
case PendingDownload:
|
||||
adapter.setProgress(-1, -1, R.string.download_pending);
|
||||
break;
|
||||
|
||||
case Downloading:
|
||||
if (newStatus.progressMax == 0) {
|
||||
// The first progress notification we get telling us our status is "Downloading"
|
||||
adapter.setProgress(-1, -1, 0);
|
||||
adapter.setProgress(-1, -1, R.string.download_pending);
|
||||
} else {
|
||||
adapter.setProgress(newStatus.progressCurrent, newStatus.progressMax, 0);
|
||||
}
|
||||
@ -691,7 +687,7 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
|
||||
|
||||
@Override
|
||||
public boolean isAppDownloading() {
|
||||
return currentStatus != null && currentStatus.isDownloading();
|
||||
return currentStatus != null && currentStatus.status == AppUpdateStatusManager.Status.Downloading;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,10 +184,6 @@ public final class AppUpdateStatusManager {
|
||||
copy.progressMax = progressMax;
|
||||
return copy;
|
||||
}
|
||||
|
||||
public boolean isDownloading() {
|
||||
return status == Status.Downloading || status == Status.PendingDownload;
|
||||
}
|
||||
}
|
||||
|
||||
private final Context context;
|
||||
|
@ -151,7 +151,6 @@ class NotificationHelper {
|
||||
if (entry.status == AppUpdateStatusManager.Status.DownloadInterrupted) {
|
||||
return true;
|
||||
} else if ((entry.status == AppUpdateStatusManager.Status.Downloading ||
|
||||
entry.status == AppUpdateStatusManager.Status.PendingDownload ||
|
||||
entry.status == AppUpdateStatusManager.Status.ReadyToInstall ||
|
||||
entry.status == AppUpdateStatusManager.Status.InstallError) &&
|
||||
AppDetails2.isAppVisible(entry.app.packageName)) {
|
||||
|
@ -166,7 +166,7 @@ public class InstallManagerService extends Service {
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
appUpdateStatusManager.addApk(apk, AppUpdateStatusManager.Status.PendingDownload, null);
|
||||
appUpdateStatusManager.addApk(apk, AppUpdateStatusManager.Status.Downloading, null);
|
||||
appUpdateStatusManager.markAsPendingInstall(urlString);
|
||||
|
||||
registerApkDownloaderReceivers(urlString);
|
||||
|
@ -291,7 +291,7 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
} else {
|
||||
name.setText(activity.getString(R.string.app_list__name__downloaded_and_ready_to_install, app.name));
|
||||
}
|
||||
} else if (currentStatus != null && currentStatus.isDownloading()) {
|
||||
} else if (currentStatus != null && currentStatus.status == AppUpdateStatusManager.Status.Downloading) {
|
||||
name.setText(activity.getString(R.string.app_list__name__downloading_in_progress, app.name));
|
||||
} else if (currentStatus != null && currentStatus.status == AppUpdateStatusManager.Status.Installed) {
|
||||
name.setText(activity.getString(R.string.app_list__name__successfully_installed, app.name));
|
||||
@ -355,22 +355,6 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
}
|
||||
}
|
||||
|
||||
private void onDownloadStarted() {
|
||||
if (installButton != null) {
|
||||
installButton.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.ic_download_progress));
|
||||
installButton.setImageLevel(0);
|
||||
}
|
||||
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setIndeterminate(true);
|
||||
}
|
||||
|
||||
if (cancelButton != null) {
|
||||
cancelButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void onDownloadProgressUpdated(int bytesRead, int totalBytes) {
|
||||
if (installButton != null) {
|
||||
installButton.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.ic_download_progress));
|
||||
@ -443,10 +427,6 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
configureActionButton(app);
|
||||
|
||||
switch (status.status) {
|
||||
case PendingDownload:
|
||||
onDownloadStarted();
|
||||
break;
|
||||
|
||||
case Downloading:
|
||||
onDownloadProgressUpdated(status.progressCurrent, status.progressMax);
|
||||
break;
|
||||
@ -564,7 +544,7 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
private final View.OnClickListener onCancelDownload = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (currentStatus == null || !currentStatus.isDownloading()) {
|
||||
if (currentStatus == null || currentStatus.status != AppUpdateStatusManager.Status.Downloading) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,7 @@ public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
* {@link org.fdroid.fdroid.AppUpdateStatusManager.Status#UpdateAvailable} are not interesting here.
|
||||
*/
|
||||
private boolean shouldShowStatus(AppUpdateStatusManager.AppUpdateStatus status) {
|
||||
return status.status == AppUpdateStatusManager.Status.PendingDownload ||
|
||||
status.status == AppUpdateStatusManager.Status.Downloading ||
|
||||
return status.status == AppUpdateStatusManager.Status.Downloading ||
|
||||
status.status == AppUpdateStatusManager.Status.Installed ||
|
||||
status.status == AppUpdateStatusManager.Status.ReadyToInstall;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user