rudimentary status bars
This commit is contained in:
parent
85ca15269c
commit
0028f3285d
|
|
@ -4,7 +4,7 @@
|
|||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2024-12-16T13:29:08.700369272Z">
|
||||
<DropdownSelection timestamp="2024-12-17T22:52:32.286553137Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/nicolas/.android/avd/Pixel_6_Pro_API_34.avd" />
|
||||
|
|
|
|||
|
|
@ -5,11 +5,20 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.dcav2gui.InstanceInterface;
|
||||
import com.example.dcav2gui.R;
|
||||
import com.example.dcav2gui.databinding.FragmentBinanceBinding;
|
||||
import com.example.dcav2gui.ui.exchanges.adapters.WorkerCardAdapter;
|
||||
import com.example.dcav2gui.ui.exchanges.WorkerData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class BinanceFragment extends Fragment {
|
||||
|
|
@ -17,6 +26,7 @@ public class BinanceFragment extends Fragment {
|
|||
private FragmentBinanceBinding binding;
|
||||
private BinanceViewModel binanceViewModel;
|
||||
private WorkerCardAdapter workerCardAdapter;
|
||||
private TextView statusBar;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
|
|
@ -24,16 +34,22 @@ public class BinanceFragment extends Fragment {
|
|||
binding = FragmentBinanceBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
//Initialize status bar
|
||||
statusBar = root.findViewById(R.id.binance_status_bar);
|
||||
|
||||
binanceViewModel = new ViewModelProvider(this).get(BinanceViewModel.class);
|
||||
|
||||
workerCardAdapter = new WorkerCardAdapter(binding.binanceCardsContainer);
|
||||
|
||||
binanceViewModel.getWorkerData().observe(getViewLifecycleOwner(), workerDataList -> {
|
||||
if (workerDataList != null) {
|
||||
WorkerCardAdapter.populateStatusBar(statusBar, workerDataList);
|
||||
workerCardAdapter.updateData(workerDataList);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -42,10 +42,8 @@ public class BinanceViewModel extends AndroidViewModel {
|
|||
List<WorkerData> newData = InstanceInterface.fetchWorkersDataForCards("binance");
|
||||
//System.err.println(newData.toString());
|
||||
workerDataList.postValue(newData);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
|
|
|||
|
|
@ -4,9 +4,13 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.dcav2gui.R;
|
||||
import com.example.dcav2gui.databinding.FragmentGateioBinding;
|
||||
import com.example.dcav2gui.ui.exchanges.adapters.WorkerCardAdapter;
|
||||
|
||||
|
|
@ -16,6 +20,7 @@ public class GateioFragment extends Fragment {
|
|||
private FragmentGateioBinding binding;
|
||||
private GateioViewModel GateioViewModel;
|
||||
private WorkerCardAdapter workerCardAdapter;
|
||||
private TextView statusBar;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
|
|
@ -23,12 +28,16 @@ public class GateioFragment extends Fragment {
|
|||
binding = FragmentGateioBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
//Initialize status bar
|
||||
statusBar = root.findViewById(R.id.gateio_status_bar);
|
||||
|
||||
GateioViewModel = new ViewModelProvider(this).get(GateioViewModel.class);
|
||||
|
||||
workerCardAdapter = new WorkerCardAdapter(binding.gateioCardsContainer);
|
||||
|
||||
GateioViewModel.getWorkerData().observe(getViewLifecycleOwner(), workerDataList -> {
|
||||
if (workerDataList != null) {
|
||||
WorkerCardAdapter.populateStatusBar(statusBar, workerDataList);
|
||||
workerCardAdapter.updateData(workerDataList);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,10 +41,8 @@ public class GateioViewModel extends AndroidViewModel {
|
|||
List<WorkerData> newData = InstanceInterface.fetchWorkersDataForCards("gateio");
|
||||
//System.err.println(newData.toString());
|
||||
workerDataList.postValue(newData);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
|
|
|||
|
|
@ -4,9 +4,13 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.dcav2gui.R;
|
||||
import com.example.dcav2gui.databinding.FragmentKucoinBinding;
|
||||
import com.example.dcav2gui.ui.exchanges.adapters.WorkerCardAdapter;
|
||||
|
||||
|
|
@ -16,6 +20,7 @@ public class KucoinFragment extends Fragment {
|
|||
private FragmentKucoinBinding binding;
|
||||
private KucoinViewModel KucoinViewModel;
|
||||
private WorkerCardAdapter workerCardAdapter;
|
||||
private TextView statusBar;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
|
|
@ -23,12 +28,16 @@ public class KucoinFragment extends Fragment {
|
|||
binding = FragmentKucoinBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
//Initialize status bar
|
||||
statusBar = root.findViewById(R.id.kucoin_status_bar);
|
||||
|
||||
KucoinViewModel = new ViewModelProvider(this).get(KucoinViewModel.class);
|
||||
|
||||
workerCardAdapter = new WorkerCardAdapter(binding.kucoinCardsContainer);
|
||||
|
||||
KucoinViewModel.getWorkerData().observe(getViewLifecycleOwner(), workerDataList -> {
|
||||
if (workerDataList != null) {
|
||||
WorkerCardAdapter.populateStatusBar(statusBar, workerDataList);
|
||||
workerCardAdapter.updateData(workerDataList);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,10 +41,8 @@ public class KucoinViewModel extends AndroidViewModel {
|
|||
List<WorkerData> newData = InstanceInterface.fetchWorkersDataForCards("kucoin");
|
||||
//System.err.println(newData.toString());
|
||||
workerDataList.postValue(newData);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
|
|
|||
|
|
@ -4,9 +4,13 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.dcav2gui.R;
|
||||
import com.example.dcav2gui.databinding.FragmentOkxBinding;
|
||||
import com.example.dcav2gui.ui.exchanges.adapters.WorkerCardAdapter;
|
||||
|
||||
|
|
@ -16,6 +20,7 @@ public class OkxFragment extends Fragment {
|
|||
private FragmentOkxBinding binding;
|
||||
private OkxViewModel OkxViewModel;
|
||||
private WorkerCardAdapter workerCardAdapter;
|
||||
private TextView statusBar;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
|
|
@ -23,12 +28,16 @@ public class OkxFragment extends Fragment {
|
|||
binding = FragmentOkxBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
//Initialize status bar
|
||||
statusBar = root.findViewById(R.id.okex_status_bar);
|
||||
|
||||
OkxViewModel = new ViewModelProvider(this).get(OkxViewModel.class);
|
||||
|
||||
workerCardAdapter = new WorkerCardAdapter(binding.okexCardsContainer);
|
||||
|
||||
OkxViewModel.getWorkerData().observe(getViewLifecycleOwner(), workerDataList -> {
|
||||
if (workerDataList != null) {
|
||||
WorkerCardAdapter.populateStatusBar(statusBar, workerDataList);
|
||||
workerCardAdapter.updateData(workerDataList);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,10 +41,8 @@ public class OkxViewModel extends AndroidViewModel {
|
|||
List<WorkerData> newData = InstanceInterface.fetchWorkersDataForCards("okex");
|
||||
//System.err.println(newData.toString());
|
||||
workerDataList.postValue(newData);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
|
|
|||
|
|
@ -107,6 +107,22 @@ public class WorkerCardAdapter{
|
|||
|
||||
}
|
||||
|
||||
public static void populateStatusBar(TextView statusBar, List<WorkerData> workerDataList) {
|
||||
int amountOfWorkers = workerDataList.size();
|
||||
int safetyOrdersSent = 0;
|
||||
int maxSafetyOrders = 0;
|
||||
|
||||
//Iterate workerDataList and extract the total amount of safety orders
|
||||
for (WorkerData worker : workerDataList) {
|
||||
if (!worker.isShort()) {
|
||||
safetyOrdersSent+=worker.getAmountOfSafetyOrders()-1;
|
||||
maxSafetyOrders+=worker.getMaxSafetyOrders();
|
||||
}
|
||||
}
|
||||
String percentage = String.format(Locale.ROOT, "%.2f", (double) safetyOrdersSent/maxSafetyOrders*100);
|
||||
String statusBarText = amountOfWorkers + " traders online - Occupancy " + percentage + "%";
|
||||
statusBar.setText(statusBarText);
|
||||
}
|
||||
|
||||
public static class WorkerViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView pair;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/light_grey"/>
|
||||
<corners android:radius="0dp"/>
|
||||
<stroke android:color="@color/stroke_color" android:width="1dp"/>
|
||||
</shape>
|
||||
|
|
@ -1,15 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/binance_cards_container"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/binance_cards_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<!-- Each card will be added dynamically here -->
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
<TextView
|
||||
android:id="@+id/binance_status_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<!-- Each card will be added dynamically here -->
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
android:background="@drawable/status_bar_background"
|
||||
android:text="Loading..."
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/black"
|
||||
android:padding="6dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -1,15 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/gateio_cards_container"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/gateio_cards_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<!-- Each card will be added dynamically here -->
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
<TextView
|
||||
android:id="@+id/gateio_status_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<!-- Each card will be added dynamically here -->
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
android:background="@drawable/status_bar_background"
|
||||
android:text="Loading..."
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/black"
|
||||
android:padding="6dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -1,15 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/kucoin_cards_container"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/kucoin_cards_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<!-- Each card will be added dynamically here -->
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
<TextView
|
||||
android:id="@+id/kucoin_status_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<!-- Each card will be added dynamically here -->
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
android:background="@drawable/status_bar_background"
|
||||
android:text="Loading..."
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/black"
|
||||
android:padding="6dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -1,15 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/okex_cards_container"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/okex_cards_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<!-- Each card will be added dynamically here -->
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
<TextView
|
||||
android:id="@+id/okex_status_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<!-- Each card will be added dynamically here -->
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
android:background="@drawable/status_bar_background"
|
||||
android:text="Loading..."
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/black"
|
||||
android:padding="6dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
<color name="blue">#FF0000FF</color>
|
||||
<color name="yellow">#FFFFFF00</color>
|
||||
<color name="grey">#FF424242</color>
|
||||
<color name= "light_grey">#979797</color>
|
||||
<color name="orange">#FFA500</color>
|
||||
<color name="dark_cyan">#008B8B</color>
|
||||
<color name="dark_green">#006A00</color>
|
||||
|
|
|
|||
Loading…
Reference in New Issue