Replace if/else with switch

This is common throughout the F-Droid code base.
This commit is contained in:
Peter Serwylo 2017-02-24 12:11:49 +11:00 committed by mvp76
parent 49f20f64b3
commit 875b0d091f
2 changed files with 28 additions and 22 deletions

View File

@ -285,15 +285,17 @@ public class AppUpdateStatusManager {
}
private PendingIntent getContentIntent(AppUpdateStatus entry) {
if (entry.status == Status.UpdateAvailable) {
switch (entry.status) {
case UpdateAvailable:
case ReadyToInstall:
// Make sure we have an intent to install the app. If not set, we create an intent
// to open up the app details page for the app. From there, the user can hit "install"
return getAppDetailsIntent(entry.apk);
} else if (entry.status == Status.ReadyToInstall) {
return getAppDetailsIntent(entry.apk);
} else if (entry.status == Status.InstallError) {
case InstallError:
return getAppErrorIntent(entry);
} else if (entry.status == Status.Installed) {
case Installed:
PackageManager pm = context.getPackageManager();
Intent intentObject = pm.getLaunchIntentForPackage(entry.app.packageName);
if (intentObject != null) {

View File

@ -249,11 +249,15 @@ class NotificationHelper {
private NotificationCompat.Action getAction(AppUpdateStatusManager.AppUpdateStatus entry) {
if (entry.intent != null) {
if (entry.status == AppUpdateStatusManager.Status.UpdateAvailable) {
switch (entry.status) {
case UpdateAvailable:
return new NotificationCompat.Action(R.drawable.ic_notify_update_24dp, context.getString(R.string.notification_action_update), entry.intent);
} else if (entry.status == AppUpdateStatusManager.Status.Downloading || entry.status == AppUpdateStatusManager.Status.Installing) {
case Downloading:
case Installing:
return new NotificationCompat.Action(R.drawable.ic_notify_cancel_24dp, context.getString(R.string.notification_action_cancel), entry.intent);
} else if (entry.status == AppUpdateStatusManager.Status.ReadyToInstall) {
case ReadyToInstall:
return new NotificationCompat.Action(R.drawable.ic_notify_install_24dp, context.getString(R.string.notification_action_install), entry.intent);
}
}