added shiba inu
This commit is contained in:
parent
7eac2c530e
commit
91e5afd4f8
@ -43,7 +43,8 @@ public class MiningBean {
|
|||||||
List<KeyValue> pool = new ArrayList<>();
|
List<KeyValue> pool = new ArrayList<>();
|
||||||
List<KeyValue> network = new ArrayList<>();
|
List<KeyValue> network = new ArrayList<>();
|
||||||
|
|
||||||
String[] cryptoCur = new String[] { "BTC", "LTC", "XRP", "ETH", "DOGE", "ADA" };
|
String[] cryptoCur = new String[] { "BTC", "LTC", "XRP", "ETH", "DOGE", "ADA", "SHIB" };
|
||||||
|
int[] roundPrices = new int[] { 4, 4, 4, 4, 4, 4, 6 };
|
||||||
double[] lastPrices = new double[cryptoCur.length];
|
double[] lastPrices = new double[cryptoCur.length];
|
||||||
|
|
||||||
ltcapikey = request.getParameter("ltcapikey");
|
ltcapikey = request.getParameter("ltcapikey");
|
||||||
@ -70,26 +71,27 @@ public class MiningBean {
|
|||||||
if (restRequest != null && restRequest.length() > 0) {
|
if (restRequest != null && restRequest.length() > 0) {
|
||||||
JSONObject tmp = new JSONObject(restRequest);
|
JSONObject tmp = new JSONObject(restRequest);
|
||||||
JSONArray data = (JSONArray) tmp.get("data");
|
JSONArray data = (JSONArray) tmp.get("data");
|
||||||
|
|
||||||
for (int i=0;i<data.length();i++) {
|
for (int i = 0; i < data.length(); i++) {
|
||||||
JSONObject o = data.getJSONObject(i);
|
JSONObject o = data.getJSONObject(i);
|
||||||
String symbol = o.getString("symbol");
|
String symbol = o.getString("symbol");
|
||||||
int pos = searchArray(cryptoCur, symbol);
|
int pos = searchArray(cryptoCur, symbol);
|
||||||
if (pos>=0) {
|
if (pos >= 0) {
|
||||||
JSONObject quote = (JSONObject) o.get("quote");
|
JSONObject quote = (JSONObject) o.get("quote");
|
||||||
JSONObject usd = (JSONObject) quote.get(currency.toUpperCase());
|
JSONObject usd = (JSONObject) quote.get(currency.toUpperCase());
|
||||||
double price = usd.getDouble("price");
|
double price = usd.getDouble("price");
|
||||||
double change = usd.getDouble("percent_change_24h");
|
double change = usd.getDouble("percent_change_24h");
|
||||||
|
|
||||||
lastPrices[pos] = price;
|
lastPrices[pos] = price;
|
||||||
if (price > 0d)
|
if (price > 0d)
|
||||||
resultStr = curSym + String.format("%.4f",(price)) + " ("+String.format("%.2f",(change))+"%)";
|
resultStr = curSym + String.format("%."+roundPrices[pos]+"f", (price)) + " (" + String.format("%.2f", (change))
|
||||||
|
+ "%)";
|
||||||
else
|
else
|
||||||
resultStr = "Unknown";
|
resultStr = "Unknown";
|
||||||
KeyValue wi = new KeyValue();
|
KeyValue wi = new KeyValue();
|
||||||
wi.setKey(symbol.concat("/").concat(currency.toUpperCase()));
|
wi.setKey(symbol.concat("/").concat(currency.toUpperCase()));
|
||||||
wi.setValue(resultStr);
|
wi.setValue(resultStr);
|
||||||
if (change>0)
|
if (change > 0)
|
||||||
wi.setColor("#00FF99");
|
wi.setColor("#00FF99");
|
||||||
else
|
else
|
||||||
wi.setColor("#FF5050");
|
wi.setColor("#FF5050");
|
||||||
@ -97,7 +99,7 @@ public class MiningBean {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@ -518,10 +520,10 @@ public class MiningBean {
|
|||||||
|
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
for (KeyValue kv : prices) {
|
for (KeyValue kv : prices) {
|
||||||
if (kv.getColor()==null)
|
if (kv.getColor() == null)
|
||||||
kv.setColor("#00CCFF");
|
kv.setColor("#00CCFF");
|
||||||
tmp = tmp.concat("<pair><key>").concat(
|
tmp = tmp.concat("<pair><key>").concat(kv.getKey().concat("</key>").concat("<value>").concat(kv.getValue())
|
||||||
kv.getKey().concat("</key>").concat("<value>").concat(kv.getValue()).concat("</value>").concat("<color>").concat(kv.getColor()).concat("</color></pair>"));
|
.concat("</value>").concat("<color>").concat(kv.getColor()).concat("</color></pair>"));
|
||||||
}
|
}
|
||||||
res = res.replace("#PRICES#", tmp);
|
res = res.replace("#PRICES#", tmp);
|
||||||
|
|
||||||
@ -550,8 +552,8 @@ public class MiningBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int searchArray(String[] array, String key) {
|
private int searchArray(String[] array, String key) {
|
||||||
int i=0;
|
int i = 0;
|
||||||
for (String str:array) {
|
for (String str : array) {
|
||||||
if (str.equals(key))
|
if (str.equals(key))
|
||||||
return i;
|
return i;
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user