Some market capitalization details
This commit is contained in:
parent
8f45e65666
commit
44333e55f7
@ -16,10 +16,13 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.github.mikephil.charting.charts.PieChart;
|
import com.github.mikephil.charting.charts.PieChart;
|
||||||
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.data.PieData;
|
import com.github.mikephil.charting.data.PieData;
|
||||||
import com.github.mikephil.charting.data.PieDataSet;
|
import com.github.mikephil.charting.data.PieDataSet;
|
||||||
import com.github.mikephil.charting.data.PieEntry;
|
import com.github.mikephil.charting.data.PieEntry;
|
||||||
import com.github.mikephil.charting.formatter.PercentFormatter;
|
import com.github.mikephil.charting.formatter.PercentFormatter;
|
||||||
|
import com.github.mikephil.charting.highlight.Highlight;
|
||||||
|
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||||
import com.nauk.moodl.Activities.SettingsActivity;
|
import com.nauk.moodl.Activities.SettingsActivity;
|
||||||
import com.nauk.moodl.DataManagers.CurrencyData.Currency;
|
import com.nauk.moodl.DataManagers.CurrencyData.Currency;
|
||||||
import com.nauk.moodl.DataManagers.MarketCapManager;
|
import com.nauk.moodl.DataManagers.MarketCapManager;
|
||||||
@ -207,7 +210,7 @@ public class MarketCapitalization extends Fragment {
|
|||||||
|
|
||||||
for(int i = 0; i < topCurrencies.size(); i++)
|
for(int i = 0; i < topCurrencies.size(); i++)
|
||||||
{
|
{
|
||||||
PieEntry pieEntry = new PieEntry(topCurrencies.get(i).getDominance(marketCapManager.getMarketCap()), topCurrencies.get(i).getSymbol());
|
PieEntry pieEntry = new PieEntry(topCurrencies.get(i).getDominance(marketCapManager.getMarketCap()), topCurrencies.get(i).getSymbol(), topCurrencies.get(i).getSymbol());
|
||||||
|
|
||||||
if(pieEntry.getValue() < 3)
|
if(pieEntry.getValue() < 3)
|
||||||
{
|
{
|
||||||
@ -271,6 +274,19 @@ public class MarketCapitalization extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onValueSelected(Entry e, Highlight h) {
|
||||||
|
Currency currency = marketCapManager.getCurrencyFromSymbol((String) e.getData());
|
||||||
|
Log.d("moodl", "> " + currency.getSymbol() + " " + currency.getMarketCapitalization() + " " + currency.getVolume24h());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
pieChart.getDescription().setEnabled(false);
|
pieChart.getDescription().setEnabled(false);
|
||||||
pieChart.getLegend().setEnabled(false);
|
pieChart.getLegend().setEnabled(false);
|
||||||
pieChart.setCenterText(generateCenterSpannableText());
|
pieChart.setCenterText(generateCenterSpannableText());
|
||||||
|
@ -40,6 +40,8 @@ public class Currency implements Parcelable {
|
|||||||
private String proofType;
|
private String proofType;
|
||||||
private int totalSupply;
|
private int totalSupply;
|
||||||
private double marketCapitalization;
|
private double marketCapitalization;
|
||||||
|
|
||||||
|
private double volume24h;
|
||||||
private double dominance;
|
private double dominance;
|
||||||
private int rank;
|
private int rank;
|
||||||
private String startDate;
|
private String startDate;
|
||||||
@ -268,6 +270,14 @@ public class Currency implements Parcelable {
|
|||||||
this.chartColor = chartColor;
|
this.chartColor = chartColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getVolume24h() {
|
||||||
|
return volume24h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolume24h(double volume24h) {
|
||||||
|
this.volume24h = volume24h;
|
||||||
|
}
|
||||||
|
|
||||||
public int getChartColor()
|
public int getChartColor()
|
||||||
{
|
{
|
||||||
return chartColor;
|
return chartColor;
|
||||||
|
@ -135,6 +135,7 @@ public class MarketCapManager {
|
|||||||
JSONObject quoteJsonObject = subCurrencyJsonObject.getJSONObject("quotes");
|
JSONObject quoteJsonObject = subCurrencyJsonObject.getJSONObject("quotes");
|
||||||
JSONObject symJsonObject = quoteJsonObject.getJSONObject(toSymbol);
|
JSONObject symJsonObject = quoteJsonObject.getJSONObject(toSymbol);
|
||||||
newCurrency.setMarketCapitalization(symJsonObject.getDouble("market_cap"));
|
newCurrency.setMarketCapitalization(symJsonObject.getDouble("market_cap"));
|
||||||
|
newCurrency.setVolume24h(symJsonObject.getDouble("volume_24h"));
|
||||||
|
|
||||||
topCurrencies.add(newCurrency);
|
topCurrencies.add(newCurrency);
|
||||||
}
|
}
|
||||||
@ -144,6 +145,22 @@ public class MarketCapManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Currency getCurrencyFromSymbol(String symbol)
|
||||||
|
{
|
||||||
|
Currency returnedCurrency = null;
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if(symbol.equals(topCurrencies.get(index).getSymbol()))
|
||||||
|
{
|
||||||
|
returnedCurrency = topCurrencies.get(index);
|
||||||
|
}
|
||||||
|
} while(index < topCurrencies.size() && returnedCurrency == null);
|
||||||
|
|
||||||
|
|
||||||
|
return returnedCurrency;
|
||||||
|
}
|
||||||
|
|
||||||
public long getMarketCap()
|
public long getMarketCap()
|
||||||
{
|
{
|
||||||
return marketCap;
|
return marketCap;
|
||||||
|
Loading…
Reference in New Issue
Block a user