Graphical adjustment

- Update every progress bar color
- Smoother quick chart loading
This commit is contained in:
Tanguy Herbron 2018-04-22 14:49:04 +02:00
parent ee318266e9
commit 97dc6df33a
6 changed files with 129 additions and 47 deletions

View File

@ -185,6 +185,11 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
}
});
Drawable progressBarDrawable = ((ProgressBar) findViewById(R.id.progressBarChart)).getIndeterminateDrawable();
progressBarDrawable.mutate();
progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
progressBarDrawable.invalidateSelf();
setupActionBar();
drawTransactionList();

View File

@ -26,6 +26,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.support.v7.widget.Toolbar;
@ -292,13 +293,29 @@ public class Watchlist extends Fragment {
.setText(PlaceholderManager.getSymbolString(currency.getSymbol(), getActivity()));
((ImageView) card.findViewById(R.id.currencyIcon)).setImageBitmap(currency.getIcon());
((LineChart) card.findViewById(R.id.LineChartView)).setNoDataTextColor(currency.getChartColor());
Drawable arrowDrawable = ((ImageView) card.findViewById(R.id.detailsArrow)).getDrawable();
arrowDrawable.mutate();
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
arrowDrawable.invalidateSelf();
Drawable progressDrawable = ((ProgressBar) card.findViewById(R.id.progressBarLinechartWatchlist)).getIndeterminateDrawable();
progressDrawable.mutate();
progressDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
progressDrawable.invalidateSelf();
updateColor(card, currency);
card.findViewById(R.id.LineChartView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), CurrencyDetailsActivity.class);
intent.putExtra("currency", currency);
getActivity().getApplicationContext().startActivity(intent);
}
});
card.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
card.setOnClickListener(new View.OnClickListener() {
@Override
@ -309,37 +326,39 @@ public class Watchlist extends Fragment {
}
else
{
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.GONE);
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.VISIBLE);
extendView(view);
if (currency.getHistoryMinutes() == null) {
currency.updateHistoryMinutes(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
extendView(view);
if(currency.getHistoryMinutes() != null)
{
setupLineChart(view, currency);
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.GONE);
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
}
else
{
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.GONE);
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
view.findViewById(R.id.linearLayoutSubLayout).findViewById(R.id.detailsArrow).setVisibility(View.GONE);
}
}
});
}
else
{
extendView(view);
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.GONE);
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
}
}
}
});
card.findViewById(R.id.LineChartView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), CurrencyDetailsActivity.class);
intent.putExtra("currency", currency);
getActivity().getApplicationContext().startActivity(intent);
}
});
if(currency.getHistoryMinutes() != null)
{
setupLineChart(card, currency);
}
return card;
}
@ -400,11 +419,13 @@ public class Watchlist extends Fragment {
lineChart.getXAxis().setEnabled(false);
lineChart.setViewPortOffsets(0, 0, 0, 0);
lineChart.setData(generateData(currency));
lineChart.invalidate();
}
private void updateColor(View card, Currency currency)
{
if(currency.getDayFluctuation() > 0)
if(currency.getDayFluctuation() >= 0)
{
((TextView) card.findViewById(R.id.currencyFluctuationPercentageTextView)).setTextColor(getResources().getColor(R.color.increase));
((TextView) card.findViewById(R.id.currencyFluctuationTextView)).setTextColor(getResources().getColor(R.color.increase));

View File

@ -53,6 +53,8 @@ public class HomeLayoutGenerator {
{
View view = LayoutInflater.from(context).inflate(R.layout.cardview_currency, null, true);
((LineChart) view.findViewById(R.id.LineChartView)).setNoDataTextColor(currency.getChartColor());
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
@ -61,18 +63,34 @@ public class HomeLayoutGenerator {
if (view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE) {
collapseView(view);
} else {
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.GONE);
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.VISIBLE);
extendView(view);
if (currency.getHistoryMinutes() == null) {
currency.updateHistoryMinutes(context, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
ChartLoader chartLoader = new ChartLoader(view, currency);
chartLoader.execute();
if(currency.getHistoryMinutes() != null)
{
setupLineChart(view, currency);
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.GONE);
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
}
else
{
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.GONE);
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
view.findViewById(R.id.linearLayoutSubLayout).findViewById(R.id.detailsArrow).setVisibility(View.GONE);
}
}
});
}
else
{
extendView(view);
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.GONE);
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
}
}
}
@ -94,7 +112,7 @@ public class HomeLayoutGenerator {
return view;
}
private class ChartLoader extends AsyncTask<Void, Integer, Void>
/*private class ChartLoader extends AsyncTask<Void, Integer, Void>
{
private View view;
private Currency currency;
@ -126,7 +144,7 @@ public class HomeLayoutGenerator {
view.findViewById(R.id.LineChartView).invalidate();
}
}
*/
private static void expand(final View v) {
v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
@ -230,6 +248,11 @@ public class HomeLayoutGenerator {
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
arrowDrawable.invalidateSelf();
Drawable progressDrawable = ((ProgressBar) view.findViewById(R.id.progressBarLinechartSummary)).getIndeterminateDrawable();
progressDrawable.mutate();
progressDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
progressDrawable.invalidateSelf();
Drawable progressBarDrawable = ((ProgressBar) view.findViewById(R.id.currencyPortfolioDominance)).getProgressDrawable();
progressBarDrawable.mutate();
progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
@ -265,7 +288,7 @@ public class HomeLayoutGenerator {
private void updateColor(View view, Currency currency)
{
if(currency.getDayFluctuationPercentage() > 0)
if(currency.getDayFluctuationPercentage() >= 0)
{
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
.setTextColor(context.getResources().getColor(R.color.increase));

View File

@ -50,6 +50,7 @@
android:gravity="center">
<ProgressBar
android:id="@+id/progressBarChart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleLarge"

View File

@ -182,16 +182,26 @@
android:focusable="true">
<ProgressBar
android:id="@+id/progressLineChart"
android:id="@+id/progressBarLinechartSummary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false"
android:visibility="visible"/>
<FrameLayout
android:id="@+id/linearLayoutSubLayout"
android:layout_width="match_parent"
android:layout_height="150dp"
android:visibility="gone"/>
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:visibility="gone">
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/LineChartView"
android:layout_width="match_parent"
android:layout_height="150dp"
android:visibility="visible"/>
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/detailsArrow"
@ -202,6 +212,8 @@
</FrameLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>

View File

@ -139,12 +139,30 @@
android:layout_width="match_parent"
android:layout_height="@dimen/cardViewChartSize"
android:clickable="true"
android:focusable="true">
android:focusable="true"
android:visibility="visible">
<ProgressBar
android:id="@+id/progressBarLinechartWatchlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false"
android:visibility="visible"/>
<FrameLayout
android:id="@+id/linearLayoutSubLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:visibility="gone">
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/LineChartView"
android:layout_width="match_parent"
android:layout_height="150dp"/>
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/detailsArrow"
@ -155,6 +173,8 @@
</FrameLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>