|
25 | 25 |
|
26 | 26 | import static android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID;
|
27 | 27 |
|
| 28 | +import java.util.Objects; |
| 29 | + |
28 | 30 | public class NextDeparturesWidgetProvider extends AppWidgetProvider {
|
29 | 31 | private static final HyperRailLog log = HyperRailLog.getLogger(NextDeparturesWidgetProvider.class);
|
30 | 32 | private static final String INTENT_EXTRA_STATION_ID = "stationId";
|
@@ -106,14 +108,7 @@ private PendingIntent createOnClickIntent(Context context, StopLocation station)
|
106 | 108 | Intent onClickIntent = new Intent(context, NextDeparturesWidgetProvider.class);
|
107 | 109 | onClickIntent.setAction(INTENT_ACTION_LAUNCH_LIVEBOARD_VIEW);
|
108 | 110 | onClickIntent.putExtra(INTENT_EXTRA_STATION_ID, station);
|
109 |
| - int flags; |
110 |
| - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { |
111 |
| - flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE; |
112 |
| - } else { |
113 |
| - flags = PendingIntent.FLAG_UPDATE_CURRENT; |
114 |
| - } |
115 |
| - PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, onClickIntent, flags); |
116 |
| - return pendingIntent; |
| 111 | + return PendingIntent.getActivity(context, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); |
117 | 112 | }
|
118 | 113 |
|
119 | 114 | private void setErrorLayout(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
|
@@ -142,7 +137,7 @@ public void onDisabled(Context context) {
|
142 | 137 | @Override
|
143 | 138 | public void onReceive(Context context, Intent intent) {
|
144 | 139 | super.onReceive(context, intent);
|
145 |
| - if (intent.getAction().equals(INTENT_ACTION_LAUNCH_LIVEBOARD_VIEW)) { |
| 140 | + if (Objects.equals(intent.getAction(), INTENT_ACTION_LAUNCH_LIVEBOARD_VIEW)) { |
146 | 141 | String stationId = intent.getStringExtra(INTENT_EXTRA_STATION_ID);
|
147 | 142 | Intent liveboardLaunchIntent = LiveboardActivity.createShortcutIntent(context, stationId);
|
148 | 143 | liveboardLaunchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
0 commit comments