Added cache toggle to some requests
This commit is contained in:
parent
90ce3ef3a2
commit
f45a9e2840
|
|
@ -313,8 +313,7 @@ public class HomeFragment extends Fragment {
|
|||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == R.id.today_this_month_details) {
|
||||
// Handle the "Details..." option
|
||||
// For example, navigate to a details fragment
|
||||
// Implement as in profit_report.py
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -330,7 +329,7 @@ public class HomeFragment extends Fragment {
|
|||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == R.id.exchangeMenuGlobalStatus) {
|
||||
fetchExchangeDetails(exchange);
|
||||
fetchExchangeDetails(exchange, true);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.exchangeMenuMissingPairs) {
|
||||
fetchMissingPairs(exchange);
|
||||
|
|
@ -342,10 +341,10 @@ public class HomeFragment extends Fragment {
|
|||
fetchTraderTime(exchange);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.exchangeMenuPausedTraders) {
|
||||
fetchPausedTraders(exchange);
|
||||
fetchPausedTraders(exchange, true);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.exchangeMenuConfigFile) {
|
||||
fetchExchangeConfig(exchange);
|
||||
fetchExchangeConfig(exchange, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -411,30 +410,36 @@ public class HomeFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void fetchExchangeDetails(String exchange) {
|
||||
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 fetchExchangeDetails(String exchange, boolean cached) {
|
||||
if (cached) {
|
||||
showInstanceDetailsDialog(MainActivity.getInstanceCache(exchange).getGlobalStats());
|
||||
} else {
|
||||
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) {
|
||||
private void fetchPausedTraders(String exchange, boolean cached) {
|
||||
if (cached) {
|
||||
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();
|
||||
} else {
|
||||
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) {
|
||||
|
|
@ -473,17 +478,20 @@ public class HomeFragment extends Fragment {
|
|||
}).start();
|
||||
}
|
||||
|
||||
private void fetchExchangeConfig(String exchange) {
|
||||
private void fetchExchangeConfig(String exchange, boolean cached) {
|
||||
if (cached) {
|
||||
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();
|
||||
} else {
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue