From a0b89896dc5580cf9b5c60623802f7466e23e92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Mon, 7 Apr 2025 09:08:06 -0300 Subject: [PATCH] force_pause on subscribe/redeem --- .../java/com/example/dcav2gui/EarnerInterface.java | 14 ++++++++------ app/src/main/res/values/strings.xml | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/example/dcav2gui/EarnerInterface.java b/app/src/main/java/com/example/dcav2gui/EarnerInterface.java index 105a0de..65913b5 100644 --- a/app/src/main/java/com/example/dcav2gui/EarnerInterface.java +++ b/app/src/main/java/com/example/dcav2gui/EarnerInterface.java @@ -345,7 +345,7 @@ public class EarnerInterface { final double amountToSubscribe = Double.parseDouble(input.getText().toString()); new Thread(() -> { try { - JsonObject response = subscribeFunds(exchange, amountToSubscribe,true); + JsonObject response = subscribeFunds(exchange, amountToSubscribe,true,true); new Handler(Looper.getMainLooper()).post(() -> { showJsonDialog(response, context); }); @@ -379,7 +379,7 @@ public class EarnerInterface { final double amountToRedeem = Double.parseDouble(input.getText().toString()); new Thread(() -> { try { - JsonObject response = redeemFunds(exchange, amountToRedeem,true); + JsonObject response = redeemFunds(exchange, amountToRedeem,true,true); new Handler(Looper.getMainLooper()).post(() -> { showJsonDialog(response, context); }); @@ -868,11 +868,12 @@ public class EarnerInterface { } } - public static JsonObject subscribeFunds(String exchange, double amount, boolean retry) throws IOException { + public static JsonObject subscribeFunds(String exchange, double amount, boolean forcePause, boolean retry) throws IOException { Gson gson = new Gson(); JsonObject jsonPayload = new JsonObject(); jsonPayload.addProperty("broker", exchange); jsonPayload.addProperty("amount", amount); + jsonPayload.addProperty("force_pause", forcePause); String jsonPayloadString = gson.toJson(jsonPayload); RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8")); @@ -885,7 +886,7 @@ public class EarnerInterface { try (Response subscribeFundsResponse = httpClient.newCall(subscribeFundsRequest).execute()) { if (!subscribeFundsResponse.isSuccessful()) { if (subscribeFundsResponse.code() == 503 && retry) { - return subscribeFunds(exchange, amount, false); + return subscribeFunds(exchange, amount, forcePause,false); } throw new IOException("Unexpected code " + subscribeFundsResponse); } @@ -906,11 +907,12 @@ public class EarnerInterface { } } - public static JsonObject redeemFunds(String exchange, double amount, boolean retry) throws IOException { + public static JsonObject redeemFunds(String exchange, double amount, boolean forcePause, boolean retry) throws IOException { Gson gson = new Gson(); JsonObject jsonPayload = new JsonObject(); jsonPayload.addProperty("broker", exchange); jsonPayload.addProperty("amount", amount); + jsonPayload.addProperty("force_pause", forcePause); String jsonPayloadString = gson.toJson(jsonPayload); RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8")); @@ -923,7 +925,7 @@ public class EarnerInterface { try (Response redeemFundsResponse = httpClient.newCall(redeemFundsRequest).execute()) { if (!redeemFundsResponse.isSuccessful()) { if (redeemFundsResponse.code() == 503 && retry) { - return redeemFunds(exchange, amount, false); + return redeemFunds(exchange, amount, forcePause,false); } throw new IOException("Unexpected code " + redeemFundsResponse); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b20f673..b9cbe76 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ DCAv2GUI DCAv2 - Version 2025.03.13 + Version 2025.04.07 Open navigation drawer Close navigation drawer Navigation header