Graphical adjustment
- Update every progress bar color - Smoother quick chart loading
This commit is contained in:
parent
ee318266e9
commit
97dc6df33a
@ -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();
|
setupActionBar();
|
||||||
|
|
||||||
drawTransactionList();
|
drawTransactionList();
|
||||||
|
@ -26,6 +26,7 @@ import android.widget.Button;
|
|||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
|
||||||
@ -292,13 +293,29 @@ public class Watchlist extends Fragment {
|
|||||||
.setText(PlaceholderManager.getSymbolString(currency.getSymbol(), getActivity()));
|
.setText(PlaceholderManager.getSymbolString(currency.getSymbol(), getActivity()));
|
||||||
((ImageView) card.findViewById(R.id.currencyIcon)).setImageBitmap(currency.getIcon());
|
((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();
|
Drawable arrowDrawable = ((ImageView) card.findViewById(R.id.detailsArrow)).getDrawable();
|
||||||
arrowDrawable.mutate();
|
arrowDrawable.mutate();
|
||||||
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
arrowDrawable.invalidateSelf();
|
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);
|
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.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
card.setOnClickListener(new View.OnClickListener() {
|
card.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -309,37 +326,39 @@ public class Watchlist extends Fragment {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.GONE);
|
||||||
|
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.VISIBLE);
|
||||||
|
extendView(view);
|
||||||
|
|
||||||
if (currency.getHistoryMinutes() == null) {
|
if (currency.getHistoryMinutes() == null) {
|
||||||
currency.updateHistoryMinutes(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
currency.updateHistoryMinutes(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
extendView(view);
|
if(currency.getHistoryMinutes() != null)
|
||||||
setupLineChart(view, currency);
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
extendView(view);
|
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;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,11 +419,13 @@ public class Watchlist extends Fragment {
|
|||||||
lineChart.getXAxis().setEnabled(false);
|
lineChart.getXAxis().setEnabled(false);
|
||||||
lineChart.setViewPortOffsets(0, 0, 0, 0);
|
lineChart.setViewPortOffsets(0, 0, 0, 0);
|
||||||
lineChart.setData(generateData(currency));
|
lineChart.setData(generateData(currency));
|
||||||
|
|
||||||
|
lineChart.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColor(View card, Currency currency)
|
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.currencyFluctuationPercentageTextView)).setTextColor(getResources().getColor(R.color.increase));
|
||||||
((TextView) card.findViewById(R.id.currencyFluctuationTextView)).setTextColor(getResources().getColor(R.color.increase));
|
((TextView) card.findViewById(R.id.currencyFluctuationTextView)).setTextColor(getResources().getColor(R.color.increase));
|
||||||
|
@ -53,6 +53,8 @@ public class HomeLayoutGenerator {
|
|||||||
{
|
{
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.cardview_currency, null, true);
|
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() {
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View view) {
|
public void onClick(final View view) {
|
||||||
@ -61,18 +63,34 @@ public class HomeLayoutGenerator {
|
|||||||
if (view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE) {
|
if (view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE) {
|
||||||
collapseView(view);
|
collapseView(view);
|
||||||
} else {
|
} else {
|
||||||
|
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.GONE);
|
||||||
|
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.VISIBLE);
|
||||||
|
extendView(view);
|
||||||
|
|
||||||
if (currency.getHistoryMinutes() == null) {
|
if (currency.getHistoryMinutes() == null) {
|
||||||
currency.updateHistoryMinutes(context, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
currency.updateHistoryMinutes(context, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currency) {
|
public void onSuccess(Currency currency) {
|
||||||
ChartLoader chartLoader = new ChartLoader(view, currency);
|
if(currency.getHistoryMinutes() != null)
|
||||||
chartLoader.execute();
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
extendView(view);
|
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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChartLoader extends AsyncTask<Void, Integer, Void>
|
/*private class ChartLoader extends AsyncTask<Void, Integer, Void>
|
||||||
{
|
{
|
||||||
private View view;
|
private View view;
|
||||||
private Currency currency;
|
private Currency currency;
|
||||||
@ -126,7 +144,7 @@ public class HomeLayoutGenerator {
|
|||||||
view.findViewById(R.id.LineChartView).invalidate();
|
view.findViewById(R.id.LineChartView).invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
private static void expand(final View v) {
|
private static void expand(final View v) {
|
||||||
v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT);
|
v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT);
|
||||||
final int targetHeight = v.getMeasuredHeight();
|
final int targetHeight = v.getMeasuredHeight();
|
||||||
@ -230,6 +248,11 @@ public class HomeLayoutGenerator {
|
|||||||
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
arrowDrawable.invalidateSelf();
|
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();
|
Drawable progressBarDrawable = ((ProgressBar) view.findViewById(R.id.currencyPortfolioDominance)).getProgressDrawable();
|
||||||
progressBarDrawable.mutate();
|
progressBarDrawable.mutate();
|
||||||
progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
@ -265,7 +288,7 @@ public class HomeLayoutGenerator {
|
|||||||
|
|
||||||
private void updateColor(View view, Currency currency)
|
private void updateColor(View view, Currency currency)
|
||||||
{
|
{
|
||||||
if(currency.getDayFluctuationPercentage() > 0)
|
if(currency.getDayFluctuationPercentage() >= 0)
|
||||||
{
|
{
|
||||||
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||||
.setTextColor(context.getResources().getColor(R.color.increase));
|
.setTextColor(context.getResources().getColor(R.color.increase));
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBarChart"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleLarge"
|
||||||
|
@ -182,23 +182,35 @@
|
|||||||
android:focusable="true">
|
android:focusable="true">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressLineChart"
|
android:id="@+id/progressBarLinechartSummary"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="150dp"
|
|
||||||
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"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/detailsArrow"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
android:layout_gravity="center"
|
||||||
android:layout_gravity="center_vertical|end"/>
|
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="match_parent"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/detailsArrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
||||||
|
android:layout_gravity="center_vertical|end"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
@ -139,19 +139,39 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/cardViewChartSize"
|
android:layout_height="@dimen/cardViewChartSize"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true">
|
android:focusable="true"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
<com.github.mikephil.charting.charts.LineChart
|
<ProgressBar
|
||||||
android:id="@+id/LineChartView"
|
android:id="@+id/progressBarLinechartWatchlist"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="150dp"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/detailsArrow"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
android:layout_gravity="center"
|
||||||
android:layout_gravity="center_vertical|end"/>
|
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="match_parent"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/detailsArrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
||||||
|
android:layout_gravity="center_vertical|end"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user