Make some static stuff non-static (potentially fixes instant run problem and leaks)
This commit is contained in:
parent
259eb51784
commit
ed38e524bf
|
@ -37,7 +37,6 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
|
@ -78,14 +77,14 @@ public class GBApplication extends Application {
|
|||
return dir.getAbsolutePath();
|
||||
}
|
||||
};
|
||||
private static DeviceManager deviceManager;
|
||||
|
||||
private DeviceManager deviceManager;
|
||||
|
||||
public static void quit() {
|
||||
GB.log("Quitting Gadgetbridge...", GB.INFO, null);
|
||||
Intent quitIntent = new Intent(GBApplication.ACTION_QUIT);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(quitIntent);
|
||||
GBApplication.deviceService().quit();
|
||||
GB.removeAllNotifications(context);
|
||||
}
|
||||
|
||||
public GBApplication() {
|
||||
|
@ -201,7 +200,7 @@ public class GBApplication extends Application {
|
|||
* when that was not successful
|
||||
* If acquiring was successful, callers must call #releaseDB when they
|
||||
* are done (from the same thread that acquired the lock!
|
||||
*
|
||||
* <p>
|
||||
* Callers must not hold a reference to the returned instance because it
|
||||
* will be invalidated at some point.
|
||||
*
|
||||
|
@ -421,6 +420,7 @@ public class GBApplication extends Application {
|
|||
theme.resolveAttribute(android.R.attr.textColor, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
public static int getBackgroundColor(Context context) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
Resources.Theme theme = context.getTheme();
|
||||
|
@ -436,7 +436,7 @@ public class GBApplication extends Application {
|
|||
return gbPrefs;
|
||||
}
|
||||
|
||||
public static DeviceManager getDeviceManager() {
|
||||
public DeviceManager getDeviceManager() {
|
||||
return deviceManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,8 @@ public class GBEnvironment {
|
|||
return env;
|
||||
}
|
||||
|
||||
public static GBEnvironment createDeviceEnvironment() {
|
||||
GBEnvironment env = new GBEnvironment();
|
||||
return env;
|
||||
static GBEnvironment createDeviceEnvironment() {
|
||||
return new GBEnvironment();
|
||||
}
|
||||
|
||||
public final boolean isTest() {
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ControlCenter extends GBActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_controlcenter);
|
||||
|
||||
deviceManager = GBApplication.getDeviceManager();
|
||||
deviceManager = ((GBApplication)getApplication()).getDeviceManager();
|
||||
|
||||
hintTextView = (TextView) findViewById(R.id.hintTextView);
|
||||
ListView deviceListView = (ListView) findViewById(R.id.deviceListView);
|
||||
|
|
|
@ -190,7 +190,7 @@ public class DbManagementActivity extends GBActivity {
|
|||
}
|
||||
|
||||
private void selectDeviceForMergingActivityDatabaseInto(final DeviceSelectionCallback callback) {
|
||||
GBDevice connectedDevice = GBApplication.getDeviceManager().getSelectedDevice();
|
||||
GBDevice connectedDevice = ((GBApplication)getApplication()).getDeviceManager().getSelectedDevice();
|
||||
if (connectedDevice == null) {
|
||||
callback.invoke(null);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue