Updates
- Remove HomeLayoutGenerator class - Add CurrencyCardview which overrides Cardview - Fix trading and general balance syncing for HitBTC
This commit is contained in:
parent
d2aaec536d
commit
84a8c98dd4
@ -31,9 +31,9 @@ import com.nauk.moodl.Activities.HomeActivity;
|
||||
import com.nauk.moodl.Activities.SettingsActivity;
|
||||
import com.nauk.moodl.DataManagers.BalanceManager;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.Currency;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.CurrencyCardview;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.CurrencyTickerList;
|
||||
import com.nauk.moodl.DataManagers.PreferencesManager;
|
||||
import com.nauk.moodl.LayoutManagers.HomeLayoutGenerator;
|
||||
import com.nauk.moodl.PlaceholderManager;
|
||||
import com.nauk.moodl.R;
|
||||
|
||||
@ -42,7 +42,6 @@ import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.nauk.moodl.MoodlBox.numberConformer;
|
||||
import static java.lang.Math.abs;
|
||||
@ -56,7 +55,6 @@ public class Summary extends Fragment {
|
||||
private LinearLayout currencyLayout;
|
||||
private PreferencesManager preferencesManager;
|
||||
private BalanceManager balanceManager;
|
||||
private HomeLayoutGenerator layoutGenerator;
|
||||
private SwipeRefreshLayout refreshLayout;
|
||||
private Dialog loadingDialog;
|
||||
private String defaultCurrency;
|
||||
@ -85,7 +83,6 @@ public class Summary extends Fragment {
|
||||
|
||||
preferencesManager = new PreferencesManager(getActivity());
|
||||
balanceManager = new BalanceManager(getActivity());
|
||||
layoutGenerator = new HomeLayoutGenerator(getActivity());
|
||||
currencyTickerList = new CurrencyTickerList(getActivity());
|
||||
|
||||
currencyLayout = fragmentView.findViewById(R.id.currencyListLayout);
|
||||
@ -154,14 +151,16 @@ public class Summary extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<View> currencyView = new ArrayList<>();
|
||||
final List<Currency> renderedCurrencies = new ArrayList<>();
|
||||
|
||||
if (balanceManager.getTotalBalance() != null)
|
||||
{
|
||||
for (int i = 0; i < balanceManager.getTotalBalance().size(); i++) {
|
||||
final Currency currency = balanceManager.getTotalBalance().get(i);
|
||||
|
||||
if (!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > preferencesManager.getMinimumAmount())) {
|
||||
currencyView.add(layoutGenerator.getInfoLayout(currency, totalValue, preferencesManager.isBalanceHidden()));
|
||||
if (!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) >= preferencesManager.getMinimumAmount())) {
|
||||
//currencyView.add(layoutGenerator.getInfoLayout(currency, totalValue, preferencesManager.isBalanceHidden()));
|
||||
renderedCurrencies.add(currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,15 +170,18 @@ public class Summary extends Fragment {
|
||||
public void run() {
|
||||
currencyLayout.removeAllViews();
|
||||
|
||||
for(int i = 0; i < currencyView.size(); i++)
|
||||
for(int i = 0; i < renderedCurrencies.size(); i++)
|
||||
{
|
||||
currencyLayout.addView(currencyView.get(i));
|
||||
//currencyLayout.addView(currencyView.get(i));
|
||||
currencyLayout.addView(new CurrencyCardview(getActivity(), renderedCurrencies.get(i), totalValue, preferencesManager.isBalanceHidden()));
|
||||
}
|
||||
|
||||
if(loadingDialog.isShowing())
|
||||
{
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
|
||||
handler.removeCallbacks(updateRunnable);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -302,6 +304,7 @@ public class Summary extends Fragment {
|
||||
coinCounter = 0;
|
||||
iconCounter = 0;
|
||||
detailsChecker = false;
|
||||
tickersChecker = false;
|
||||
|
||||
totalValue = 0;
|
||||
totalFluctuation = 0;
|
||||
@ -309,7 +312,6 @@ public class Summary extends Fragment {
|
||||
|
||||
private void adaptView()
|
||||
{
|
||||
|
||||
layoutRefresherRunnable.run();
|
||||
}
|
||||
|
||||
@ -549,7 +551,6 @@ public class Summary extends Fragment {
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
handler.removeCallbacks(updateRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -619,16 +620,13 @@ public class Summary extends Fragment {
|
||||
{
|
||||
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
|
||||
|
||||
if(balanceManager.getIconUrl(localCurrency.getSymbol()) != null)
|
||||
{
|
||||
getBitmapFromURL(balanceManager.getIconUrl(localCurrency.getSymbol()), new HomeActivity.IconCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Bitmap bitmapIcon) {
|
||||
localCurrency.setIcon(bitmapIcon);
|
||||
countIcons();
|
||||
}
|
||||
});
|
||||
}
|
||||
getBitmapFromURL(balanceManager.getIconUrl(localCurrency.getSymbol()), new HomeActivity.IconCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Bitmap bitmapIcon) {
|
||||
localCurrency.setIcon(bitmapIcon);
|
||||
countIcons();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -696,7 +694,6 @@ public class Summary extends Fragment {
|
||||
balanceManager.updateTotalBalance(new BalanceManager.VolleyCallBack() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
final List<Currency> balance = balanceManager.getTotalBalance();
|
||||
|
||||
if(balanceManager.getTotalBalance().size() > 0)
|
||||
|
@ -34,6 +34,7 @@ import com.nauk.moodl.Activities.HomeActivity;
|
||||
import com.nauk.moodl.Activities.SettingsActivity;
|
||||
import com.nauk.moodl.DataManagers.BalanceManager;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.Currency;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.CurrencyCardview;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.CurrencyDataChart;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.CurrencyDetailsList;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.CurrencyTickerList;
|
||||
@ -184,12 +185,6 @@ public class Watchlist extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void displayChartView()
|
||||
{
|
||||
expandH(view.findViewById(R.id.collapsableLayout));
|
||||
view.findViewById(R.id.LineChartView).invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
@ -248,31 +243,17 @@ public class Watchlist extends Fragment {
|
||||
|
||||
private void generateCards()
|
||||
{
|
||||
final List<View> watchlistViews = new ArrayList<View>();
|
||||
|
||||
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).removeAllViews();
|
||||
|
||||
Runnable newRunnable = new Runnable() {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for(final Currency currency : watchlistManager.getWatchlist())
|
||||
for(Currency currency : watchlistManager.getWatchlist())
|
||||
{
|
||||
watchlistViews.add(getCurrencyCardFor(currency));
|
||||
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).addView(new CurrencyCardview(getContext(), currency));
|
||||
}
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for(int i = 0; i < watchlistViews.size(); i++)
|
||||
{
|
||||
((LinearLayout) view.findViewById(R.id.linearLayoutWatchlist)).addView(watchlistViews.get(i), 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
newRunnable.run();
|
||||
});
|
||||
|
||||
if(refreshLayout.isRefreshing())
|
||||
{
|
||||
@ -290,104 +271,6 @@ public class Watchlist extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
private View getCurrencyCardFor(final Currency currency)
|
||||
{
|
||||
final View card = LayoutInflater.from(getContext()).inflate(R.layout.cardview_watchlist, null);
|
||||
|
||||
card.setTag(currency.getSymbol());
|
||||
|
||||
((TextView) card.findViewById(R.id.currencyFluctuationTextView))
|
||||
.setText(PlaceholderManager.getValueParenthesisString(numberConformer(currency.getDayFluctuation()), getActivity()));
|
||||
((TextView) card.findViewById(R.id.currencyValueTextView))
|
||||
.setText(PlaceholderManager.getValueString(numberConformer(currency.getValue()), getActivity()));
|
||||
|
||||
((TextView) card.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||
.setText(PlaceholderManager.getPercentageString(numberConformer(currency.getDayFluctuationPercentage()), getActivity()));
|
||||
((TextView) card.findViewById(R.id.currencyNameTextView))
|
||||
.setText(currency.getName());
|
||||
((TextView) card.findViewById(R.id.currencySymbolTextView))
|
||||
.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();
|
||||
|
||||
card.findViewById(R.id.deleteCardWatchlist).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
collapseH(card);
|
||||
DatabaseManager databaseManager = new DatabaseManager(getActivity());
|
||||
databaseManager.deleteCurrencyFromWatchlist(currency.getSymbol());
|
||||
}
|
||||
});
|
||||
|
||||
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
|
||||
public void onClick(final View view) {
|
||||
if(view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE)
|
||||
{
|
||||
collapseH(view.findViewById(R.id.collapsableLayout));
|
||||
}
|
||||
else
|
||||
{
|
||||
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.VISIBLE);
|
||||
|
||||
displayChartView();
|
||||
|
||||
if (currency.getHistoryMinutes() == null) {
|
||||
currency.updateHistoryMinutes(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Currency currency) {
|
||||
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
|
||||
{
|
||||
displayChartView();
|
||||
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
private LineData generateData(Currency currency)
|
||||
{
|
||||
LineDataSet dataSet;
|
||||
@ -427,42 +310,6 @@ public class Watchlist extends Fragment {
|
||||
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));
|
||||
|
||||
lineChart.invalidate();
|
||||
}
|
||||
|
||||
private void updateColor(View card, Currency currency)
|
||||
{
|
||||
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));
|
||||
}
|
||||
else
|
||||
{
|
||||
((TextView) card.findViewById(R.id.currencyFluctuationPercentageTextView)).setTextColor(getResources().getColor(R.color.decrease));
|
||||
((TextView) card.findViewById(R.id.currencyFluctuationTextView)).setTextColor(getResources().getColor(R.color.decrease));
|
||||
}
|
||||
}
|
||||
|
||||
private String getIconUrl(String symbol)
|
||||
{
|
||||
String url;
|
||||
@ -547,17 +394,14 @@ public class Watchlist extends Fragment {
|
||||
currency.updatePrice(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||
@Override
|
||||
public void onSuccess(final Currency sucessCurrency) {
|
||||
if(getIconUrl(sucessCurrency.getSymbol()) != null)
|
||||
{
|
||||
getBitmapFromURL(getIconUrl(sucessCurrency.getSymbol()), new HomeActivity.IconCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Bitmap bitmapIcon) {
|
||||
sucessCurrency.setIcon(bitmapIcon);
|
||||
updateChartColor(currency);
|
||||
countWatchlist();
|
||||
}
|
||||
});
|
||||
}
|
||||
getBitmapFromURL(getIconUrl(sucessCurrency.getSymbol()), new HomeActivity.IconCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Bitmap bitmapIcon) {
|
||||
sucessCurrency.setIcon(bitmapIcon);
|
||||
updateChartColor(currency);
|
||||
countWatchlist();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class BalanceManager {
|
||||
|
||||
for(int i = 0; i < hitBtcManagers.size(); i++)
|
||||
{
|
||||
hitBtcManagers.get(i).updateBalance(new HitBtcManager.HitBtcCallBack() {
|
||||
hitBtcManagers.get(i).updateGlobalBalance(new HitBtcManager.HitBtcCallBack() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
countBalances(callBack);
|
||||
@ -274,8 +274,16 @@ public class BalanceManager {
|
||||
String url;
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
|
||||
url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50";
|
||||
switch (symbol)
|
||||
{
|
||||
case "IOTA":
|
||||
url = "https://www.cryptocompare.com/media/1383540/iota_logo.png?width=50";
|
||||
break;
|
||||
default:
|
||||
JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
|
||||
url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50";
|
||||
break;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
Log.d(context.getResources().getString(R.string.debug), symbol + " has no icon URL");
|
||||
url = null;
|
||||
|
@ -96,6 +96,7 @@ public class Currency implements Parcelable {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(currencyDetails);
|
||||
url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50";
|
||||
|
||||
} catch (NullPointerException e) {
|
||||
//Log.d(context.getResources().getString(R.string.debug), symbol + " has no icon URL");
|
||||
url = null;
|
||||
|
@ -0,0 +1,330 @@
|
||||
package com.nauk.moodl.DataManagers.CurrencyData;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
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.moodl.Activities.CurrencyDetailsActivity;
|
||||
import com.nauk.moodl.DataManagers.PreferencesManager;
|
||||
import com.nauk.moodl.PlaceholderManager;
|
||||
import com.nauk.moodl.R;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.nauk.moodl.MoodlBox.collapseH;
|
||||
import static com.nauk.moodl.MoodlBox.expandH;
|
||||
import static com.nauk.moodl.MoodlBox.numberConformer;
|
||||
|
||||
/**
|
||||
* Created by Tiji on 12/05/2018.
|
||||
*/
|
||||
|
||||
public class CurrencyCardview extends CardView {
|
||||
|
||||
public CurrencyCardview(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public CurrencyCardview(@NonNull final Context context, final Currency currency)
|
||||
{
|
||||
super (context);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.cardview_watchlist, this, true);
|
||||
|
||||
((LineChart) findViewById(R.id.LineChartView)).setNoDataTextColor(currency.getChartColor());
|
||||
|
||||
findViewById(R.id.masterLayout).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
PreferencesManager preferencesManager = new PreferencesManager(context);
|
||||
|
||||
if (view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE) {
|
||||
collapseH(view.findViewById(R.id.collapsableLayout));
|
||||
} else {
|
||||
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.VISIBLE);
|
||||
expandH(view.findViewById(R.id.collapsableLayout));
|
||||
|
||||
if (currency.getHistoryMinutes() == null) {
|
||||
currency.updateHistoryMinutes(context, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Currency currency) {
|
||||
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
|
||||
{
|
||||
expandH(view.findViewById(R.id.collapsableLayout));
|
||||
view.findViewById(R.id.progressBarLinechartWatchlist).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
updateCardViewInfos(currency);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
updateColor(currency);
|
||||
}
|
||||
|
||||
public CurrencyCardview(@NonNull final Context context, final Currency currency, float totalValue, boolean isBalanceHidden)
|
||||
{
|
||||
super(context);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.cardview_currency, this, true);
|
||||
|
||||
((LineChart) findViewById(R.id.LineChartView)).setNoDataTextColor(currency.getChartColor());
|
||||
|
||||
findViewById(R.id.masterLayout).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
PreferencesManager preferencesManager = new PreferencesManager(context);
|
||||
|
||||
if (view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE) {
|
||||
collapseH(view.findViewById(R.id.collapsableLayout));
|
||||
} else {
|
||||
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.VISIBLE);
|
||||
expandH(view.findViewById(R.id.collapsableLayout));
|
||||
|
||||
if (currency.getHistoryMinutes() == null) {
|
||||
currency.updateHistoryMinutes(context, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Currency currency) {
|
||||
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
|
||||
{
|
||||
expandH(view.findViewById(R.id.collapsableLayout));
|
||||
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
updateCardViewInfos(currency, totalValue, isBalanceHidden);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
updateColor(currency);
|
||||
}
|
||||
|
||||
private void setupLineChart(View view, final Currency currency)
|
||||
{
|
||||
LineChart lineChart = 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 updateCardViewInfos(Currency currency)
|
||||
{
|
||||
((TextView) findViewById(R.id.currencyFluctuationTextView))
|
||||
.setText(PlaceholderManager.getValueParenthesisString(numberConformer(currency.getDayFluctuation()), getContext()));
|
||||
((TextView) findViewById(R.id.currencyValueTextView))
|
||||
.setText(PlaceholderManager.getValueString(numberConformer(currency.getValue()), getContext()));
|
||||
|
||||
((ImageView) findViewById(R.id.currencyIcon))
|
||||
.setImageBitmap(currency.getIcon());
|
||||
((TextView) findViewById(R.id.currencyNameTextView))
|
||||
.setText(currency.getName());
|
||||
((TextView) findViewById(R.id.currencySymbolTextView))
|
||||
.setText(PlaceholderManager.getSymbolString(currency.getSymbol(), getContext()));
|
||||
((TextView) findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||
.setText(PlaceholderManager.getPercentageString(numberConformer(currency.getDayFluctuationPercentage()), getContext()));
|
||||
|
||||
Drawable arrowDrawable = ((ImageView) findViewById(R.id.detailsArrow)).getDrawable();
|
||||
arrowDrawable.mutate();
|
||||
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||
arrowDrawable.invalidateSelf();
|
||||
|
||||
Drawable progressDrawable = ((ProgressBar) findViewById(R.id.progressBarLinechartWatchlist)).getIndeterminateDrawable();
|
||||
progressDrawable.mutate();
|
||||
progressDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||
progressDrawable.invalidateSelf();
|
||||
}
|
||||
|
||||
private void updateCardViewInfos(Currency currency, float totalValue, boolean isBalanceHidden)
|
||||
{
|
||||
double value = currency.getValue() * currency.getBalance();
|
||||
double percentage = value / totalValue * 100;
|
||||
|
||||
((TextView) findViewById(R.id.currencyValueOwnedTextView))
|
||||
.setText(PlaceholderManager.getValueParenthesisString(numberConformer(currency.getValue() * currency.getBalance()), getContext()));
|
||||
((TextView) findViewById(R.id.currencyFluctuationTextView))
|
||||
.setText(PlaceholderManager.getValueParenthesisString(numberConformer(currency.getDayFluctuation()), getContext()));
|
||||
((TextView) findViewById(R.id.currencyValueTextView))
|
||||
.setText(PlaceholderManager.getValueString(numberConformer(currency.getValue()), getContext()));
|
||||
|
||||
((ImageView) findViewById(R.id.currencyIcon))
|
||||
.setImageBitmap(currency.getIcon());
|
||||
((TextView) findViewById(R.id.currencyNameTextView))
|
||||
.setText(currency.getName());
|
||||
((TextView) findViewById(R.id.currencySymbolTextView))
|
||||
.setText(PlaceholderManager.getSymbolString(currency.getSymbol(), getContext()));
|
||||
((TextView) findViewById(R.id.currencyOwnedTextView))
|
||||
.setText(PlaceholderManager.getBalanceString(numberConformer(currency.getBalance()), currency.getSymbol(), getContext()));
|
||||
((TextView) findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||
.setText(PlaceholderManager.getPercentageString(numberConformer(currency.getDayFluctuationPercentage()), getContext()));
|
||||
|
||||
Drawable arrowDrawable = ((ImageView) findViewById(R.id.detailsArrow)).getDrawable();
|
||||
arrowDrawable.mutate();
|
||||
arrowDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||
arrowDrawable.invalidateSelf();
|
||||
|
||||
Drawable progressDrawable = ((ProgressBar) findViewById(R.id.progressBarLinechartSummary)).getIndeterminateDrawable();
|
||||
progressDrawable.mutate();
|
||||
progressDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||
progressDrawable.invalidateSelf();
|
||||
|
||||
Drawable progressBarDrawable = ((ProgressBar) findViewById(R.id.currencyPortfolioDominance)).getProgressDrawable();
|
||||
progressBarDrawable.mutate();
|
||||
progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||
progressBarDrawable.invalidateSelf();
|
||||
|
||||
((ProgressBar) findViewById(R.id.currencyPortfolioDominance)).setProgress((int) Math.round(percentage));
|
||||
((TextView) findViewById(R.id.percentageOwnedTextView)).setText(PlaceholderManager.getPercentageString(numberConformer(percentage), getContext()));
|
||||
|
||||
if(isBalanceHidden)
|
||||
{
|
||||
findViewById(R.id.currencyPortfolioDominance).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.percentageOwnedTextView).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
findViewById(R.id.currencyPortfolioDominance).setVisibility(View.INVISIBLE);
|
||||
findViewById(R.id.percentageOwnedTextView).setVisibility(View.GONE);
|
||||
findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private LineData generateData(Currency currency)
|
||||
{
|
||||
LineDataSet dataSet;
|
||||
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
||||
ArrayList<Entry> values = new ArrayList<>();
|
||||
|
||||
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 void updateColor(Currency currency)
|
||||
{
|
||||
if(currency.getDayFluctuationPercentage() >= 0)
|
||||
{
|
||||
((TextView) findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||
.setTextColor(getResources().getColor(R.color.increase));
|
||||
((TextView) findViewById(R.id.currencyFluctuationTextView))
|
||||
.setTextColor(getResources().getColor(R.color.increase));
|
||||
}
|
||||
else
|
||||
{
|
||||
((TextView) findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||
.setTextColor(getResources().getColor(R.color.decrease));
|
||||
((TextView) findViewById(R.id.currencyFluctuationTextView))
|
||||
.setTextColor(getResources().getColor(R.color.decrease));
|
||||
}
|
||||
}
|
||||
|
||||
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 ;
|
||||
}
|
||||
}
|
@ -27,12 +27,12 @@ public class CurrencyDataRetriever {
|
||||
final static int HOURS = 1;
|
||||
final static int DAYS = 2;
|
||||
|
||||
private String minuteHistoryUrl = "https://min-api.cryptocompare.com/data/histominute";
|
||||
private String hourHistoryUrl = "https://min-api.cryptocompare.com/data/histohour";
|
||||
private String dayHistoryUrl = "https://min-api.cryptocompare.com/data/histoday";
|
||||
private String priceUrl = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=";
|
||||
private String snapshotUrl = "https://www.cryptocompare.com/api/data/coinsnapshotfullbyid/?id=";
|
||||
private String tickerUrl = "https://api.coinmarketcap.com/v2/ticker/";
|
||||
private final static String minuteHistoryUrl = "https://min-api.cryptocompare.com/data/histominute";
|
||||
private final static String hourHistoryUrl = "https://min-api.cryptocompare.com/data/histohour";
|
||||
private final static String dayHistoryUrl = "https://min-api.cryptocompare.com/data/histoday";
|
||||
private final static String priceUrl = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=";
|
||||
private final static String snapshotUrl = "https://www.cryptocompare.com/api/data/coinsnapshotfullbyid/?id=";
|
||||
private final static String tickerUrl = "https://api.coinmarketcap.com/v2/ticker/";
|
||||
|
||||
private RequestQueue requestQueue;
|
||||
|
||||
@ -157,8 +157,12 @@ public class CurrencyDataRetriever {
|
||||
requestQueue.add(stringRequest);
|
||||
}
|
||||
|
||||
public void updatePrice(final String symbolCurrencyFrom, String symbolCurrencyTo, final CurrencyCallBack callBack)
|
||||
public void updatePrice(String symbolCurrencyFrom, String symbolCurrencyTo, final CurrencyCallBack callBack)
|
||||
{
|
||||
if(symbolCurrencyFrom.equals("MIOTA"))
|
||||
{
|
||||
symbolCurrencyFrom = "IOT";
|
||||
}
|
||||
String requestUrl = priceUrl + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo;
|
||||
|
||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
|
||||
|
@ -26,7 +26,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class CurrencyDetailsList {
|
||||
|
||||
final private static String DETAILURL = "https://www.cryptocompare.com/api/data/coinlist/";
|
||||
final private static String DETAILURL = "https://min-api.cryptocompare.com/data/all/coinlist";
|
||||
private RequestQueue requestQueue;
|
||||
private LinkedHashMap<String, String> coinInfosHashmap;
|
||||
private android.content.Context context;
|
||||
@ -74,7 +74,18 @@ public class CurrencyDetailsList {
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
JSONObject jsonObject = new JSONObject(tab[i]);
|
||||
|
||||
coinInfosHashmap.put(jsonObject.getString("Symbol"), tab[i]);
|
||||
switch (jsonObject.getString("Symbol"))
|
||||
{
|
||||
case "IOT":
|
||||
coinInfosHashmap.put("MIOTA", tab[i]);
|
||||
break;
|
||||
case "XRB":
|
||||
coinInfosHashmap.put("NANO", tab[i]);
|
||||
break;
|
||||
default:
|
||||
coinInfosHashmap.put(jsonObject.getString("Symbol"), tab[i]);
|
||||
break;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.d(context.getResources().getString(R.string.debug), "ImageUrl not found.");
|
||||
}
|
||||
|
@ -85,18 +85,7 @@ public class CurrencyTickerList {
|
||||
for(int i = 0; i < dataJsonArray.length(); i++)
|
||||
{
|
||||
JSONObject currencyJsonObject = dataJsonArray.getJSONObject(i);
|
||||
switch (currencyJsonObject.getString("symbol"))
|
||||
{
|
||||
case "MIOTA":
|
||||
currencyTickerList.add(new Currency(currencyJsonObject.getString("name"), "IOT", currencyJsonObject.getInt("id")));
|
||||
break;
|
||||
case "NANO":
|
||||
currencyTickerList.add(new Currency(currencyJsonObject.getString("name"), "XRB", currencyJsonObject.getInt("id")));
|
||||
break;
|
||||
default:
|
||||
currencyTickerList.add(new Currency(currencyJsonObject.getString("name"), currencyJsonObject.getString("symbol"), currencyJsonObject.getInt("id")));
|
||||
break;
|
||||
}
|
||||
currencyTickerList.add(new Currency(currencyJsonObject.getString("name"), currencyJsonObject.getString("symbol"), currencyJsonObject.getInt("id")));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -204,11 +204,10 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
|
||||
ArrayList<Transaction> transactionList = new ArrayList<>();
|
||||
|
||||
resultatList.moveToLast();
|
||||
|
||||
do {
|
||||
while (resultatList.moveToNext())
|
||||
{
|
||||
transactionList.add(new Transaction(resultatList.getInt(0), resultatList.getString(1), resultatList.getDouble(3), resultatList.getLong(4), resultatList.getLong(5), resultatList.getDouble(7)));
|
||||
} while(resultatList.moveToPrevious());
|
||||
}
|
||||
|
||||
resultatList.close();
|
||||
|
||||
|
@ -31,9 +31,12 @@ public class HitBtcManager {
|
||||
private String publicKey;
|
||||
private String privateKey;
|
||||
final private String hitBalanceUrl = "https://api.hitbtc.com/api/2/account/balance";
|
||||
final private String hitTradingBalanceUrl = "https://api.hitbtc.com/api/2/trading/balance";
|
||||
final private String tradeHistoryUrl = "https://api.hitbtc.com/api/2/history/trades?";
|
||||
private RequestQueue requestQueue;
|
||||
private List<String> pairSymbolList;
|
||||
private boolean isTradingBalanceUpdated;
|
||||
private boolean isBalanceUpdated;
|
||||
|
||||
private List<Currency> balance;
|
||||
private android.content.Context context;
|
||||
@ -62,7 +65,97 @@ public class HitBtcManager {
|
||||
|
||||
}
|
||||
|
||||
public void updateBalance(final HitBtcCallBack callBack)
|
||||
private void mergeBalanceSymbols()
|
||||
{
|
||||
List<Currency> mergedBalance = new ArrayList<>();
|
||||
|
||||
for(int i = 0; i < balance.size(); i++)
|
||||
{
|
||||
boolean updated = false;
|
||||
|
||||
for(int j = 0; j < mergedBalance.size(); j++)
|
||||
{
|
||||
if(mergedBalance.get(j).getSymbol().equals(balance.get(i).getSymbol()))
|
||||
{
|
||||
mergedBalance.get(j).setBalance(mergedBalance.get(j).getBalance() + balance.get(i).getBalance());
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!updated)
|
||||
{
|
||||
mergedBalance.add(balance.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
balance = mergedBalance;
|
||||
}
|
||||
|
||||
public void updateGlobalBalance(final HitBtcCallBack masterCallBack)
|
||||
{
|
||||
isTradingBalanceUpdated = false;
|
||||
isBalanceUpdated = false;
|
||||
|
||||
balance = new ArrayList<>();
|
||||
|
||||
updateBalance(new HitBtcCallBack() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
isBalanceUpdated = true;
|
||||
|
||||
if(isTradingBalanceUpdated)
|
||||
{
|
||||
mergeBalanceSymbols();
|
||||
masterCallBack.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
masterCallBack.onError(error);
|
||||
}
|
||||
});
|
||||
|
||||
updateTradingBalance(new HitBtcCallBack() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
isTradingBalanceUpdated = true;
|
||||
|
||||
if(isBalanceUpdated)
|
||||
{
|
||||
mergeBalanceSymbols();
|
||||
masterCallBack.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
masterCallBack.onError(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateTradingBalance(final HitBtcCallBack callBack)
|
||||
{
|
||||
JsonArrayRequest arrayRequest = new JsonArrayRequest(Request.Method.GET, hitTradingBalanceUrl
|
||||
, getResponseListener(callBack), getErrorResponseListener(callBack))
|
||||
{
|
||||
@Override
|
||||
public Map<String, String> getHeaders() throws AuthFailureError {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
String credentials = publicKey + ":" + privateKey;
|
||||
String auth = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
|
||||
headers.put("Content-Type", "application/json");
|
||||
headers.put("Authorization", auth);
|
||||
|
||||
return headers;
|
||||
}
|
||||
};
|
||||
|
||||
requestQueue.add(arrayRequest);
|
||||
}
|
||||
|
||||
private void updateBalance(final HitBtcCallBack callBack)
|
||||
{
|
||||
JsonArrayRequest arrayRequest = new JsonArrayRequest(Request.Method.GET, hitBalanceUrl
|
||||
, getResponseListener(callBack), getErrorResponseListener(callBack))
|
||||
@ -109,8 +202,6 @@ public class HitBtcManager {
|
||||
|
||||
private void parseBalance(JSONArray response)
|
||||
{
|
||||
balance = new ArrayList<>();
|
||||
|
||||
for(int i = 0; i < response.length(); i++)
|
||||
{
|
||||
try {
|
||||
@ -120,7 +211,15 @@ public class HitBtcManager {
|
||||
|
||||
if(available > 0 || reserved > 0)
|
||||
{
|
||||
balance.add(new Currency(jsonObject.getString("currency"), available + reserved));
|
||||
switch (jsonObject.getString("currency"))
|
||||
{
|
||||
case "IOTA":
|
||||
balance.add(new Currency("MIOTA", available + reserved));
|
||||
break;
|
||||
default:
|
||||
balance.add(new Currency(jsonObject.getString("currency"), available + reserved));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
|
@ -1,332 +0,0 @@
|
||||
package com.nauk.moodl.LayoutManagers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Transformation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
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.moodl.Activities.CurrencyDetailsActivity;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.Currency;
|
||||
import com.nauk.moodl.DataManagers.CurrencyData.CurrencyDataChart;
|
||||
import com.nauk.moodl.DataManagers.PreferencesManager;
|
||||
import com.nauk.moodl.PlaceholderManager;
|
||||
import com.nauk.moodl.R;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.nauk.moodl.MoodlBox.collapseH;
|
||||
import static com.nauk.moodl.MoodlBox.expandH;
|
||||
import static com.nauk.moodl.MoodlBox.numberConformer;
|
||||
|
||||
/**
|
||||
* Created by Tiji on 05/01/2018.
|
||||
*/
|
||||
|
||||
public class HomeLayoutGenerator {
|
||||
|
||||
private android.content.Context context;
|
||||
|
||||
public HomeLayoutGenerator(Context context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public View getInfoLayout(final Currency currency, float totalValue, boolean isBalanceHidden)
|
||||
{
|
||||
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) {
|
||||
PreferencesManager preferencesManager = new PreferencesManager(context);
|
||||
|
||||
if (view.findViewById(R.id.collapsableLayout).getVisibility() == View.VISIBLE) {
|
||||
collapseH(view.findViewById(R.id.collapsableLayout));
|
||||
} else {
|
||||
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.VISIBLE);
|
||||
expandH(view.findViewById(R.id.collapsableLayout));
|
||||
|
||||
if (currency.getHistoryMinutes() == null) {
|
||||
currency.updateHistoryMinutes(context, preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Currency currency) {
|
||||
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
|
||||
{
|
||||
expandH(view.findViewById(R.id.collapsableLayout));
|
||||
view.findViewById(R.id.progressBarLinechartSummary).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.linearLayoutSubLayout).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
updateColor(view, currency);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
/*private class ChartLoader extends AsyncTask<Void, Integer, Void>
|
||||
{
|
||||
private View view;
|
||||
private Currency currency;
|
||||
|
||||
ChartLoader(View view, Currency currency)
|
||||
{
|
||||
this.view = view;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
extendView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
setupLineChart(view, currency);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
|
||||
view.findViewById(R.id.progressLineChart).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.LineChartView).setVisibility(View.VISIBLE);
|
||||
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);
|
||||
}
|
||||
|
||||
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 updateCardViewInfos(View view, Currency currency, float totalValue, boolean isBalanceHidden)
|
||||
{
|
||||
double value = currency.getValue() * currency.getBalance();
|
||||
double percentage = value / totalValue * 100;
|
||||
DecimalFormat df = new DecimalFormat(".##");
|
||||
|
||||
((TextView) view.findViewById(R.id.currencyValueOwnedTextView))
|
||||
.setText(PlaceholderManager.getValueParenthesisString(numberConformer(currency.getValue() * currency.getBalance()), context));
|
||||
((TextView) view.findViewById(R.id.currencyValueTextView))
|
||||
.setText(PlaceholderManager.getValueString(numberConformer(currency.getValue()), context));
|
||||
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||
.setText(PlaceholderManager.getValueParenthesisString(numberConformer(currency.getDayFluctuation()), context));
|
||||
|
||||
((ImageView) view.findViewById(R.id.currencyIcon))
|
||||
.setImageBitmap(currency.getIcon());
|
||||
((TextView) view.findViewById(R.id.currencyNameTextView))
|
||||
.setText(currency.getName());
|
||||
((TextView) view.findViewById(R.id.currencySymbolTextView))
|
||||
.setText(PlaceholderManager.getSymbolString(currency.getSymbol(), context));
|
||||
((TextView) view.findViewById(R.id.currencyOwnedTextView))
|
||||
.setText(PlaceholderManager.getBalanceString(numberConformer(currency.getBalance()), currency.getSymbol(), context));
|
||||
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||
.setText(PlaceholderManager.getPercentageString(numberConformer(currency.getDayFluctuationPercentage()), context));
|
||||
|
||||
Drawable arrowDrawable = ((ImageView) view.findViewById(R.id.detailsArrow)).getDrawable();
|
||||
arrowDrawable.mutate();
|
||||
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));
|
||||
progressBarDrawable.invalidateSelf();
|
||||
|
||||
((ProgressBar) view.findViewById(R.id.currencyPortfolioDominance)).setProgress((int) Math.round(percentage));
|
||||
((TextView) view.findViewById(R.id.percentageOwnedTextView)).setText(PlaceholderManager.getPercentageString(numberConformer(percentage), context));
|
||||
|
||||
if(isBalanceHidden)
|
||||
{
|
||||
view.findViewById(R.id.currencyPortfolioDominance).setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.percentageOwnedTextView).setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
view.findViewById(R.id.currencyPortfolioDominance).setVisibility(View.INVISIBLE);
|
||||
view.findViewById(R.id.percentageOwnedTextView).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.currencyOwnedInfoLayout).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateColor(View view, Currency currency)
|
||||
{
|
||||
if(currency.getDayFluctuationPercentage() >= 0)
|
||||
{
|
||||
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||
.setTextColor(context.getResources().getColor(R.color.increase));
|
||||
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||
.setTextColor(context.getResources().getColor(R.color.increase));
|
||||
}
|
||||
else
|
||||
{
|
||||
((TextView) view.findViewById(R.id.currencyFluctuationPercentageTextView))
|
||||
.setTextColor(context.getResources().getColor(R.color.decrease));
|
||||
((TextView) view.findViewById(R.id.currencyFluctuationTextView))
|
||||
.setTextColor(context.getResources().getColor(R.color.decrease));
|
||||
}
|
||||
}
|
||||
|
||||
private LineData generateData(Currency currency)
|
||||
{
|
||||
LineDataSet dataSet;
|
||||
List<CurrencyDataChart> dataChartList = currency.getHistoryMinutes();
|
||||
ArrayList<Entry> values = new ArrayList<>();
|
||||
|
||||
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 ;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/masterLayout"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:card_view="http://schemas.android.com/tools"
|
||||
android:clickable="true"
|
||||
@ -9,10 +10,12 @@
|
||||
android:paddingBottom="4dp">
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/cardview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:backgroundTint="@color/cardview_background"
|
||||
app:cardCornerRadius="2dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
@ -2,6 +2,7 @@
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/masterLayout"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
@ -19,199 +20,192 @@
|
||||
android:tag="Parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/mainLinear"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:clickable="false"
|
||||
android:orientation="vertical"
|
||||
android:tag="mainLinear">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/mainLinear"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:orientation="vertical"
|
||||
android:tag="mainLinear">
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/currencyInfoLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false">
|
||||
android:layout_margin="5dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.92">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/currencyInfoLayout"
|
||||
android:layout_width="0dp"
|
||||
android:id="@+id/topLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.92">
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/topLayout"
|
||||
<ImageView
|
||||
android:id="@+id/currencyIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="1dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currencyNameTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="start"
|
||||
android:textColor="@color/mainTextViewColor"
|
||||
android:textSize="@dimen/cardViewMainText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currencySymbolTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:gravity="left"
|
||||
android:textColor="@color/secondaryTextViewColor"
|
||||
android:textSize="@dimen/cardViewSecondaryText" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currencyValueTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center">
|
||||
android:gravity="start"
|
||||
android:textColor="@color/secondaryTextViewColor"
|
||||
android:textSize="@dimen/cardViewMainText"
|
||||
android:layout_weight="0.5"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/currencyIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="1dp" />
|
||||
<LinearLayout
|
||||
android:id="@+id/secondaryLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="0.5">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currencyNameTextView"
|
||||
android:id="@+id/currencyFluctuationPercentageTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="start"
|
||||
android:textColor="@color/mainTextViewColor"
|
||||
android:textSize="@dimen/cardViewMainText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currencySymbolTextView"
|
||||
android:id="@+id/currencyFluctuationTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:gravity="left"
|
||||
android:textColor="@color/secondaryTextViewColor"
|
||||
android:textSize="@dimen/cardViewSecondaryText" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currencyValueTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="start"
|
||||
android:textColor="@color/secondaryTextViewColor"
|
||||
android:textSize="@dimen/cardViewMainText"
|
||||
android:layout_weight="0.5"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/secondaryLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="0.5">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currencyFluctuationPercentageTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/cardViewMainText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currencyFluctuationTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/cardViewSecondaryText" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/deleteCardWatchlist"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/decreaseCandle"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="end"
|
||||
android:visibility="gone"
|
||||
android:layout_weight="0.08"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ic_delete_white_24dp"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/collapsableLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/deleteCardWatchlist"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/decreaseCandle"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="end"
|
||||
android:visibility="gone"
|
||||
android:layout_weight="0.08"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/separationLayout"
|
||||
android:layout_width="match_parent"
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp">
|
||||
android:background="@drawable/ic_delete_white_24dp"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Day history"
|
||||
android:textSize="@dimen/cardViewSecondaryText" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/separationLineSize"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:background="@color/separationColor" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/collapsableLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/separationLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Day history"
|
||||
android:textSize="@dimen/cardViewSecondaryText" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/separationLineSize"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:background="@color/separationColor" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frameLayoutChart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/cardViewChartSize"
|
||||
android:clickable="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/frameLayoutChart"
|
||||
android:id="@+id/linearLayoutSubLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/cardViewChartSize"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:visibility="visible">
|
||||
android:visibility="gone">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBarLinechartWatchlist"
|
||||
<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: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="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>
|
||||
android:src="@drawable/ic_keyboard_arrow_right_grey_48dp"
|
||||
android:layout_gravity="center_vertical|end"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -79,11 +79,6 @@
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:overScrollMode="never">
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayoutWatchlist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -101,8 +96,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonAddWatchlist"
|
||||
android:text="Add to watchlist"
|
||||
|
Loading…
x
Reference in New Issue
Block a user