wip
This commit is contained in:
parent
e50cfa808b
commit
7cf1beaf4c
|
|
@ -5,6 +5,7 @@
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:enableOnBackInvokedCallback="true"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class BinanceViewModel extends AndroidViewModel {
|
||||||
// Simulate fetching data from a source
|
// Simulate fetching data from a source
|
||||||
List<WorkerData> data = new ArrayList<>();
|
List<WorkerData> data = new ArrayList<>();
|
||||||
// Add WorkerData objects to the list
|
// Add WorkerData objects to the list
|
||||||
workerDataList.setValue(data);
|
workerDataList.postValue(data);
|
||||||
|
|
||||||
// Schedule a periodic update
|
// Schedule a periodic update
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
|
@ -40,6 +40,7 @@ public class BinanceViewModel extends AndroidViewModel {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
// Fetch and update the data
|
// Fetch and update the data
|
||||||
List<WorkerData> newData = InstanceInterface.fetchWorkersDataForCards("binance");
|
List<WorkerData> newData = InstanceInterface.fetchWorkersDataForCards("binance");
|
||||||
|
//System.err.println(newData.toString());
|
||||||
workerDataList.postValue(newData);
|
workerDataList.postValue(newData);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -51,5 +52,4 @@ public class BinanceViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -20,6 +20,8 @@ public class WorkerData {
|
||||||
double nextSoPrice, double price, double takeProfitPrice, boolean isShort,
|
double nextSoPrice, double price, double takeProfitPrice, boolean isShort,
|
||||||
boolean isBoosted, boolean isAuto, boolean isPaused,
|
boolean isBoosted, boolean isAuto, boolean isPaused,
|
||||||
InstanceInterface.OldLongDictionary oldLongDictionary) {
|
InstanceInterface.OldLongDictionary oldLongDictionary) {
|
||||||
|
|
||||||
|
// TODO: Add total_amount_of_quote and total_amount_of_base
|
||||||
this.pair = pair;
|
this.pair = pair;
|
||||||
this.amountOfSafetyOrders = amountOfSafetyOrders;
|
this.amountOfSafetyOrders = amountOfSafetyOrders;
|
||||||
this.maxSafetyOrders = maxSafetyOrders;
|
this.maxSafetyOrders = maxSafetyOrders;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package com.example.dcav2gui.ui.exchanges.adapters;
|
package com.example.dcav2gui.ui.exchanges.adapters;
|
||||||
|
|
||||||
|
import static java.lang.Math.abs;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
@ -11,6 +14,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.example.dcav2gui.R;
|
import com.example.dcav2gui.R;
|
||||||
import com.example.dcav2gui.ui.exchanges.WorkerData;
|
import com.example.dcav2gui.ui.exchanges.WorkerData;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class WorkerCardAdapter extends RecyclerView.Adapter<WorkerCardAdapter.WorkerViewHolder> {
|
public class WorkerCardAdapter extends RecyclerView.Adapter<WorkerCardAdapter.WorkerViewHolder> {
|
||||||
|
|
||||||
|
|
@ -30,11 +35,33 @@ public class WorkerCardAdapter extends RecyclerView.Adapter<WorkerCardAdapter.Wo
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull WorkerViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull WorkerViewHolder holder, int position) {
|
||||||
WorkerData worker = workerDataList.get(position);
|
WorkerData worker = workerDataList.get(position);
|
||||||
|
holder.pair.setText(worker.getPair());
|
||||||
|
holder.price.setText(String.format(Locale.ROOT, "%.8f", worker.getPrice()));
|
||||||
|
holder.nextSoPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getNextSoPrice()));
|
||||||
|
holder.takeProfitPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getTakeProfitPrice()));
|
||||||
|
|
||||||
//Here goes all the logic to update the view
|
String percentage = String.format(Locale.ROOT, "%.2f",abs(worker.getTakeProfitPrice()- worker.getPrice())/worker.getPrice()*100)+"%";
|
||||||
|
holder.percentage.setText(percentage);
|
||||||
|
|
||||||
|
String safetyOrders = worker.getAmountOfSafetyOrders() + " / " + worker.getMaxSafetyOrders();
|
||||||
|
holder.safetyOrders.setText(safetyOrders);
|
||||||
|
|
||||||
|
holder.uptime.setText(formatSeconds(worker.getUptime()));
|
||||||
|
|
||||||
|
double progressBarPercentage = (worker.getPrice()-worker.getNextSoPrice())/(worker.getTakeProfitPrice()-worker.getNextSoPrice());
|
||||||
|
holder.progressBar.setProgress((int) (progressBarPercentage * 100));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatSeconds(double seconds) {
|
||||||
|
long days = TimeUnit.SECONDS.toDays((long) seconds);
|
||||||
|
long hours = TimeUnit.SECONDS.toHours((long) seconds) % 24;
|
||||||
|
long minutes = TimeUnit.SECONDS.toMinutes((long) seconds) % 60;
|
||||||
|
long secs = (long) (seconds % 60);
|
||||||
|
|
||||||
|
return String.format(Locale.ROOT,"%03d:%02d:%02d:%02d", days, hours, minutes, secs);
|
||||||
|
|
||||||
// holder.workerName.setText(worker.getName());
|
|
||||||
// holder.workerStatus.setText(worker.getStatus());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue