Several fixes/improvements
- Add Watchlist charts - Add Detail Activity for Watchlist coins - Add padding for Watchlist - Remove superfluous 0s when displaying balance/price - Fix Summary Detail Button not changing form - Fix app crash when Marketcap fragment is not fully loaded - Fix separate Fragment update obligations - Fix 0 coin in Detail activity when coming from Watchlist
This commit is contained in:
parent
9973c4bf37
commit
f0c4062871
@ -202,8 +202,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
TradeUpdater updater = new TradeUpdater();
|
TradeUpdater updater = new TradeUpdater();
|
||||||
updater.execute();
|
updater.execute();
|
||||||
|
|
||||||
Log.d("coinfolio", "Details loaded for " + currency.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInfoTab()
|
private void updateInfoTab()
|
||||||
@ -212,8 +210,15 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupActionBar()
|
private void setupActionBar()
|
||||||
|
{
|
||||||
|
if(currency.getBalance() == 0)
|
||||||
|
{
|
||||||
|
setTitle(" " + currency.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
setTitle(" " + currency.getName() + " | " + currency.getBalance());
|
setTitle(" " + currency.getName() + " | " + currency.getBalance());
|
||||||
|
}
|
||||||
|
|
||||||
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
|
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
|
||||||
ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO);
|
ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO);
|
||||||
@ -584,7 +589,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
private String getDate(long timeStamp){
|
private String getDate(long timeStamp){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
//SimpleDateFormat sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy");
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy", Locale.getDefault());
|
SimpleDateFormat sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy", Locale.getDefault());
|
||||||
Date netDate = (new Date(timeStamp));
|
Date netDate = (new Date(timeStamp));
|
||||||
return sdf.format(netDate);
|
return sdf.format(netDate);
|
||||||
@ -833,7 +837,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
deleteLayout.setOnClickListener(new View.OnClickListener() {
|
deleteLayout.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
preferencesManager.setMustUpdate(true);
|
preferencesManager.setMustUpdateSummary(true);
|
||||||
databaseManager.deleteTransactionFromId(Integer.parseInt(view.getTag().toString()));
|
databaseManager.deleteTransactionFromId(Integer.parseInt(view.getTag().toString()));
|
||||||
drawTransactionList();
|
drawTransactionList();
|
||||||
hasBeenModified = true;
|
hasBeenModified = true;
|
||||||
|
@ -7,8 +7,6 @@ import android.os.Looper;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@ -100,7 +98,7 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
|
|||||||
DatabaseManager databaseManager = new DatabaseManager(getApplicationContext());
|
DatabaseManager databaseManager = new DatabaseManager(getApplicationContext());
|
||||||
|
|
||||||
databaseManager.addCurrencyToWatchlist(selectedCurrency);
|
databaseManager.addCurrencyToWatchlist(selectedCurrency);
|
||||||
preferencesManager.setMustUpdate(true);
|
preferencesManager.setMustUpdateWatchlist(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -93,12 +93,14 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
switch (item.getItemId())
|
switch (item.getItemId())
|
||||||
{
|
{
|
||||||
case R.id.navigation_watchlist:
|
case R.id.navigation_watchlist:
|
||||||
|
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(false, true);
|
||||||
viewPager.setCurrentItem(0);
|
viewPager.setCurrentItem(0);
|
||||||
break;
|
break;
|
||||||
case R.id.navigation_currencies_list:
|
case R.id.navigation_currencies_list:
|
||||||
viewPager.setCurrentItem(1);
|
viewPager.setCurrentItem(1);
|
||||||
break;
|
break;
|
||||||
case R.id.navigation_market_cap:
|
case R.id.navigation_market_cap:
|
||||||
|
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(false, true);
|
||||||
viewPager.setCurrentItem(2);
|
viewPager.setCurrentItem(2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -125,10 +127,16 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
final PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager(), 3);
|
final PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager(), 3);
|
||||||
|
|
||||||
viewPager.setAdapter(adapter);
|
viewPager.setAdapter(adapter);
|
||||||
|
viewPager.setOffscreenPageLimit(2);
|
||||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
bottomNavigationView.getMenu().getItem(position).setChecked(true);
|
bottomNavigationView.getMenu().getItem(position).setChecked(true);
|
||||||
|
|
||||||
|
if(position % 2 == 0)
|
||||||
|
{
|
||||||
|
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,11 +173,8 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
//overridePendingTransition(R.anim.activity_enter, R.anim.activity_exit);
|
//overridePendingTransition(R.anim.activity_enter, R.anim.activity_exit);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void switchMainView()
|
private void switchMainView()
|
||||||
{
|
{
|
||||||
Log.d("coinfolio", "Should");
|
Log.d("coinfolio", "Should");
|
||||||
|
@ -2,8 +2,10 @@ package com.nauk.coinfolio.Activities.HomeActivityFragments;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.support.design.widget.AppBarLayout;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -11,6 +13,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.github.mikephil.charting.charts.PieChart;
|
import com.github.mikephil.charting.charts.PieChart;
|
||||||
@ -53,7 +56,7 @@ public class MarketCapitalization extends Fragment {
|
|||||||
setupDominantCurrenciesColors();
|
setupDominantCurrenciesColors();
|
||||||
|
|
||||||
marketCapManager = new MarketCapManager(getContext());
|
marketCapManager = new MarketCapManager(getContext());
|
||||||
refreshLayout = view.findViewById(R.id.swiperefresh);
|
refreshLayout = view.findViewById(R.id.swiperefreshmarketcap);
|
||||||
|
|
||||||
refreshLayout.setOnRefreshListener(
|
refreshLayout.setOnRefreshListener(
|
||||||
new SwipeRefreshLayout.OnRefreshListener() {
|
new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@ -72,6 +75,12 @@ public class MarketCapitalization extends Fragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
private void setupDominantCurrenciesColors()
|
private void setupDominantCurrenciesColors()
|
||||||
{
|
{
|
||||||
dominantCurrenciesColors = new HashMap<>();
|
dominantCurrenciesColors = new HashMap<>();
|
||||||
@ -196,11 +205,13 @@ public class MarketCapitalization extends Fragment {
|
|||||||
{
|
{
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
refreshLayout.setEnabled(false);
|
refreshLayout.setEnabled(false);
|
||||||
|
getActivity().findViewById(R.id.viewPager).setEnabled(false);
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
refreshLayout.setEnabled(true);
|
refreshLayout.setEnabled(true);
|
||||||
|
getActivity().findViewById(R.id.viewPager).setEnabled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -210,8 +221,7 @@ public class MarketCapitalization extends Fragment {
|
|||||||
pieChart.getDescription().setEnabled(false);
|
pieChart.getDescription().setEnabled(false);
|
||||||
pieChart.getLegend().setEnabled(false);
|
pieChart.getLegend().setEnabled(false);
|
||||||
pieChart.setCenterText(generateCenterSpannableText());
|
pieChart.setCenterText(generateCenterSpannableText());
|
||||||
pieChart.invalidate(); // refresh
|
pieChart.invalidate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpannableString generateCenterSpannableText() {
|
private SpannableString generateCenterSpannableText() {
|
||||||
@ -228,8 +238,8 @@ public class MarketCapitalization extends Fragment {
|
|||||||
symbols.setGroupingSeparator(' ');
|
symbols.setGroupingSeparator(' ');
|
||||||
formatter.setDecimalFormatSymbols(symbols);
|
formatter.setDecimalFormatSymbols(symbols);
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.marketCapTextView)).setText(getResources().getString(R.string.market_cap_textview, formatter.format(marketCapManager.getMarketCap())));
|
((TextView) view.findViewById(R.id.marketCapTextView)).setText(getActivity().getResources().getString(R.string.market_cap_textview, formatter.format(marketCapManager.getMarketCap())));
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.dayVolumeTotalMarketCap)).setText(getResources().getString(R.string.volume_market_cap_textview, formatter.format(marketCapManager.getDayVolume())));
|
((TextView) view.findViewById(R.id.dayVolumeTotalMarketCap)).setText(getActivity().getResources().getString(R.string.volume_market_cap_textview, formatter.format(marketCapManager.getDayVolume())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.support.design.widget.CollapsingToolbarLayout;
|
import android.support.design.widget.CollapsingToolbarLayout;
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
@ -19,6 +18,7 @@ import android.view.Gravity;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@ -27,7 +27,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.nauk.coinfolio.Activities.CurrencySelectionActivity;
|
import com.nauk.coinfolio.Activities.CurrencySelectionActivity;
|
||||||
import com.nauk.coinfolio.Activities.HomeActivity;
|
import com.nauk.coinfolio.Activities.HomeActivity;
|
||||||
import com.nauk.coinfolio.Activities.SettingsActivity;
|
|
||||||
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||||
@ -45,7 +44,6 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Summary extends Fragment {
|
public class Summary extends Fragment {
|
||||||
|
|
||||||
private boolean isDetailed;
|
|
||||||
private LinearLayout currencyLayout;
|
private LinearLayout currencyLayout;
|
||||||
private PreferencesManager preferencesManager;
|
private PreferencesManager preferencesManager;
|
||||||
private BalanceManager balanceManager;
|
private BalanceManager balanceManager;
|
||||||
@ -76,12 +74,10 @@ public class Summary extends Fragment {
|
|||||||
preferencesManager = new PreferencesManager(getActivity());
|
preferencesManager = new PreferencesManager(getActivity());
|
||||||
balanceManager = new BalanceManager(getActivity());
|
balanceManager = new BalanceManager(getActivity());
|
||||||
layoutGenerator = new HomeLayoutGenerator(getActivity());
|
layoutGenerator = new HomeLayoutGenerator(getActivity());
|
||||||
refreshLayout = view.findViewById(R.id.swiperefresh);
|
refreshLayout = view.findViewById(R.id.swiperefreshsummary);
|
||||||
toolbarSubtitle = getActivity().findViewById(R.id.toolbarSubtitle);
|
toolbarSubtitle = getActivity().findViewById(R.id.toolbarSubtitle);
|
||||||
toolbarLayout = getActivity().findViewById(R.id.toolbar_layout);
|
toolbarLayout = getActivity().findViewById(R.id.toolbar_layout);
|
||||||
|
|
||||||
isDetailed = preferencesManager.getDetailOption();
|
|
||||||
|
|
||||||
totalValue = 0;
|
totalValue = 0;
|
||||||
totalFluctuation = 0;
|
totalFluctuation = 0;
|
||||||
lastTimestamp = 0;
|
lastTimestamp = 0;
|
||||||
@ -133,6 +129,7 @@ public class Summary extends Fragment {
|
|||||||
detailsButton.setOnClickListener(new View.OnClickListener() {
|
detailsButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
preferencesManager.setDetailOption(!preferencesManager.getDetailOption());
|
||||||
updateViewButtonIcon();
|
updateViewButtonIcon();
|
||||||
switchView();
|
switchView();
|
||||||
}
|
}
|
||||||
@ -140,18 +137,45 @@ public class Summary extends Fragment {
|
|||||||
|
|
||||||
updateTitle();
|
updateTitle();
|
||||||
|
|
||||||
generateSplashScreen();
|
|
||||||
|
|
||||||
updateAll(true);
|
updateAll(true);
|
||||||
|
|
||||||
|
generateSplashScreen();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generateSplashScreen()
|
||||||
|
{
|
||||||
|
LinearLayout loadingLayout = new LinearLayout(getActivity());
|
||||||
|
|
||||||
|
loadingLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
loadingLayout.setGravity(Gravity.CENTER);
|
||||||
|
loadingLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|
||||||
|
loadingDialog = new Dialog(getActivity(), android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
||||||
|
|
||||||
|
TextView txtView = new TextView(getActivity());
|
||||||
|
txtView.setText("Loading data...");
|
||||||
|
txtView.setTextSize(20);
|
||||||
|
txtView.setGravity(Gravity.CENTER);
|
||||||
|
txtView.setTextColor(this.getResources().getColor(R.color.cardview_light_background));
|
||||||
|
|
||||||
|
ProgressBar progressBar = new ProgressBar(getActivity());
|
||||||
|
progressBar.setIndeterminate(true);
|
||||||
|
|
||||||
|
loadingLayout.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark));
|
||||||
|
loadingLayout.addView(txtView);
|
||||||
|
loadingLayout.addView(progressBar);
|
||||||
|
|
||||||
|
loadingDialog.setContentView(loadingLayout);
|
||||||
|
loadingDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
updateAll(preferencesManager.mustUpdate());
|
updateAll(preferencesManager.mustUpdateSummary());
|
||||||
|
|
||||||
updateViewButtonIcon();
|
updateViewButtonIcon();
|
||||||
|
|
||||||
@ -207,45 +231,14 @@ public class Summary extends Fragment {
|
|||||||
totalFluctuation = 0;
|
totalFluctuation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateSplashScreen()
|
|
||||||
{
|
|
||||||
LinearLayout loadingLayout = new LinearLayout(getActivity());
|
|
||||||
|
|
||||||
loadingLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
||||||
loadingLayout.setGravity(Gravity.CENTER);
|
|
||||||
loadingLayout.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
|
|
||||||
loadingDialog = new Dialog(getActivity(), android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
|
||||||
|
|
||||||
TextView txtView = new TextView(getActivity());
|
|
||||||
txtView.setText("Loading data...");
|
|
||||||
txtView.setTextSize(20);
|
|
||||||
txtView.setGravity(Gravity.CENTER);
|
|
||||||
txtView.setTextColor(this.getResources().getColor(R.color.cardview_light_background));
|
|
||||||
|
|
||||||
ProgressBar progressBar = new ProgressBar(getActivity());
|
|
||||||
progressBar.setIndeterminate(true);
|
|
||||||
|
|
||||||
loadingLayout.setBackgroundColor(this.getResources().getColor(R.color.colorPrimaryDark));
|
|
||||||
loadingLayout.addView(txtView);
|
|
||||||
loadingLayout.addView(progressBar);
|
|
||||||
|
|
||||||
loadingDialog.setContentView(loadingLayout);
|
|
||||||
loadingDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void switchView()
|
private void switchView()
|
||||||
{
|
{
|
||||||
if(isDetailed)
|
if(preferencesManager.getDetailOption())
|
||||||
{
|
{
|
||||||
isDetailed = false;
|
|
||||||
|
|
||||||
adaptView();
|
adaptView();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isDetailed = true;
|
|
||||||
|
|
||||||
adaptView();
|
adaptView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,7 +253,7 @@ public class Summary extends Fragment {
|
|||||||
|
|
||||||
if(!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > 0.001 || currency.getHistoryMinutes() == null))
|
if(!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > 0.001 || currency.getHistoryMinutes() == null))
|
||||||
{
|
{
|
||||||
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, isDetailed, totalValue, preferencesManager.isBalanceHidden()));
|
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, preferencesManager.getDetailOption(), totalValue, preferencesManager.isBalanceHidden()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,9 +446,11 @@ public class Summary extends Fragment {
|
|||||||
Currency currency = balanceManager.getTotalBalance().get(i);
|
Currency currency = balanceManager.getTotalBalance().get(i);
|
||||||
|
|
||||||
if(!currency.getSymbol().equals("USD") && (currency.getBalance() * currency.getValue()) > 0.001) {
|
if(!currency.getSymbol().equals("USD") && (currency.getBalance() * currency.getValue()) > 0.001) {
|
||||||
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, isDetailed, totalValue, preferencesManager.isBalanceHidden()));
|
currencyLayout.addView(layoutGenerator.getInfoLayout(currency, preferencesManager.getDetailOption(), totalValue, preferencesManager.isBalanceHidden()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adaptView();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -502,7 +497,6 @@ public class Summary extends Fragment {
|
|||||||
refreshLayout.setRefreshing(false);
|
refreshLayout.setRefreshing(false);
|
||||||
refreshCurrencyList();
|
refreshCurrencyList();
|
||||||
handler.removeCallbacks(updateRunnable);
|
handler.removeCallbacks(updateRunnable);
|
||||||
adaptView();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,12 +530,10 @@ public class Summary extends Fragment {
|
|||||||
if(preferencesManager.getDetailOption())
|
if(preferencesManager.getDetailOption())
|
||||||
{
|
{
|
||||||
imgButton.setBackground(this.getResources().getDrawable(R.drawable.ic_unfold_less_black_24dp));
|
imgButton.setBackground(this.getResources().getDrawable(R.drawable.ic_unfold_less_black_24dp));
|
||||||
preferencesManager.setDetailOption(false);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
imgButton.setBackground(this.getResources().getDrawable(R.drawable.ic_details_black_24dp));
|
imgButton.setBackground(this.getResources().getDrawable(R.drawable.ic_details_black_24dp));
|
||||||
preferencesManager.setDetailOption(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,24 +3,40 @@ package com.nauk.coinfolio.Activities.HomeActivityFragments;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.support.design.widget.AppBarLayout;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
|
import android.support.v7.graphics.Palette;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.Transformation;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
|
import com.github.mikephil.charting.data.Entry;
|
||||||
|
import com.github.mikephil.charting.data.LineData;
|
||||||
|
import com.github.mikephil.charting.data.LineDataSet;
|
||||||
|
import com.nauk.coinfolio.Activities.CurrencyDetailsActivity;
|
||||||
import com.nauk.coinfolio.Activities.CurrencySelectionActivity;
|
import com.nauk.coinfolio.Activities.CurrencySelectionActivity;
|
||||||
import com.nauk.coinfolio.Activities.HomeActivity;
|
import com.nauk.coinfolio.Activities.HomeActivity;
|
||||||
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||||
|
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
|
||||||
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDetailsList;
|
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDetailsList;
|
||||||
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||||
import com.nauk.coinfolio.DataManagers.WatchlistManager;
|
import com.nauk.coinfolio.DataManagers.WatchlistManager;
|
||||||
@ -32,6 +48,8 @@ import org.json.JSONObject;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static java.lang.Math.abs;
|
import static java.lang.Math.abs;
|
||||||
@ -55,7 +73,7 @@ public class Watchlist extends Fragment {
|
|||||||
{
|
{
|
||||||
view = inflater.inflate(R.layout.fragment_watchlist_homeactivity, container, false);
|
view = inflater.inflate(R.layout.fragment_watchlist_homeactivity, container, false);
|
||||||
|
|
||||||
refreshLayout = view.findViewById(R.id.swiperefresh);
|
refreshLayout = view.findViewById(R.id.swiperefreshwatchlist);
|
||||||
currencyDetailsList = new CurrencyDetailsList(getContext());
|
currencyDetailsList = new CurrencyDetailsList(getContext());
|
||||||
preferencesManager = new PreferencesManager(getContext());
|
preferencesManager = new PreferencesManager(getContext());
|
||||||
|
|
||||||
@ -85,12 +103,78 @@ public class Watchlist extends Fragment {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void collapseView(View view)
|
||||||
|
{
|
||||||
|
collapse(view.findViewById(R.id.collapsableLayout));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void extendView(View view)
|
||||||
|
{
|
||||||
|
expand(view.findViewById(R.id.collapsableLayout));
|
||||||
|
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();
|
||||||
|
|
||||||
|
// Older versions of android (pre API 21) cancel animations for views with a height of 0.
|
||||||
|
v.getLayoutParams().height = 1;
|
||||||
|
v.setVisibility(View.VISIBLE);
|
||||||
|
Animation a = new Animation()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
|
v.getLayoutParams().height = interpolatedTime == 1
|
||||||
|
? CardView.LayoutParams.WRAP_CONTENT
|
||||||
|
: (int)(targetHeight * interpolatedTime);
|
||||||
|
v.requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean willChangeBounds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1dp/ms
|
||||||
|
a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density));
|
||||||
|
v.startAnimation(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void collapse(final View v) {
|
||||||
|
final int initialHeight = v.getMeasuredHeight();
|
||||||
|
|
||||||
|
Animation a = new Animation()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||||
|
if(interpolatedTime == 1){
|
||||||
|
v.setVisibility(View.GONE);
|
||||||
|
}else{
|
||||||
|
v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
|
||||||
|
v.requestLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean willChangeBounds() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1dp/ms
|
||||||
|
a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
|
||||||
|
v.startAnimation(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
updateWatchlist(preferencesManager.mustUpdate());
|
updateWatchlist(preferencesManager.mustUpdateWatchlist());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWatchlist(boolean mustUpdate)
|
private void updateWatchlist(boolean mustUpdate)
|
||||||
@ -131,7 +215,7 @@ public class Watchlist extends Fragment {
|
|||||||
{
|
{
|
||||||
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).removeAllViews();
|
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).removeAllViews();
|
||||||
|
|
||||||
for(Currency currency : watchlistManager.getWatchlist())
|
for(final Currency currency : watchlistManager.getWatchlist())
|
||||||
{
|
{
|
||||||
View card = LayoutInflater.from(getContext()).inflate(R.layout.cardview_watchlist, null);
|
View card = LayoutInflater.from(getContext()).inflate(R.layout.cardview_watchlist, null);
|
||||||
|
|
||||||
@ -142,16 +226,42 @@ public class Watchlist extends Fragment {
|
|||||||
((ImageView) card.findViewById(R.id.currencyIcon)).setImageBitmap(currency.getIcon());
|
((ImageView) card.findViewById(R.id.currencyIcon)).setImageBitmap(currency.getIcon());
|
||||||
((TextView) card.findViewById(R.id.currencyValueTextView)).setText(getResources().getString(R.string.currencyDollarPlaceholder, numberConformer(currency.getValue())));
|
((TextView) card.findViewById(R.id.currencyValueTextView)).setText(getResources().getString(R.string.currencyDollarPlaceholder, numberConformer(currency.getValue())));
|
||||||
|
|
||||||
|
Drawable arrowDrawable = ((ImageView) card.findViewById(R.id.detailsArrow)).getDrawable();
|
||||||
|
arrowDrawable.mutate();
|
||||||
|
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
|
arrowDrawable.invalidateSelf();
|
||||||
|
|
||||||
updateColor(card, currency);
|
updateColor(card, currency);
|
||||||
|
|
||||||
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
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Log.d("coinfolio", "Clicked !");
|
if(view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE)
|
||||||
|
{
|
||||||
|
collapseView(view);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extendView(view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).addView(card, 0);
|
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).addView(card, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +271,65 @@ public class Watchlist extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private LineData generateData(Currency currency)
|
||||||
|
{
|
||||||
|
LineDataSet dataSet;
|
||||||
|
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
||||||
|
ArrayList<Entry> values = new ArrayList<>();
|
||||||
|
|
||||||
|
Log.d("coinfolio", "Generating data for " + currency.getSymbol());
|
||||||
|
for(int i = 0; i < dataChartList.size(); i+=10)
|
||||||
|
{
|
||||||
|
values.add(new Entry(i, (float) dataChartList.get(i).getOpen()));
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSet = new LineDataSet(values, "History");
|
||||||
|
dataSet.setDrawIcons(false);
|
||||||
|
dataSet.setColor(currency.getChartColor());
|
||||||
|
dataSet.setLineWidth(1);
|
||||||
|
dataSet.setDrawFilled(true);
|
||||||
|
dataSet.setFillColor(getColorWithAplha(currency.getChartColor(), 0.5f));
|
||||||
|
dataSet.setFormLineWidth(1);
|
||||||
|
dataSet.setFormSize(15);
|
||||||
|
dataSet.setDrawCircles(false);
|
||||||
|
dataSet.setDrawValues(false);
|
||||||
|
dataSet.setHighlightEnabled(false);
|
||||||
|
|
||||||
|
return new LineData(dataSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getColorWithAplha(int color, float ratio)
|
||||||
|
{
|
||||||
|
int transColor;
|
||||||
|
int alpha = Math.round(Color.alpha(color) * ratio);
|
||||||
|
int r = Color.red(color);
|
||||||
|
int g = Color.green(color);
|
||||||
|
int b = Color.blue(color);
|
||||||
|
|
||||||
|
transColor = Color.argb(alpha, r, g, b);
|
||||||
|
|
||||||
|
return transColor ;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupLineChart(View view, final Currency currency)
|
||||||
|
{
|
||||||
|
LineChart lineChart = view.findViewById(R.id.LineChartView);
|
||||||
|
|
||||||
|
lineChart.setDrawGridBackground(false);
|
||||||
|
lineChart.setDrawBorders(false);
|
||||||
|
lineChart.setDrawMarkers(false);
|
||||||
|
lineChart.setDoubleTapToZoomEnabled(false);
|
||||||
|
lineChart.setPinchZoom(false);
|
||||||
|
lineChart.setScaleEnabled(false);
|
||||||
|
lineChart.setDragEnabled(false);
|
||||||
|
lineChart.getDescription().setEnabled(false);
|
||||||
|
lineChart.getAxisLeft().setEnabled(false);
|
||||||
|
lineChart.getAxisRight().setEnabled(false);
|
||||||
|
lineChart.getLegend().setEnabled(false);
|
||||||
|
lineChart.getXAxis().setEnabled(false);
|
||||||
|
lineChart.setViewPortOffsets(0, 0, 0, 0);
|
||||||
|
lineChart.setData(generateData(currency));
|
||||||
|
}
|
||||||
|
|
||||||
private void updateColor(View card, Currency currency)
|
private void updateColor(View card, Currency currency)
|
||||||
{
|
{
|
||||||
@ -215,6 +384,20 @@ public class Watchlist extends Fragment {
|
|||||||
callBack.onSuccess(result);
|
callBack.onSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateChartColor(Currency currency)
|
||||||
|
{
|
||||||
|
if(currency.getIcon() != null)
|
||||||
|
{
|
||||||
|
Palette.Builder builder = Palette.from(currency.getIcon());
|
||||||
|
|
||||||
|
currency.setChartColor(builder.generate().getDominantColor(0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currency.setChartColor(12369084);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class WatchlistUpdater extends AsyncTask<Void, Integer, Void>
|
private class WatchlistUpdater extends AsyncTask<Void, Integer, Void>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -225,7 +408,7 @@ public class Watchlist extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
for(Currency currency : watchlistManager.getWatchlist())
|
for(final Currency currency : watchlistManager.getWatchlist())
|
||||||
{
|
{
|
||||||
currency.updateHistoryMinutes(getActivity(), new Currency.CurrencyCallBack() {
|
currency.updateHistoryMinutes(getActivity(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
@ -236,6 +419,7 @@ public class Watchlist extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(Bitmap bitmapIcon) {
|
public void onSuccess(Bitmap bitmapIcon) {
|
||||||
sucessCurrency.setIcon(bitmapIcon);
|
sucessCurrency.setIcon(bitmapIcon);
|
||||||
|
updateChartColor(currency);
|
||||||
countWatchlist();
|
countWatchlist();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package com.nauk.coinfolio.Activities;
|
package com.nauk.coinfolio.Activities;
|
||||||
|
|
||||||
import android.app.DatePickerDialog;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -21,7 +18,6 @@ import com.nauk.coinfolio.R;
|
|||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class RecordTransactionActivity extends AppCompatActivity {
|
public class RecordTransactionActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -76,7 +72,7 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
databaseManager.addCurrencyToManualCurrency(symbol, Double.parseDouble(amountTxtView.getText().toString()), calendar.getTime(), purchasedPrice.getText().toString());
|
databaseManager.addCurrencyToManualCurrency(symbol, Double.parseDouble(amountTxtView.getText().toString()), calendar.getTime(), purchasedPrice.getText().toString());
|
||||||
preferenceManager.setMustUpdate(true);
|
preferenceManager.setMustUpdateSummary(true);
|
||||||
Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
|
Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -276,7 +276,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
|
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
|
||||||
editor.putBoolean("mustUpdate", true);
|
editor.putBoolean("mustUpdateSummary", true);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
return isChecked;
|
return isChecked;
|
||||||
@ -292,7 +292,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
|
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
|
||||||
editor.putBoolean("mustUpdate", true);
|
editor.putBoolean("mustUpdateSummary", true);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
return isChecked;
|
return isChecked;
|
||||||
|
@ -83,20 +83,39 @@ public class PreferencesManager {
|
|||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMustUpdate(boolean mustUpdate)
|
public void setMustUpdateWatchlist(boolean mustUpdate)
|
||||||
{
|
{
|
||||||
SharedPreferences.Editor editor = settingPreferences.edit();
|
SharedPreferences.Editor editor = settingPreferences.edit();
|
||||||
editor.putBoolean("mustUpdate", mustUpdate);
|
editor.putBoolean("mustUpdateWatchlist", mustUpdate);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mustUpdate()
|
public boolean mustUpdateWatchlist()
|
||||||
{
|
{
|
||||||
boolean mustUpdate = settingPreferences.getBoolean("mustUpdate", false);
|
boolean mustUpdate = settingPreferences.getBoolean("mustUpdateWatchlist", false);
|
||||||
|
|
||||||
if(mustUpdate)
|
if(mustUpdate)
|
||||||
{
|
{
|
||||||
setMustUpdate(false);
|
setMustUpdateWatchlist(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mustUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMustUpdateSummary(boolean mustUpdate)
|
||||||
|
{
|
||||||
|
SharedPreferences.Editor editor = settingPreferences.edit();
|
||||||
|
editor.putBoolean("mustUpdateSummary", mustUpdate);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mustUpdateSummary()
|
||||||
|
{
|
||||||
|
boolean mustUpdate = settingPreferences.getBoolean("mustUpdateSummary", false);
|
||||||
|
|
||||||
|
if(mustUpdate)
|
||||||
|
{
|
||||||
|
setMustUpdateSummary(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mustUpdate;
|
return mustUpdate;
|
||||||
|
@ -7,6 +7,7 @@ import android.graphics.PorterDuff;
|
|||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
@ -64,7 +65,19 @@ public class HomeLayoutGenerator {
|
|||||||
|
|
||||||
updateCardViewInfos(view, currency, totalValue, isBalanceHidden);
|
updateCardViewInfos(view, currency, totalValue, isBalanceHidden);
|
||||||
|
|
||||||
|
view.findViewById(R.id.LineChartView).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class);
|
||||||
|
intent.putExtra("currency", currency);
|
||||||
|
context.getApplicationContext().startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(currency.getHistoryMinutes() != null)
|
||||||
|
{
|
||||||
setupLineChart(view, currency);
|
setupLineChart(view, currency);
|
||||||
|
}
|
||||||
|
|
||||||
if(isExtended)
|
if(isExtended)
|
||||||
{
|
{
|
||||||
@ -152,15 +165,6 @@ public class HomeLayoutGenerator {
|
|||||||
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.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class);
|
|
||||||
intent.putExtra("currency", currency);
|
|
||||||
context.getApplicationContext().startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCardViewInfos(View view, Currency currency, float totalValue, boolean isBalanceHidden)
|
private void updateCardViewInfos(View view, Currency currency, float totalValue, boolean isBalanceHidden)
|
||||||
@ -249,6 +253,7 @@ public class HomeLayoutGenerator {
|
|||||||
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
||||||
ArrayList<Entry> values = new ArrayList<>();
|
ArrayList<Entry> values = new ArrayList<>();
|
||||||
|
|
||||||
|
Log.d("coinfolio", "Generating data for " + currency.getSymbol());
|
||||||
for(int i = 0; i < dataChartList.size(); i+=10)
|
for(int i = 0; i < dataChartList.size(); i+=10)
|
||||||
{
|
{
|
||||||
values.add(new Entry(i, (float) dataChartList.get(i).getOpen()));
|
values.add(new Entry(i, (float) dataChartList.get(i).getOpen()));
|
||||||
@ -288,11 +293,11 @@ public class HomeLayoutGenerator {
|
|||||||
|
|
||||||
if(abs(number) > 1)
|
if(abs(number) > 1)
|
||||||
{
|
{
|
||||||
str = String.format( Locale.UK, "%.2f", number);
|
str = String.format( Locale.UK, "%.2f", number).replaceAll("\\.?0*$", "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
str = String.format( Locale.UK, "%.4f", number);
|
str = String.format( Locale.UK, "%.4f", number).replaceAll("\\.?0*$", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.nauk.coinfolio;
|
package com.nauk.coinfolio;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||||
|
@ -105,12 +105,18 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/collapsableLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/separationLayout"
|
android:id="@+id/separationLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="5dp"
|
android:layout_margin="5dp">
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -120,7 +126,7 @@
|
|||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="@dimen/separationLineSize"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
@ -133,41 +139,26 @@
|
|||||||
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="gone">
|
|
||||||
|
|
||||||
<!--<com.db.chart.view.LineChartView
|
|
||||||
android:id="@+id/LineChartView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/cardViewChartSize"
|
|
||||||
android:visibility="gone" />-->
|
|
||||||
|
|
||||||
<com.github.mikephil.charting.charts.LineChart
|
<com.github.mikephil.charting.charts.LineChart
|
||||||
android:id="@+id/LineChartView"
|
android:id="@+id/LineChartView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="150dp"
|
android:layout_height="150dp"/>
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/errorTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/cardViewChartSize"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="Error"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/detailsArrow"
|
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:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_gravity="center_vertical|end"/>
|
android:layout_gravity="center_vertical|end"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/swiperefresh"
|
android:id="@+id/swiperefreshmarketcap"
|
||||||
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"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/swiperefresh"
|
android:id="@+id/swiperefreshsummary"
|
||||||
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"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/swiperefresh"
|
android:id="@+id/swiperefreshwatchlist"
|
||||||
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"
|
||||||
@ -11,7 +11,8 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="10dp">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user