diff options
author | Stefan Niedermann <info@niedermann.it> | 2021-05-16 15:16:13 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2021-05-16 15:16:13 +0300 |
commit | c3c041d91b8f1ad0815fc79b82439124f1053187 (patch) | |
tree | 892af92fbbc64b427e3b5e8cba369e275622363a /app/src/main/java/it/niedermann | |
parent | 5e8bcb00079a589a1d57a27d541495a302358449 (diff) |
Do not explicitly request ApplicationContext because we already do it in the constructor
Diffstat (limited to 'app/src/main/java/it/niedermann')
-rw-r--r-- | app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java index 1f2a2e06..9e553be1 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java @@ -147,9 +147,9 @@ public class NotesRepository { this.syncOnlyOnWifiKey = context.getApplicationContext().getResources().getString(R.string.pref_key_wifi_only); // Registers BroadcastReceiver to track network connection changes. - context.getApplicationContext().registerReceiver(networkReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); + this.context.registerReceiver(networkReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); - final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.context.getApplicationContext()); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.context); prefs.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener); syncOnlyOnWifi = prefs.getBoolean(syncOnlyOnWifiKey, false); @@ -541,20 +541,20 @@ public class NotesRepository { private void updateDynamicShortcuts(long accountId) { executor.submit(() -> { if (SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) { - ShortcutManager shortcutManager = context.getApplicationContext().getSystemService(ShortcutManager.class); + ShortcutManager shortcutManager = this.context.getSystemService(ShortcutManager.class); if (shortcutManager != null) { if (!shortcutManager.isRateLimitingActive()) { List<ShortcutInfo> newShortcuts = new ArrayList<>(); for (Note note : db.getNoteDao().getRecentNotes(accountId)) { if (!TextUtils.isEmpty(note.getTitle())) { - Intent intent = new Intent(context.getApplicationContext(), EditNoteActivity.class); + Intent intent = new Intent(this.context, EditNoteActivity.class); intent.putExtra(EditNoteActivity.PARAM_NOTE_ID, note.getId()); intent.setAction(ACTION_SHORTCUT); - newShortcuts.add(new ShortcutInfo.Builder(context.getApplicationContext(), note.getId() + "") + newShortcuts.add(new ShortcutInfo.Builder(this.context, note.getId() + "") .setShortLabel(note.getTitle() + "") - .setIcon(Icon.createWithResource(context.getApplicationContext(), note.getFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_grey_ccc_24dp)) + .setIcon(Icon.createWithResource(this.context, note.getFavorite() ? R.drawable.ic_star_yellow_24dp : R.drawable.ic_star_grey_ccc_24dp)) .setIntent(intent) .build()); } else { @@ -693,7 +693,7 @@ public class NotesRepository { @Override protected void finalize() throws Throwable { - context.getApplicationContext().unregisterReceiver(networkReceiver); + this.context.unregisterReceiver(networkReceiver); super.finalize(); } @@ -857,7 +857,7 @@ public class NotesRepository { public void updateNetworkStatus() { try { - final ConnectivityManager connMgr = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); + final ConnectivityManager connMgr = (ConnectivityManager) this.context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connMgr == null) { throw new NetworkErrorException("ConnectivityManager is null"); } |