Using global caches for instance stats

This commit is contained in:
Nicolás Sánchez 2024-12-23 11:46:45 -03:00
parent ad636a445c
commit 90ce3ef3a2
1 changed files with 30 additions and 27 deletions

View File

@ -412,27 +412,29 @@ public class HomeFragment extends Fragment {
}
private void fetchExchangeDetails(String exchange) {
new Thread(() -> {
try {
InstanceInterface.InstanceGlobalStatsData result = InstanceInterface.getInstanceGlobalStatus(exchange, true);
new Handler(Looper.getMainLooper()).post(() -> showInstanceDetailsDialog(result));
} catch (IOException e) {
e.printStackTrace();
new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(getContext(), "Failed to fetch details", Toast.LENGTH_SHORT).show());
}
}).start();
showInstanceDetailsDialog(MainActivity.getInstanceCache(exchange).getGlobalStats());
// new Thread(() -> {
// try {
// InstanceInterface.InstanceGlobalStatsData result = InstanceInterface.getInstanceGlobalStatus(exchange, true);
// new Handler(Looper.getMainLooper()).post(() -> showInstanceDetailsDialog(result));
// } catch (IOException e) {
// e.printStackTrace();
// new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(getContext(), "Failed to fetch details", Toast.LENGTH_SHORT).show());
// }
// }).start();
}
private void fetchPausedTraders(String exchange) {
new Thread(() -> {
try {
InstanceInterface.InstanceGlobalStatsData result = InstanceInterface.getInstanceGlobalStatus(exchange, true);
new Handler(Looper.getMainLooper()).post(() -> showPausedTradersDialog(result));
} catch (IOException e) {
e.printStackTrace();
new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(getContext(), "Failed to fetch details", Toast.LENGTH_SHORT).show());
}
}).start();
showPausedTradersDialog(MainActivity.getInstanceCache(exchange).getGlobalStats());
// new Thread(() -> {
// try {
// InstanceInterface.InstanceGlobalStatsData result = InstanceInterface.getInstanceGlobalStatus(exchange, true);
// new Handler(Looper.getMainLooper()).post(() -> showPausedTradersDialog(result));
// } catch (IOException e) {
// e.printStackTrace();
// new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(getContext(), "Failed to fetch details", Toast.LENGTH_SHORT).show());
// }
// }).start();
}
private void fetchMissingPairs(String exchange) {
@ -472,15 +474,16 @@ public class HomeFragment extends Fragment {
}
private void fetchExchangeConfig(String exchange) {
new Thread(() -> {
try {
InstanceInterface.InstanceGlobalStatsData result = InstanceInterface.getInstanceGlobalStatus(exchange, true);
new Handler(Looper.getMainLooper()).post(() -> showInstanceConfigDialog(result));
} catch (IOException e) {
e.printStackTrace();
new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(getContext(), "Failed to fetch details", Toast.LENGTH_SHORT).show());
}
}).start();
showInstanceConfigDialog(MainActivity.getInstanceCache(exchange).getGlobalStats());
// new Thread(() -> {
// try {
// InstanceInterface.InstanceGlobalStatsData result = InstanceInterface.getInstanceGlobalStatus(exchange, true);
// new Handler(Looper.getMainLooper()).post(() -> showInstanceConfigDialog(result));
// } catch (IOException e) {
// e.printStackTrace();
// new Handler(Looper.getMainLooper()).post(() -> Toast.makeText(getContext(), "Failed to fetch details", Toast.LENGTH_SHORT).show());
// }
// }).start();
}
private void showInstanceDetailsDialog(InstanceInterface.InstanceGlobalStatsData result) {