mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Always use the application context when instantiating singletons
This commit is contained in:
parent
c3808827a8
commit
bd6cdecdb0
@ -25,8 +25,9 @@ public class Preferences {
|
|||||||
private static Preferences preferences;
|
private static Preferences preferences;
|
||||||
|
|
||||||
public static synchronized Preferences getPreferences(Context context) {
|
public static synchronized Preferences getPreferences(Context context) {
|
||||||
|
Context appContext = context.getApplicationContext();
|
||||||
if (preferences == null) {
|
if (preferences == null) {
|
||||||
preferences = new Preferences(context);
|
preferences = new Preferences(appContext);
|
||||||
}
|
}
|
||||||
return preferences;
|
return preferences;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public abstract class Contacts {
|
|||||||
* @return Appropriate {@link Contacts} instance for this device.
|
* @return Appropriate {@link Contacts} instance for this device.
|
||||||
*/
|
*/
|
||||||
public static Contacts getInstance(Context context) {
|
public static Contacts getInstance(Context context) {
|
||||||
|
Context appContext = context.getApplicationContext();
|
||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
/*
|
/*
|
||||||
* Check the version of the SDK we are running on. Choose an
|
* Check the version of the SDK we are running on. Choose an
|
||||||
@ -41,9 +42,9 @@ public abstract class Contacts {
|
|||||||
* The new API was introduced with SDK 5. But Android versions < 2.2
|
* The new API was introduced with SDK 5. But Android versions < 2.2
|
||||||
* need some additional code to be able to search for phonetic names.
|
* need some additional code to be able to search for phonetic names.
|
||||||
*/
|
*/
|
||||||
sInstance = new ContactsSdk5p(context);
|
sInstance = new ContactsSdk5p(appContext);
|
||||||
} else {
|
} else {
|
||||||
sInstance = new ContactsSdk5(context);
|
sInstance = new ContactsSdk5(appContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,11 +18,12 @@ public class TracingPowerManager {
|
|||||||
private Timer timer = null;
|
private Timer timer = null;
|
||||||
|
|
||||||
public static synchronized TracingPowerManager getPowerManager(Context context) {
|
public static synchronized TracingPowerManager getPowerManager(Context context) {
|
||||||
|
Context appContext = context.getApplicationContext();
|
||||||
if (tracingPowerManager == null) {
|
if (tracingPowerManager == null) {
|
||||||
if (K9.DEBUG) {
|
if (K9.DEBUG) {
|
||||||
Log.v(K9.LOG_TAG, "Creating TracingPowerManager");
|
Log.v(K9.LOG_TAG, "Creating TracingPowerManager");
|
||||||
}
|
}
|
||||||
tracingPowerManager = new TracingPowerManager(context);
|
tracingPowerManager = new TracingPowerManager(appContext);
|
||||||
}
|
}
|
||||||
return tracingPowerManager;
|
return tracingPowerManager;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user