Get address and port once
Этот коммит содержится в:
@@ -33,7 +33,9 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private SharedPreferences preferences;
|
|
||||||
|
private String address;
|
||||||
|
private int port;
|
||||||
|
|
||||||
private PositionProvider positionProvider;
|
private PositionProvider positionProvider;
|
||||||
private DatabaseHelper databaseHelper;
|
private DatabaseHelper databaseHelper;
|
||||||
@@ -54,7 +56,7 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
public TrackingController(Context context) {
|
public TrackingController(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
if (preferences.getString(MainActivity.KEY_PROVIDER, null).equals("mixed")) {
|
if (preferences.getString(MainActivity.KEY_PROVIDER, null).equals("mixed")) {
|
||||||
positionProvider = new MixedPositionProvider(context, this);
|
positionProvider = new MixedPositionProvider(context, this);
|
||||||
} else {
|
} else {
|
||||||
@@ -64,6 +66,9 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
networkManager = new NetworkManager(context, this);
|
networkManager = new NetworkManager(context, this);
|
||||||
isOnline = networkManager.isOnline();
|
isOnline = networkManager.isOnline();
|
||||||
|
|
||||||
|
address = preferences.getString(MainActivity.KEY_ADDRESS, null);
|
||||||
|
port = Integer.parseInt(preferences.getString(MainActivity.KEY_PORT, null));
|
||||||
|
|
||||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
|
||||||
}
|
}
|
||||||
@@ -173,11 +178,7 @@ public class TrackingController implements PositionProvider.PositionListener, Ne
|
|||||||
private void send(final Position position) {
|
private void send(final Position position) {
|
||||||
log("send", position);
|
log("send", position);
|
||||||
lock();
|
lock();
|
||||||
String request = ProtocolFormatter.formatRequest(
|
String request = ProtocolFormatter.formatRequest(address, port, position);
|
||||||
preferences.getString(MainActivity.KEY_ADDRESS, null),
|
|
||||||
Integer.parseInt(preferences.getString(MainActivity.KEY_PORT, null)),
|
|
||||||
position);
|
|
||||||
|
|
||||||
RequestManager.sendRequestAsync(request, new RequestManager.RequestHandler() {
|
RequestManager.sendRequestAsync(request, new RequestManager.RequestHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(boolean success) {
|
public void onComplete(boolean success) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user