Add active markets/cryptocurrencies at marketcap activity

This commit is contained in:
Tanguy Herbron 2018-05-26 17:17:33 +02:00
parent 2cfb2df9d3
commit 9218d54261
3 changed files with 64 additions and 1 deletions

View File

@ -321,6 +321,10 @@ public class MarketCapitalization extends Fragment {
pieChart.setEntryLabelColor(Color.WHITE);
updateDetails(marketCapManager.getMarketCap(), marketCapManager.getDayVolume(), "Global", 0);
((TextView) view.findViewById(R.id.textViewActiveCrypto))
.setText(marketCapManager.getActive_crypto());
((TextView) view.findViewById(R.id.textViewActiveMarkets))
.setText(marketCapManager.getActive_markets());
pieChart.setOnTouchListener(new View.OnTouchListener() {
@Override
@ -350,6 +354,9 @@ public class MarketCapitalization extends Fragment {
@Override
public void run() {
view.findViewById(R.id.layoutActiveCrypto).setVisibility(View.GONE);
view.findViewById(R.id.layoutActiveMarkets).setVisibility(View.GONE);
if(!e.getData().equals("others"))
{
Currency currency = marketCapManager.getCurrencyFromSymbol((String) e.getData());
@ -390,6 +397,9 @@ public class MarketCapitalization extends Fragment {
view.findViewById(R.id.currencyIcon).setVisibility(View.GONE);
view.findViewById(R.id.layoutPercentageDominance).setVisibility(View.GONE);
view.findViewById(R.id.layoutActiveCrypto).setVisibility(View.VISIBLE);
view.findViewById(R.id.layoutActiveMarkets).setVisibility(View.VISIBLE);
updateDetails(marketCapManager.getMarketCap(), marketCapManager.getDayVolume(), "Global", 0);
pieChart.setDrawCenterText(true);

View File

@ -33,6 +33,8 @@ public class MarketCapManager {
private List<Currency> topCurrencies;
private long marketCap;
private long dayVolume;
private String active_crypto;
private String active_markets;
public MarketCapManager(android.content.Context context)
{
@ -99,14 +101,25 @@ public class MarketCapManager {
JSONObject quotesJsonObject = dataJsonObject.getJSONObject("quotes");
JSONObject valuesJsonObject = quotesJsonObject.getJSONObject(toSymbol);
active_crypto = dataJsonObject.getString("active_cryptocurrencies");
active_markets = dataJsonObject.getString("active_markets");
marketCap = valuesJsonObject.getLong("total_market_cap");
dayVolume = valuesJsonObject.getLong("total_volume_24h");
} catch (JSONException e) {
e.printStackTrace();
}
}
public String getActive_crypto()
{
return active_crypto;
}
public String getActive_markets()
{
return active_markets;
}
public List<Currency> getTopCurrencies()
{
return topCurrencies;

View File

@ -167,6 +167,26 @@
</LinearLayout>
<LinearLayout
android:id="@+id/layoutActiveCrypto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Active cryptocurrencies"
android:textStyle="bold"/>
<TextView
android:id="@+id/textViewActiveCrypto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
@ -186,6 +206,26 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:id="@+id/layoutActiveMarkets"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Active markets"
android:textStyle="bold"/>
<TextView
android:id="@+id/textViewActiveMarkets"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>