Update Marketcap Piechart layout and fix conflict with RefreshLayout

This commit is contained in:
Tanguy Herbron 2018-03-13 16:59:21 +01:00
parent 511d239f16
commit 1ca4db4b24
6 changed files with 51 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package com.nauk.coinfolio.Activities;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
@ -25,9 +26,11 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.DragEvent;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@ -283,7 +286,7 @@ public class HomeActivity extends AppCompatActivity {
{
final SpaceNavigationView spaceNavigationView = findViewById(R.id.space);
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
spaceNavigationView.addSpaceItem(new SpaceItem("Charts", R.drawable.ic_show_chart_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("WatchList", R.drawable.ic_remove_red_eye_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Market Cap.", R.drawable.ic_pie_chart_black_24dp));
spaceNavigationView.setSpaceBackgroundColor(getResources().getColor(R.color.colorPrimary));
spaceNavigationView.setCentreButtonIcon(R.drawable.ic_view_list_white_24dp);
@ -325,6 +328,11 @@ public class HomeActivity extends AppCompatActivity {
viewFlipper.setDisplayedChild(itemIndex * 2);
if(itemIndex == 1)
{
((PieChart) findViewById(R.id.marketCapPieChart)).animateX(1000);
}
}
@Override
@ -548,6 +556,7 @@ public class HomeActivity extends AppCompatActivity {
});
}
@SuppressLint("ClickableViewAccessibility")
private void countCompletedMarketCapRequest()
{
marketCapCounter++;
@ -563,7 +572,7 @@ public class HomeActivity extends AppCompatActivity {
ArrayList<Integer> colors = new ArrayList<>();
PieChart pieChart = findViewById(R.id.marketCapPieChart);
final PieChart pieChart = findViewById(R.id.marketCapPieChart);
float otherCurrenciesDominance = 0;
@ -580,12 +589,34 @@ public class HomeActivity extends AppCompatActivity {
PieDataSet set = new PieDataSet(entries, "Market Cap Dominance");
set.setColors(colors);
set.setSliceSpace(1);
set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
PieData data = new PieData(set);
pieChart.setData(data);
pieChart.setDrawSlicesUnderHole(true);
pieChart.setDrawSlicesUnderHole(false);
pieChart.setUsePercentValues(true);
pieChart.setTouchEnabled(false);
pieChart.setTouchEnabled(true);
pieChart.setEntryLabelColor(Color.parseColor("#FF000000"));
pieChart.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction())
{
case MotionEvent.ACTION_DOWN:
refreshLayout.setEnabled(false);
break;
case MotionEvent.ACTION_MOVE:
break;
default:
refreshLayout.setEnabled(true);
break;
}
return false;
}
});
pieChart.getDescription().setEnabled(false);
pieChart.getLegend().setEnabled(false);

View File

@ -0,0 +1,9 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="linear"
android:centerX="10%"
android:startColor="#FF1CB5E0"
android:centerColor="#FFEEEEEE"
android:endColor="#FFEEEEEE"
android:angle="-90"/>
</shape>

View File

@ -18,7 +18,8 @@
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"
android:background="@drawable/gradient_background">
android:background="@drawable/gradient_background"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"

View File

@ -5,7 +5,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_marginBottom="50dp">
android:layout_marginBottom="50dp"
android:background="@drawable/gradient_second_background">
<ViewFlipper
android:id="@+id/viewFlipperSummary"
@ -39,10 +40,7 @@
android:id="@+id/nestedScrollViewLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.nauk.coinfolio.Activities.HomeActivity"
tools:showIn="@layout/activity_currency_summary"
android:background="@color/listBackground">
tools:context="com.nauk.coinfolio.Activities.HomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -4,7 +4,7 @@
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_show_chart_black_24dp"
android:title="@string/title_watchlist" />
android:title="@string/title_history" />
<item
android:id="@+id/navigation_dashboard"

View File

@ -121,6 +121,7 @@
<string name="activity_add_amount">Amount</string>
<string name="activity_purchased_price">Purchased price</string>
<string name="title_activity_currency_details">CurrencyDetailsActivity</string>
<string name="title_history">History charts</string>
<string name="title_watchlist">Watchlist</string>
<string name="title_infos">Infos</string>
<string name="title_transactions">Transactions</string>