Refactoring

This commit is contained in:
M66B
2019-03-17 18:17:41 +00:00
parent 872984b33c
commit 23fe035085
2 changed files with 7 additions and 7 deletions

View File

@@ -127,10 +127,10 @@ public class ApplicationEx extends Application {
}
@RequiresApi(api = Build.VERSION_CODES.O)
public JSONArray channelsToJSON() throws JSONException {
static JSONArray channelsToJSON(Context context) throws JSONException {
JSONArray jchannels = new JSONArray();
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
for (NotificationChannel channel : nm.getNotificationChannels())
if (!DEFAULT_CHANNEL_NAMES.contains(channel.getId())) {
JSONObject jchannel = new JSONObject();
@@ -163,8 +163,8 @@ public class ApplicationEx extends Application {
}
@RequiresApi(api = Build.VERSION_CODES.O)
public void channelsFromJSON(JSONArray jchannels) throws JSONException {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
static void channelsFromJSON(Context context, JSONArray jchannels) throws JSONException {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
for (int c = 0; c < jchannels.length(); c++) {
JSONObject jchannel = (JSONObject) jchannels.get(c);
@@ -189,7 +189,7 @@ public class ApplicationEx extends Application {
if (jchannel.has("sound") && !jchannel.isNull("sound")) {
Uri uri = Uri.parse(jchannel.getString("sound"));
Ringtone ringtone = RingtoneManager.getRingtone(this, uri);
Ringtone ringtone = RingtoneManager.getRingtone(context, uri);
if (ringtone != null)
channel.setSound(uri, Notification.AUDIO_ATTRIBUTES_DEFAULT);
}