workers toggle menus implemented
This commit is contained in:
parent
108c4a0a10
commit
0b228033df
|
|
@ -11,11 +11,13 @@ import android.widget.Toast;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import okhttp3.FormBody;
|
import okhttp3.FormBody;
|
||||||
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
|
|
@ -149,14 +151,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request addTraderRequest = new Request.Builder()
|
Request addTraderRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/add_pair")
|
.url(API_BASE_URL + "/" + exchange + "/add_pair")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response addTraderResponse = httpClient.newCall(addTraderRequest).execute()) {
|
try (Response addTraderResponse = httpClient.newCall(addTraderRequest).execute()) {
|
||||||
|
|
@ -188,14 +193,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request removeTraderRequest = new Request.Builder()
|
Request removeTraderRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/remove_pair")
|
.url(API_BASE_URL + "/" + exchange + "/remove_pair")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response removeTraderResponse = httpClient.newCall(removeTraderRequest).execute()) {
|
try (Response removeTraderResponse = httpClient.newCall(removeTraderRequest).execute()) {
|
||||||
|
|
@ -227,14 +235,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request restartTraderRequest = new Request.Builder()
|
Request restartTraderRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/restart_pair")
|
.url(API_BASE_URL + "/" + exchange + "/restart_pair")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response restartTraderResponse = httpClient.newCall(restartTraderRequest).execute()) {
|
try (Response restartTraderResponse = httpClient.newCall(restartTraderRequest).execute()) {
|
||||||
|
|
@ -266,14 +277,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request importTraderRequest = new Request.Builder()
|
Request importTraderRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/import_pair")
|
.url(API_BASE_URL + "/" + exchange + "/import_pair")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response importTraderResponse = httpClient.newCall(importTraderRequest).execute()) {
|
try (Response importTraderResponse = httpClient.newCall(importTraderRequest).execute()) {
|
||||||
|
|
@ -305,14 +319,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request togglePauseRequest = new Request.Builder()
|
Request togglePauseRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/toggle_pause")
|
.url(API_BASE_URL + "/" + exchange + "/toggle_pause")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response togglePauseResponse = httpClient.newCall(togglePauseRequest).execute()) {
|
try (Response togglePauseResponse = httpClient.newCall(togglePauseRequest).execute()) {
|
||||||
|
|
@ -344,14 +361,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request toggleAutoswitchRequest = new Request.Builder()
|
Request toggleAutoswitchRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/toggle_autoswitch")
|
.url(API_BASE_URL + "/" + exchange + "/toggle_autoswitch")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response toggleAutoswitchResponse = httpClient.newCall(toggleAutoswitchRequest).execute()) {
|
try (Response toggleAutoswitchResponse = httpClient.newCall(toggleAutoswitchRequest).execute()) {
|
||||||
|
|
@ -383,14 +403,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request toggleCleanupRequest = new Request.Builder()
|
Request toggleCleanupRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/toggle_cleanup")
|
.url(API_BASE_URL + "/" + exchange + "/toggle_cleanup")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response toggleCleanupResponse = httpClient.newCall(toggleCleanupRequest).execute()) {
|
try (Response toggleCleanupResponse = httpClient.newCall(toggleCleanupRequest).execute()) {
|
||||||
|
|
@ -423,14 +446,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request toggleLastCallRequest = new Request.Builder()
|
Request toggleLastCallRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/last_call")
|
.url(API_BASE_URL + "/" + exchange + "/last_call")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response toggleLastCallResponse = httpClient.newCall(toggleLastCallRequest).execute()) {
|
try (Response toggleLastCallResponse = httpClient.newCall(toggleLastCallRequest).execute()) {
|
||||||
|
|
@ -466,15 +492,18 @@ public class WorkerInterface {
|
||||||
profits = "1";
|
profits = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
formBuilder.add("calculate_profits", profits);
|
jsonPayload.addProperty("quote", quote);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("calculate_profits", profits);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request switchToLongRequest = new Request.Builder()
|
Request switchToLongRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/switch_to_long")
|
.url(API_BASE_URL + "/" + exchange + "/switch_to_long")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response switchToLongResponse = httpClient.newCall(switchToLongRequest).execute()) {
|
try (Response switchToLongResponse = httpClient.newCall(switchToLongRequest).execute()) {
|
||||||
|
|
@ -506,14 +535,17 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request switchToShortRequest = new Request.Builder()
|
Request switchToShortRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/switch_to_short")
|
.url(API_BASE_URL + "/" + exchange + "/switch_to_short")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response switchToShortResponse = httpClient.newCall(switchToShortRequest).execute()) {
|
try (Response switchToShortResponse = httpClient.newCall(switchToShortRequest).execute()) {
|
||||||
|
|
@ -545,15 +577,18 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
formBuilder.add("new_quote", targetQuoteCurrency);
|
jsonPayload.addProperty("quote", quote);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("new_quote", targetQuoteCurrency);
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request switchQuoteCurrencyRequest = new Request.Builder()
|
Request switchQuoteCurrencyRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/switch_quote_currency")
|
.url(API_BASE_URL + "/" + exchange + "/switch_quote_currency")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response switchQuoteCurrencyResponse = httpClient.newCall(switchQuoteCurrencyRequest).execute()) {
|
try (Response switchQuoteCurrencyResponse = httpClient.newCall(switchQuoteCurrencyRequest).execute()) {
|
||||||
|
|
@ -585,15 +620,18 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
formBuilder.add("amount", String.valueOf(amount));
|
jsonPayload.addProperty("quote", quote);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("amount", String.valueOf(amount));
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request addSafetyOrdersRequest = new Request.Builder()
|
Request addSafetyOrdersRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/add_so")
|
.url(API_BASE_URL + "/" + exchange + "/add_so")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response addSafetyOrdersResponse = httpClient.newCall(addSafetyOrdersRequest).execute()) {
|
try (Response addSafetyOrdersResponse = httpClient.newCall(addSafetyOrdersRequest).execute()) {
|
||||||
|
|
@ -625,15 +663,18 @@ public class WorkerInterface {
|
||||||
String base = pairBaseAndQuote[0];
|
String base = pairBaseAndQuote[0];
|
||||||
String quote = pairBaseAndQuote[1];
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
FormBody.Builder formBuilder = new FormBody.Builder();
|
Gson gson = new Gson();
|
||||||
formBuilder.add("base", base);
|
JsonObject jsonPayload = new JsonObject();
|
||||||
formBuilder.add("quote", quote);
|
jsonPayload.addProperty("base", base);
|
||||||
formBuilder.add("amount", String.valueOf(amount));
|
jsonPayload.addProperty("quote", quote);
|
||||||
RequestBody formBody = formBuilder.build();
|
jsonPayload.addProperty("amount", String.valueOf(amount));
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
Request addQuoteRequest = new Request.Builder()
|
Request addQuoteRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/add_quote")
|
.url(API_BASE_URL + "/" + exchange + "/add_quote")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.post(formBody)
|
.post(requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response addQuoteResponse = httpClient.newCall(addQuoteRequest).execute()) {
|
try (Response addQuoteResponse = httpClient.newCall(addQuoteRequest).execute()) {
|
||||||
|
|
@ -660,6 +701,68 @@ public class WorkerInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showToggleDialog(JsonObject result, Context context) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
|
||||||
|
for (String key: result.keySet()) {
|
||||||
|
builder.setTitle(key);
|
||||||
|
builder.setMessage(result.get(key).getAsString());
|
||||||
|
}
|
||||||
|
builder.setPositiveButton("OK", null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendTogglePause(String exchange, String pair, Context context) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
JsonObject result = togglePause(exchange, pair, true);
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> WorkerInterface.showToggleDialog(result, context));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(context, "Failed to toggle pause", Toast.LENGTH_SHORT).show());
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendToggleAutoswitch(String exchange, String pair, Context context) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
JsonObject result = toggleAutoswitch(exchange, pair, true);
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> WorkerInterface.showToggleDialog(result, context));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(context, "Failed to toggle autoswitch", Toast.LENGTH_SHORT).show());
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendToggleCleanup(String exchange, String pair, Context context) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
JsonObject result = toggleCleanup(exchange, pair, true);
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> WorkerInterface.showToggleDialog(result, context));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(context, "Failed to toggle cleanup", Toast.LENGTH_SHORT).show());
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendToggleLastCall(String exchange, String pair, Context context) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
JsonObject result = toggleLastCall(exchange, pair, true);
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> WorkerInterface.showToggleDialog(result, context));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(context, "Failed to toggle last call", Toast.LENGTH_SHORT).show());
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void fetchWorkerStats(String exchange, String pair, Context context) {
|
public static void fetchWorkerStats(String exchange, String pair, Context context) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ import com.example.dcav2gui.ui.exchanges.adapters.WorkerCardAdapter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import kotlinx.coroutines.scheduling.CoroutineScheduler;
|
||||||
|
|
||||||
|
|
||||||
public class BinanceFragment extends Fragment implements WorkerCardAdapter.OnCardLongClickListener {
|
public class BinanceFragment extends Fragment implements WorkerCardAdapter.OnCardLongClickListener {
|
||||||
|
|
||||||
|
|
@ -88,16 +90,16 @@ public class BinanceFragment extends Fragment implements WorkerCardAdapter.OnCar
|
||||||
System.err.println(pair + " Import option clicked");
|
System.err.println(pair + " Import option clicked");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.togglePause) {
|
} else if (item.getItemId() == R.id.togglePause) {
|
||||||
System.err.println(pair + " Toggle pause option clicked");
|
WorkerInterface.sendTogglePause("binance", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleAutoswitch) {
|
} else if (item.getItemId() == R.id.toggleAutoswitch) {
|
||||||
System.err.println(pair + " Toggle autoswitch option clicked");
|
WorkerInterface.sendToggleAutoswitch("binance", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleCleanup) {
|
} else if (item.getItemId() == R.id.toggleCleanup) {
|
||||||
System.err.println(pair + " Toggle cleanup option clicked");
|
WorkerInterface.sendToggleCleanup("binance", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleLastCall) {
|
} else if (item.getItemId() == R.id.toggleLastCall) {
|
||||||
System.err.println(pair + " Toggle last call option clicked");
|
WorkerInterface.sendToggleLastCall("binance", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.switchToLong) {
|
} else if (item.getItemId() == R.id.switchToLong) {
|
||||||
System.err.println(pair + " Switch to long option clicked");
|
System.err.println(pair + " Switch to long option clicked");
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,16 @@ public class GateioFragment extends Fragment implements WorkerCardAdapter.OnCard
|
||||||
System.err.println(pair + " Import option clicked");
|
System.err.println(pair + " Import option clicked");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.togglePause) {
|
} else if (item.getItemId() == R.id.togglePause) {
|
||||||
System.err.println(pair + " Toggle pause option clicked");
|
WorkerInterface.sendTogglePause("gateio", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleAutoswitch) {
|
} else if (item.getItemId() == R.id.toggleAutoswitch) {
|
||||||
System.err.println(pair + " Toggle autoswitch option clicked");
|
WorkerInterface.sendToggleAutoswitch("gateio", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleCleanup) {
|
} else if (item.getItemId() == R.id.toggleCleanup) {
|
||||||
System.err.println(pair + " Toggle cleanup option clicked");
|
WorkerInterface.sendToggleCleanup("gateio", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleLastCall) {
|
} else if (item.getItemId() == R.id.toggleLastCall) {
|
||||||
System.err.println(pair + " Toggle last call option clicked");
|
WorkerInterface.sendToggleLastCall("gateio", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.switchToLong) {
|
} else if (item.getItemId() == R.id.switchToLong) {
|
||||||
System.err.println(pair + " Switch to long option clicked");
|
System.err.println(pair + " Switch to long option clicked");
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,16 @@ public class KucoinFragment extends Fragment implements WorkerCardAdapter.OnCard
|
||||||
System.err.println(pair + " Import option clicked");
|
System.err.println(pair + " Import option clicked");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.togglePause) {
|
} else if (item.getItemId() == R.id.togglePause) {
|
||||||
System.err.println(pair + " Toggle pause option clicked");
|
WorkerInterface.sendTogglePause("kucoin", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleAutoswitch) {
|
} else if (item.getItemId() == R.id.toggleAutoswitch) {
|
||||||
System.err.println(pair + " Toggle autoswitch option clicked");
|
WorkerInterface.sendToggleAutoswitch("kucoin", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleCleanup) {
|
} else if (item.getItemId() == R.id.toggleCleanup) {
|
||||||
System.err.println(pair + " Toggle cleanup option clicked");
|
WorkerInterface.sendToggleCleanup("kucoin", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleLastCall) {
|
} else if (item.getItemId() == R.id.toggleLastCall) {
|
||||||
System.err.println(pair + " Toggle last call option clicked");
|
WorkerInterface.sendToggleLastCall("kucoin", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.switchToLong) {
|
} else if (item.getItemId() == R.id.switchToLong) {
|
||||||
System.err.println(pair + " Switch to long option clicked");
|
System.err.println(pair + " Switch to long option clicked");
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,16 @@ public class OkxFragment extends Fragment implements WorkerCardAdapter.OnCardLon
|
||||||
System.err.println(pair + " Import option clicked");
|
System.err.println(pair + " Import option clicked");
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.togglePause) {
|
} else if (item.getItemId() == R.id.togglePause) {
|
||||||
System.err.println(pair + " Toggle pause option clicked");
|
WorkerInterface.sendTogglePause("okex", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleAutoswitch) {
|
} else if (item.getItemId() == R.id.toggleAutoswitch) {
|
||||||
System.err.println(pair + " Toggle autoswitch option clicked");
|
WorkerInterface.sendToggleAutoswitch("okex", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleCleanup) {
|
} else if (item.getItemId() == R.id.toggleCleanup) {
|
||||||
System.err.println(pair + " Toggle cleanup option clicked");
|
WorkerInterface.sendToggleCleanup("okex", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.toggleLastCall) {
|
} else if (item.getItemId() == R.id.toggleLastCall) {
|
||||||
System.err.println(pair + " Toggle last call option clicked");
|
WorkerInterface.sendToggleLastCall("okex", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.switchToLong) {
|
} else if (item.getItemId() == R.id.switchToLong) {
|
||||||
System.err.println(pair + " Switch to long option clicked");
|
System.err.println(pair + " Switch to long option clicked");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue