Replace if/else with switch
This is common throughout the F-Droid code base.
This commit is contained in:
parent
49f20f64b3
commit
875b0d091f
@ -285,15 +285,17 @@ public class AppUpdateStatusManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PendingIntent getContentIntent(AppUpdateStatus entry) {
|
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
|
// 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"
|
// to open up the app details page for the app. From there, the user can hit "install"
|
||||||
return getAppDetailsIntent(entry.apk);
|
return getAppDetailsIntent(entry.apk);
|
||||||
} else if (entry.status == Status.ReadyToInstall) {
|
|
||||||
return getAppDetailsIntent(entry.apk);
|
case InstallError:
|
||||||
} else if (entry.status == Status.InstallError) {
|
|
||||||
return getAppErrorIntent(entry);
|
return getAppErrorIntent(entry);
|
||||||
} else if (entry.status == Status.Installed) {
|
|
||||||
|
case Installed:
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
Intent intentObject = pm.getLaunchIntentForPackage(entry.app.packageName);
|
Intent intentObject = pm.getLaunchIntentForPackage(entry.app.packageName);
|
||||||
if (intentObject != null) {
|
if (intentObject != null) {
|
||||||
|
@ -249,11 +249,15 @@ class NotificationHelper {
|
|||||||
|
|
||||||
private NotificationCompat.Action getAction(AppUpdateStatusManager.AppUpdateStatus entry) {
|
private NotificationCompat.Action getAction(AppUpdateStatusManager.AppUpdateStatus entry) {
|
||||||
if (entry.intent != null) {
|
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);
|
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);
|
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);
|
return new NotificationCompat.Action(R.drawable.ic_notify_install_24dp, context.getString(R.string.notification_action_install), entry.intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user