Avoid useless calls

This commit is contained in:
tom79 2019-10-18 18:08:39 +02:00
parent 4154eef44e
commit 1c3dc3376f
5 changed files with 9 additions and 29 deletions

View File

@ -1378,12 +1378,6 @@ public abstract class BaseMainActivity extends BaseActivity
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
editor.apply();
if (Build.VERSION.SDK_INT >= 26) {
NotificationManager notif = ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE));
if (notif != null) {
notif.deleteNotificationChannel(LiveNotificationDelayedService.CHANNEL_ID);
}
}
break;
}
switch (Helper.liveNotifType(getApplicationContext())){

View File

@ -91,14 +91,6 @@ public class AccountLiveAdapter extends RecyclerView.Adapter {
streamingIntent = new Intent(context, LiveNotificationDelayedService.class);
context.startService(streamingIntent);
break;
case Helper.NOTIF_NONE:
if (Build.VERSION.SDK_INT >= 26) {
NotificationManager notif = ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
if (notif != null) {
notif.deleteNotificationChannel(LiveNotificationDelayedService.CHANNEL_ID);
}
}
break;
}
}
});

View File

@ -1240,6 +1240,7 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_NOTIFY, isChecked);
editor.apply();
context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
if (isChecked) {
notification_settings.setVisibility(View.VISIBLE);
try {
@ -1254,15 +1255,6 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
break;
}
} catch (Exception ignored) {}
}else {
notification_settings.setVisibility(View.GONE);
context.sendBroadcast(new Intent(context, StopLiveNotificationReceiver.class));
if (Build.VERSION.SDK_INT >= 26) {
NotificationManager notif = ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
if (notif != null) {
notif.deleteNotificationChannel(LiveNotificationDelayedService.CHANNEL_ID);
}
}
}
}
});
@ -1322,12 +1314,6 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
live_notif_per_account.setVisibility(View.GONE);
editor.apply();
if (Build.VERSION.SDK_INT >= 26) {
NotificationManager notif = ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
if (notif != null) {
notif.deleteNotificationChannel(LiveNotificationDelayedService.CHANNEL_ID);
}
}
break;
}
switch (Helper.liveNotifType(context)){

View File

@ -131,6 +131,13 @@ public class LiveNotificationDelayedService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent == null || intent.getBooleanExtra("stop", false)) {
totalAccount = 0;
stopSelf();
}
if( totalAccount > 0) {
return START_STICKY;
}

View File

@ -174,6 +174,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent == null || intent.getBooleanExtra("stop", false)) {
totalAccount = 0;
stopSelf();
}
if( totalAccount > 0) {