Marketp cap activity improvements
- Add icon review - Add "global" and "others" info - Add dominance percentage
This commit is contained in:
parent
9845edd8cb
commit
2cfb2df9d3
@ -42,7 +42,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.nauk.moodl.MoodlBox.numberConformer;
|
|
||||||
import static java.lang.Math.abs;
|
import static java.lang.Math.abs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -213,8 +212,6 @@ public class MarketCapitalization extends Fragment {
|
|||||||
|
|
||||||
private void refreshDisplayedData()
|
private void refreshDisplayedData()
|
||||||
{
|
{
|
||||||
setupTextViewMarketCap();
|
|
||||||
|
|
||||||
view.findViewById(R.id.progressBarMarketCap).setVisibility(View.GONE);
|
view.findViewById(R.id.progressBarMarketCap).setVisibility(View.GONE);
|
||||||
view.findViewById(R.id.layoutProgressMarketCap).setVisibility(View.VISIBLE);
|
view.findViewById(R.id.layoutProgressMarketCap).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
@ -252,7 +249,7 @@ public class MarketCapitalization extends Fragment {
|
|||||||
colors.add(dominantCurrenciesColors.get(topCurrencies.get(i).getSymbol()));
|
colors.add(dominantCurrenciesColors.get(topCurrencies.get(i).getSymbol()));
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.add(new PieEntry(100-topCurrenciesDominance, "Others"));
|
entries.add(new PieEntry(100-topCurrenciesDominance, "Others", "others"));
|
||||||
colors.add(-12369084);
|
colors.add(-12369084);
|
||||||
|
|
||||||
PieDataSet set = new PieDataSet(entries, "Market Cap Dominance");
|
PieDataSet set = new PieDataSet(entries, "Market Cap Dominance");
|
||||||
@ -323,6 +320,8 @@ public class MarketCapitalization extends Fragment {
|
|||||||
pieChart.setTouchEnabled(true);
|
pieChart.setTouchEnabled(true);
|
||||||
pieChart.setEntryLabelColor(Color.WHITE);
|
pieChart.setEntryLabelColor(Color.WHITE);
|
||||||
|
|
||||||
|
updateDetails(marketCapManager.getMarketCap(), marketCapManager.getDayVolume(), "Global", 0);
|
||||||
|
|
||||||
pieChart.setOnTouchListener(new View.OnTouchListener() {
|
pieChart.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||||
@ -350,19 +349,15 @@ public class MarketCapitalization extends Fragment {
|
|||||||
getActivity().runOnUiThread(new Runnable() {
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(e.getData() != null)
|
|
||||||
{
|
|
||||||
view.findViewById(R.id.layoutMarketDetails).setVisibility(View.VISIBLE);
|
|
||||||
view.findViewById(R.id.currencyIcon).setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
|
if(!e.getData().equals("others"))
|
||||||
|
{
|
||||||
Currency currency = marketCapManager.getCurrencyFromSymbol((String) e.getData());
|
Currency currency = marketCapManager.getCurrencyFromSymbol((String) e.getData());
|
||||||
|
view.findViewById(R.id.currencyIcon).setVisibility(View.VISIBLE);
|
||||||
((TextView) view.findViewById(R.id.textViewMarketCap))
|
view.findViewById(R.id.layoutPercentageDominance).setVisibility(View.VISIBLE);
|
||||||
.setText(PlaceholderManager.getValueString(MoodlBox.numberConformer(currency.getMarketCapitalization()), getContext()));
|
|
||||||
((TextView) view.findViewById(R.id.textViewVolume))
|
updateDetails(currency.getMarketCapitalization(), currency.getVolume24h(), currency.getName() + " (" + currency.getSymbol() + ")", h.getY());
|
||||||
.setText(PlaceholderManager.getValueString(MoodlBox.numberConformer(currency.getVolume24h()), getContext()));
|
|
||||||
((TextView) view.findViewById(R.id.textViewNameSymbol))
|
|
||||||
.setText(currency.getName() + " (" + currency.getSymbol() + ")");
|
|
||||||
((ImageView) view.findViewById(R.id.currencyIcon))
|
((ImageView) view.findViewById(R.id.currencyIcon))
|
||||||
.setImageBitmap(currency.getIcon());
|
.setImageBitmap(currency.getIcon());
|
||||||
|
|
||||||
@ -370,8 +365,20 @@ public class MarketCapitalization extends Fragment {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
double othersMarketCap = marketCapManager.getMarketCap();
|
||||||
|
double othersVolume = marketCapManager.getDayVolume();
|
||||||
|
|
||||||
|
for(int i = 0; i < marketCapManager.getTopCurrencies().size(); i++)
|
||||||
|
{
|
||||||
|
othersMarketCap -= marketCapManager.getTopCurrencies().get(i).getMarketCapitalization();
|
||||||
|
othersVolume -= marketCapManager.getTopCurrencies().get(i).getVolume24h();
|
||||||
|
}
|
||||||
|
|
||||||
view.findViewById(R.id.currencyIcon).setVisibility(View.GONE);
|
view.findViewById(R.id.currencyIcon).setVisibility(View.GONE);
|
||||||
view.findViewById(R.id.layoutMarketDetails).setVisibility(View.GONE);
|
view.findViewById(R.id.layoutPercentageDominance).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
updateDetails(othersMarketCap, othersVolume, "Other coins", h.getY());
|
||||||
|
|
||||||
pieChart.setDrawCenterText(true);
|
pieChart.setDrawCenterText(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -381,7 +388,10 @@ public class MarketCapitalization extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onNothingSelected() {
|
public void onNothingSelected() {
|
||||||
view.findViewById(R.id.currencyIcon).setVisibility(View.GONE);
|
view.findViewById(R.id.currencyIcon).setVisibility(View.GONE);
|
||||||
view.findViewById(R.id.layoutMarketDetails).setVisibility(View.GONE);
|
view.findViewById(R.id.layoutPercentageDominance).setVisibility(View.GONE);
|
||||||
|
|
||||||
|
updateDetails(marketCapManager.getMarketCap(), marketCapManager.getDayVolume(), "Global", 0);
|
||||||
|
|
||||||
pieChart.setDrawCenterText(true);
|
pieChart.setDrawCenterText(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -392,17 +402,21 @@ public class MarketCapitalization extends Fragment {
|
|||||||
pieChart.invalidate();
|
pieChart.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDetails(double marketCap, double volume, String title, double percentage)
|
||||||
|
{
|
||||||
|
((TextView) view.findViewById(R.id.textViewMarketCap))
|
||||||
|
.setText(PlaceholderManager.getValueString(MoodlBox.numberConformer(marketCap), getContext()));
|
||||||
|
((TextView) view.findViewById(R.id.textViewVolume))
|
||||||
|
.setText(PlaceholderManager.getValueString(MoodlBox.numberConformer(volume), getContext()));
|
||||||
|
((TextView) view.findViewById(R.id.textViewTitle))
|
||||||
|
.setText(title);
|
||||||
|
((TextView) view.findViewById(R.id.textViewDominancePercentage))
|
||||||
|
.setText(PlaceholderManager.getPercentageString(MoodlBox.numberConformer(percentage), getContext()));
|
||||||
|
}
|
||||||
|
|
||||||
private SpannableString generateCenterSpannableText() {
|
private SpannableString generateCenterSpannableText() {
|
||||||
|
|
||||||
SpannableString spannableString = new SpannableString("Market Capitalization Dominance");
|
SpannableString spannableString = new SpannableString("Market Capitalization Dominance");
|
||||||
return spannableString;
|
return spannableString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTextViewMarketCap()
|
|
||||||
{
|
|
||||||
((TextView) view.findViewById(R.id.marketCapTextView))
|
|
||||||
.setText(PlaceholderManager.getValueString(numberConformer(marketCapManager.getMarketCap()), getActivity()));
|
|
||||||
((TextView) view.findViewById(R.id.dayVolumeTotalMarketCap))
|
|
||||||
.setText(PlaceholderManager.getValueString(numberConformer(marketCapManager.getDayVolume()), getActivity()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -403,12 +403,16 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
loadingDialog.dismiss();
|
loadingDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
try {
|
||||||
@Override
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
updateTitle();
|
public void run() {
|
||||||
}
|
updateTitle();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateTitle()
|
protected void updateTitle()
|
||||||
|
@ -78,31 +78,10 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/marketCapTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:textSize="20dp"
|
|
||||||
android:gravity="center_horizontal"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/dayVolumeTotalMarketCap"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:gravity="center_horizontal"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="350dp">
|
android:layout_height="350dp"
|
||||||
|
android:layout_marginTop="5dp">
|
||||||
|
|
||||||
<com.nauk.moodl.LayoutManagers.CustomPieChart
|
<com.nauk.moodl.LayoutManagers.CustomPieChart
|
||||||
android:id="@+id/marketCapPieChart"
|
android:id="@+id/marketCapPieChart"
|
||||||
@ -128,13 +107,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp">
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/textViewNameSymbol"
|
android:id="@+id/textViewTitle"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textSize="20sp"/>
|
android:textSize="20sp"/>
|
||||||
|
|
||||||
@ -168,6 +146,27 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layoutPercentageDominance"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="5dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Dominance percentage"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textViewDominancePercentage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
Loading…
Reference in New Issue
Block a user