Update graddle | Display marketcap details | Fix marketcap piechart click crash
This commit is contained in:
parent
44333e55f7
commit
984956e535
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
4
.idea/gradle.xml
generated
4
.idea/gradle.xml
generated
@ -3,9 +3,9 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="LOCAL" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-4.1" />
|
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-4.7" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
@ -14,6 +14,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
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.Entry;
|
||||||
@ -27,6 +28,7 @@ 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;
|
||||||
import com.nauk.moodl.DataManagers.PreferencesManager;
|
import com.nauk.moodl.DataManagers.PreferencesManager;
|
||||||
|
import com.nauk.moodl.LayoutManagers.CustomPieChart;
|
||||||
import com.nauk.moodl.LayoutManagers.CustomViewPager;
|
import com.nauk.moodl.LayoutManagers.CustomViewPager;
|
||||||
import com.nauk.moodl.PlaceholderManager;
|
import com.nauk.moodl.PlaceholderManager;
|
||||||
import com.nauk.moodl.R;
|
import com.nauk.moodl.R;
|
||||||
@ -246,7 +248,7 @@ public class MarketCapitalization extends Fragment {
|
|||||||
|
|
||||||
private void setupPieChart(PieData data)
|
private void setupPieChart(PieData data)
|
||||||
{
|
{
|
||||||
PieChart pieChart = view.findViewById(R.id.marketCapPieChart);
|
CustomPieChart pieChart = view.findViewById(R.id.marketCapPieChart);
|
||||||
|
|
||||||
pieChart.setData(data);
|
pieChart.setData(data);
|
||||||
pieChart.setDrawSlicesUnderHole(false);
|
pieChart.setDrawSlicesUnderHole(false);
|
||||||
@ -270,6 +272,9 @@ public class MarketCapitalization extends Fragment {
|
|||||||
((CustomViewPager) view.getParent().getParent().getParent().getParent().getParent()).setPagingEnabled(true);
|
((CustomViewPager) view.getParent().getParent().getParent().getParent().getParent()).setPagingEnabled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view.performClick();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -277,8 +282,23 @@ public class MarketCapitalization extends Fragment {
|
|||||||
pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onValueSelected(Entry e, Highlight h) {
|
public void onValueSelected(Entry e, Highlight h) {
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(e.getData() != null)
|
||||||
|
{
|
||||||
Currency currency = marketCapManager.getCurrencyFromSymbol((String) e.getData());
|
Currency currency = marketCapManager.getCurrencyFromSymbol((String) e.getData());
|
||||||
Log.d("moodl", "> " + currency.getSymbol() + " " + currency.getMarketCapitalization() + " " + currency.getVolume24h());
|
//view.findViewById(R.id.layoutMarketDetails).setVisibility();
|
||||||
|
((TextView) view.findViewById(R.id.textViewMarketCap))
|
||||||
|
.setText(PlaceholderManager.getValueString(String.valueOf(currency.getMarketCapitalization()), getContext()));
|
||||||
|
((TextView) view.findViewById(R.id.textViewVolume))
|
||||||
|
.setText(PlaceholderManager.getValueString(String.valueOf(currency.getVolume24h()), getContext()));
|
||||||
|
((TextView) view.findViewById(R.id.textViewSymbol))
|
||||||
|
.setText(currency.getName());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -155,6 +155,8 @@ public class MarketCapManager {
|
|||||||
{
|
{
|
||||||
returnedCurrency = topCurrencies.get(index);
|
returnedCurrency = topCurrencies.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
} while(index < topCurrencies.size() && returnedCurrency == null);
|
} while(index < topCurrencies.size() && returnedCurrency == null);
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.nauk.moodl.LayoutManagers;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.charts.PieChart;
|
||||||
|
|
||||||
|
public class CustomPieChart extends PieChart {
|
||||||
|
|
||||||
|
public CustomPieChart(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomPieChart(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomPieChart(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean performClick() {
|
||||||
|
super.performClick();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -101,11 +101,62 @@
|
|||||||
android:textSize="18dp"
|
android:textSize="18dp"
|
||||||
android:gravity="center_horizontal"/>
|
android:gravity="center_horizontal"/>
|
||||||
|
|
||||||
<com.github.mikephil.charting.charts.PieChart
|
<com.nauk.moodl.LayoutManagers.CustomPieChart
|
||||||
android:id="@+id/marketCapPieChart"
|
android:id="@+id/marketCapPieChart"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="350dp"/>
|
android:layout_height="350dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layoutMarketDetails"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/textViewSymbol"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Market capitalization"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textViewMarketCap"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="24h volume"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textViewVolume"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user