Update Marketcap Piechart layout and fix conflict with RefreshLayout
This commit is contained in:
parent
511d239f16
commit
1ca4db4b24
@ -1,5 +1,6 @@
|
|||||||
package com.nauk.coinfolio.Activities;
|
package com.nauk.coinfolio.Activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@ -25,9 +26,11 @@ import android.text.style.ForegroundColorSpan;
|
|||||||
import android.text.style.RelativeSizeSpan;
|
import android.text.style.RelativeSizeSpan;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.DragEvent;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@ -283,7 +286,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
{
|
{
|
||||||
final SpaceNavigationView spaceNavigationView = findViewById(R.id.space);
|
final SpaceNavigationView spaceNavigationView = findViewById(R.id.space);
|
||||||
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
|
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.addSpaceItem(new SpaceItem("Market Cap.", R.drawable.ic_pie_chart_black_24dp));
|
||||||
spaceNavigationView.setSpaceBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
spaceNavigationView.setSpaceBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
||||||
spaceNavigationView.setCentreButtonIcon(R.drawable.ic_view_list_white_24dp);
|
spaceNavigationView.setCentreButtonIcon(R.drawable.ic_view_list_white_24dp);
|
||||||
@ -325,6 +328,11 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
viewFlipper.setDisplayedChild(itemIndex * 2);
|
viewFlipper.setDisplayedChild(itemIndex * 2);
|
||||||
|
|
||||||
|
if(itemIndex == 1)
|
||||||
|
{
|
||||||
|
((PieChart) findViewById(R.id.marketCapPieChart)).animateX(1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -548,6 +556,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private void countCompletedMarketCapRequest()
|
private void countCompletedMarketCapRequest()
|
||||||
{
|
{
|
||||||
marketCapCounter++;
|
marketCapCounter++;
|
||||||
@ -563,7 +572,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
ArrayList<Integer> colors = new ArrayList<>();
|
ArrayList<Integer> colors = new ArrayList<>();
|
||||||
|
|
||||||
PieChart pieChart = findViewById(R.id.marketCapPieChart);
|
final PieChart pieChart = findViewById(R.id.marketCapPieChart);
|
||||||
|
|
||||||
float otherCurrenciesDominance = 0;
|
float otherCurrenciesDominance = 0;
|
||||||
|
|
||||||
@ -580,12 +589,34 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
PieDataSet set = new PieDataSet(entries, "Market Cap Dominance");
|
PieDataSet set = new PieDataSet(entries, "Market Cap Dominance");
|
||||||
set.setColors(colors);
|
set.setColors(colors);
|
||||||
set.setSliceSpace(1);
|
set.setSliceSpace(1);
|
||||||
|
set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
|
||||||
|
set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
|
||||||
PieData data = new PieData(set);
|
PieData data = new PieData(set);
|
||||||
pieChart.setData(data);
|
pieChart.setData(data);
|
||||||
|
|
||||||
pieChart.setDrawSlicesUnderHole(true);
|
pieChart.setDrawSlicesUnderHole(false);
|
||||||
pieChart.setUsePercentValues(true);
|
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.getDescription().setEnabled(false);
|
||||||
pieChart.getLegend().setEnabled(false);
|
pieChart.getLegend().setEnabled(false);
|
||||||
|
9
app/src/main/res/drawable/gradient_second_background.xml
Normal file
9
app/src/main/res/drawable/gradient_second_background.xml
Normal 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>
|
@ -18,7 +18,8 @@
|
|||||||
android:layout_height="@dimen/app_bar_height"
|
android:layout_height="@dimen/app_bar_height"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay"
|
android:theme="@style/AppTheme.AppBarOverlay"
|
||||||
android:background="@drawable/gradient_background">
|
android:background="@drawable/gradient_background"
|
||||||
|
app:elevation="0dp">
|
||||||
|
|
||||||
<android.support.design.widget.CollapsingToolbarLayout
|
<android.support.design.widget.CollapsingToolbarLayout
|
||||||
android:id="@+id/toolbar_layout"
|
android:id="@+id/toolbar_layout"
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
android:layout_marginBottom="50dp">
|
android:layout_marginBottom="50dp"
|
||||||
|
android:background="@drawable/gradient_second_background">
|
||||||
|
|
||||||
<ViewFlipper
|
<ViewFlipper
|
||||||
android:id="@+id/viewFlipperSummary"
|
android:id="@+id/viewFlipperSummary"
|
||||||
@ -39,10 +40,7 @@
|
|||||||
android:id="@+id/nestedScrollViewLayout"
|
android:id="@+id/nestedScrollViewLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.nauk.coinfolio.Activities.HomeActivity"
|
tools:context="com.nauk.coinfolio.Activities.HomeActivity">
|
||||||
tools:showIn="@layout/activity_currency_summary"
|
|
||||||
android:background="@color/listBackground">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/navigation_home"
|
android:id="@+id/navigation_home"
|
||||||
android:icon="@drawable/ic_show_chart_black_24dp"
|
android:icon="@drawable/ic_show_chart_black_24dp"
|
||||||
android:title="@string/title_watchlist" />
|
android:title="@string/title_history" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/navigation_dashboard"
|
android:id="@+id/navigation_dashboard"
|
||||||
|
@ -121,6 +121,7 @@
|
|||||||
<string name="activity_add_amount">Amount</string>
|
<string name="activity_add_amount">Amount</string>
|
||||||
<string name="activity_purchased_price">Purchased price</string>
|
<string name="activity_purchased_price">Purchased price</string>
|
||||||
<string name="title_activity_currency_details">CurrencyDetailsActivity</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_watchlist">Watchlist</string>
|
||||||
<string name="title_infos">Infos</string>
|
<string name="title_infos">Infos</string>
|
||||||
<string name="title_transactions">Transactions</string>
|
<string name="title_transactions">Transactions</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user