Skip to content

Commit 28b1d21

Browse files
committed
rename DataHandler context to application
1 parent d1dda70 commit 28b1d21

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/src/main/java/rocks/tbog/tblauncher/handler/DataHandler.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package rocks.tbog.tblauncher.handler;
22

3+
import android.app.Application;
34
import android.app.KeyguardManager;
45
import android.content.BroadcastReceiver;
56
import android.content.ComponentName;
@@ -104,7 +105,7 @@ public class DataHandler extends BroadcastReceiver
104105
);
105106

106107
@NonNull
107-
private final Context context;
108+
private final Application mApplication;
108109
private String currentQuery;
109110
private final Map<String, ProviderEntry> providers = new LinkedHashMap<>(); // preserve insert order
110111
private boolean mFullLoadOverSent = false;
@@ -114,11 +115,12 @@ public class DataHandler extends BroadcastReceiver
114115
/**
115116
* Initialize all providers
116117
*/
117-
public DataHandler(Context ctx) {
118+
public DataHandler(@NonNull Application app) {
118119
// Make sure we are in the context of the main application
119120
// (otherwise we might receive an exception about broadcast listeners not being able
120121
// to bind to services)
121-
context = ctx.getApplicationContext();
122+
mApplication = app;
123+
Context ctx = app.getApplicationContext();
122124

123125
mTimer.start();
124126

@@ -130,7 +132,7 @@ public DataHandler(Context ctx) {
130132
ctx.sendBroadcast(i);
131133

132134
// Monitor changes for service preferences (to automatically start and stop services)
133-
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
135+
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
134136
prefs.registerOnSharedPreferenceChangeListener(this);
135137

136138
// add DB providers
@@ -161,7 +163,7 @@ public DataHandler(Context ctx) {
161163

162164
@NonNull
163165
public Context getContext() {
164-
return context;
166+
return mApplication.getApplicationContext();
165167
}
166168

167169
/*
@@ -170,6 +172,7 @@ public Context getContext() {
170172
* to them dynamically.
171173
*/
172174
private void basicProviders() {
175+
Context context = mApplication;
173176
// Filters
174177
{
175178
ProviderEntry providerEntry = new ProviderEntry();

0 commit comments

Comments
 (0)