Update detail activity

Details for
1h, 3h, 1d, 3d, 1w, 1M, 3M, 6M & 1Y
This commit is contained in:
Tanguy Herbron 2018-02-06 15:59:01 +01:00
parent d220e661b4
commit 267cdefc9b
9 changed files with 785 additions and 507 deletions

View File

@ -1,9 +1,8 @@
package com.nauk.coinfolio.Activities;
import android.content.ContentValues;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
@ -13,22 +12,16 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.BounceInterpolator;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.ViewFlipper;
import com.daimajia.swipe.SwipeLayout;
import com.db.chart.animation.Animation;
import com.db.chart.model.LineSet;
import com.db.chart.model.Point;
import com.db.chart.renderer.AxisRenderer;
import com.db.chart.tooltip.Tooltip;
import com.db.chart.util.Tools;
import com.db.chart.view.LineChartView;
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
@ -36,11 +29,8 @@ import com.nauk.coinfolio.DataManagers.CurrencyData.Transaction;
import com.nauk.coinfolio.DataManagers.DatabaseManager;
import com.nauk.coinfolio.R;
import org.w3c.dom.Text;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -58,6 +48,11 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
private Tooltip tip;
private int indexMax;
private int indexMin;
private final static int HOUR = 0;
private final static int DAY = 1;
private final static int WEEK = 2;
private final static int MONTH = 3;
private final static int YEAR = 4;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@ -108,19 +103,21 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
drawTransactionList();
if(currency.getDayPriceHistory().size() > 0)
initializeButtons();
if(currency.getHistoryMinutes().size() > 0)
{
drawChart();
drawChart(DAY, 1);
}
else
{
TextView errorTextView = new TextView(this);
errorTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 500));
errorTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 750));
errorTextView.setText("Not enough data");
errorTextView.setTag("chart_layout");
errorTextView.setGravity(Gravity.CENTER);
chartLayout.addView(errorTextView);
chartLayout.addView(errorTextView, 0);
}
setTitle(currency.getName());
@ -131,56 +128,259 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
hasBeenModified = false;
}
private void drawChart()
private void initializeButtons()
{
final LineChartView chartView = new LineChartView(this);
LineSet lineSet = new LineSet();
double valMin;
double valMax;
int counter = 0;
Calendar calendar = Calendar.getInstance(Locale.FRANCE);
String hour;
String minute;
LinearLayout buttonLayout = findViewById(R.id.layoutChartButtons);
final List<CurrencyDataChart> dataChartList = currency.getDayPriceHistory();
indexMin = 0;
indexMax = 0;
valMin = dataChartList.get(0).getOpen();
valMax = dataChartList.get(0).getOpen();
for(int i = 1; i < dataChartList.size(); i++)
for(int i = 0; i < buttonLayout.getChildCount(); i++)
{
if(valMax < dataChartList.get(i).getOpen())
{
valMax = dataChartList.get(i).getOpen();
indexMax = i;
final Button button = (Button) buttonLayout.getChildAt(i);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
buttonEvent(v);
}
if(valMin > dataChartList.get(i).getOpen())
{
valMin = dataChartList.get(i).getOpen();
indexMin = i;
});
}
}
if(valMax == valMin)
private void buttonEvent(View v)
{
valMin = 0;
valMax *= 2;
v.setEnabled(false);
LinearLayout buttonLayout = (LinearLayout) v.getParent();
for(int i = 0; i < buttonLayout.getChildCount(); i++)
{
Button button = (Button) buttonLayout.getChildAt(i);
if(button != v)
{
button.setEnabled(true);
}
}
chartEvent((Button) v);
}
private void chartEvent(Button button)
{
findViewById(R.id.chartView).setVisibility(View.GONE);
findViewById(R.id.progressLayoutChart).setVisibility(View.VISIBLE);
String interval = button.getText().toString().substring(button.getText().toString().length()-2);
switch (interval)
{
case "1h":
drawChart(HOUR, 1);
break;
case "3h":
drawChart(HOUR, 3);
break;
case "1d":
drawChart(DAY, 1);
break;
case "3d":
currency.updateHistoryHours(this, new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
runOnUiThread(new Runnable() {
@Override
public void run() {
drawChart(CurrencyDetailsActivity.DAY, 3);
}
});
}
});
break;
case "1w":
currency.updateHistoryHours(this, new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
runOnUiThread(new Runnable() {
@Override
public void run() {
drawChart(CurrencyDetailsActivity.WEEK, 1);
}
});
}
});
break;
case "1M":
currency.updateHistoryDays(this, new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
runOnUiThread(new Runnable() {
@Override
public void run() {
drawChart(CurrencyDetailsActivity.MONTH, 1);
}
});
}
});
break;
case "3M":
currency.updateHistoryDays(this, new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
runOnUiThread(new Runnable() {
@Override
public void run() {
drawChart(CurrencyDetailsActivity.MONTH, 3);
}
});
}
});
break;
case "6M":
currency.updateHistoryDays(this, new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
runOnUiThread(new Runnable() {
@Override
public void run() {
drawChart(CurrencyDetailsActivity.MONTH, 6);
}
});
}
});
break;
case "1y":
currency.updateHistoryDays(this, new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
runOnUiThread(new Runnable() {
@Override
public void run() {
drawChart(CurrencyDetailsActivity.YEAR, 1);
}
});
}
});
break;
}
}
private void drawChart(int timeUnit, int amount)
{
final LineChartView chartView = findViewById(R.id.chartView);
LineSet lineSet = generateChartSet(timeUnit, amount);
float valMin = lineSet.getMin().getValue();
float valMax = lineSet.getMax().getValue();
int indexMinValue;
int indexMaxValue;
for(int i = 0; i < lineSet.size(); i++)
{
if(lineSet.getEntry(i).getValue() == valMin)
{
indexMinValue = i;
}
if(lineSet.getEntry(i).getValue() == valMax)
{
indexMaxValue = i;
}
}
chartView.reset();
chartView.setAxisBorderValues((float) valMin, (float) valMax);
chartView.setYLabels(AxisRenderer.LabelPosition.NONE);
chartView.setYAxis(false);
chartView.setXAxis(false);
for(int i = 0; i < dataChartList.size(); i+=10)
chartView.addData(lineSet);
chartView.setFadingEdgeLength(15);
chartView.setLongClickable(true);
findViewById(R.id.chartView).setVisibility(View.VISIBLE);
findViewById(R.id.progressLayoutChart).setVisibility(View.GONE);
//chartView.show(new Animation().fromAlpha(0).withEndAction(launchAction));
chartView.show(new Animation().fromAlpha(0));
}
private LineSet generateChartSet(int timeUnit, int amount)
{
if(counter == 30)
List<CurrencyDataChart> dataChartList = new ArrayList<>();
LineSet lineSet = new LineSet();
int counter = 0;
Calendar calendar = Calendar.getInstance(Locale.FRANCE);
String hour;
String minute;
String dayName = "";
String dayNumber;
String monthName = "";
String monthNumber;
int offset = 10;
int pointFormat = HOUR;
switch (timeUnit)
{
case HOUR:
dataChartList = currency.getHistoryMinutes().subList(currency.getHistoryMinutes().size()-(60*amount), currency.getHistoryMinutes().size());
offset = 10 * amount;
pointFormat = HOUR;
break;
case DAY:
if(amount == 1)
{
dataChartList = currency.getHistoryMinutes();
offset = 10 * 24;
pointFormat = HOUR;
}
else
{
dataChartList = currency.getHistoryHours().subList(currency.getHistoryHours().size()-(24*amount), currency.getHistoryHours().size());
offset = 24;
pointFormat = DAY;
}
break;
case WEEK:
dataChartList = currency.getHistoryHours().subList(currency.getHistoryHours().size()-168, currency.getHistoryHours().size());
offset = 28;
pointFormat = DAY;
break;
case MONTH:
switch (amount)
{
case 1:
dataChartList = currency.getHistoryHours();
offset = 124;
pointFormat = MONTH;
break;
case 3:
dataChartList = currency.getHistoryDays().subList(currency.getHistoryDays().size()-93, currency.getHistoryDays().size());
offset = 15;
pointFormat = MONTH;
break;
case 6:
dataChartList = currency.getHistoryDays().subList(currency.getHistoryDays().size()-186, currency.getHistoryDays().size());
offset = 31;
pointFormat = MONTH;
break;
}
break;
case YEAR:
dataChartList = currency.getHistoryDays();
offset = 30;
pointFormat = YEAR;
break;
}
for(int i = 0; i < dataChartList.size(); i++)
{
if(counter == offset)
{
calendar.setTimeInMillis(dataChartList.get(i).getTimestamp()*1000);
switch (pointFormat)
{
case HOUR:
hour = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY));
minute = String.valueOf(calendar.get(Calendar.MINUTE));
@ -195,6 +395,99 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
}
lineSet.addPoint(hour + ":" + minute, (float) dataChartList.get(i).getOpen());
break;
case DAY:
int dayIndex = calendar.get(Calendar.DAY_OF_WEEK)+1;
switch (dayIndex)
{
case Calendar.MONDAY:
dayName = "Mon";
break;
case Calendar.TUESDAY:
dayName = "Tue";
break;
case Calendar.WEDNESDAY:
dayName = "Wed";
break;
case Calendar.THURSDAY:
dayName = "Thu";
break;
case Calendar.FRIDAY:
dayName = "Fri";
break;
case Calendar.SATURDAY:
dayName = "Sat";
break;
case Calendar.SUNDAY:
dayName = "Sun";
break;
}
lineSet.addPoint(dayName, (float) dataChartList.get(i).getOpen());
break;
case MONTH:
dayNumber = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)+1);
monthNumber = String.valueOf(calendar.get(Calendar.MONTH)+1);
if(dayNumber.length() < 2)
{
dayNumber = '0' + dayNumber;
}
if(monthNumber.length() < 2)
{
monthNumber = '0' + monthNumber;
}
lineSet.addPoint(dayNumber + "/" + monthNumber, (float) dataChartList.get(i).getOpen());
break;
case YEAR:
int mb = calendar.get(Calendar.MONTH);
switch (mb)
{
case Calendar.JANUARY:
monthName = "Jan";
break;
case Calendar.FEBRUARY:
monthName = "Feb";
break;
case Calendar.MARCH:
monthName = "Mar";
break;
case Calendar.APRIL:
monthName = "Apr";
break;
case Calendar.MAY:
monthName = "May";
break;
case Calendar.JUNE:
monthName = "Jun";
break;
case Calendar.JULY:
monthName = "Jul";
break;
case Calendar.AUGUST:
monthName = "Aug";
break;
case Calendar.SEPTEMBER:
monthName = "Sep";
break;
case Calendar.OCTOBER:
monthName = "Oct";
break;
case Calendar.NOVEMBER:
monthName = "Nov";
break;
case Calendar.DECEMBER:
monthName = "Dec";
break;
}
lineSet.addPoint(monthName, (float) dataChartList.get(i).getOpen());
break;
}
counter = 0;
}
else
@ -205,52 +498,11 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
}
lineSet.setSmooth(true);
lineSet.setThickness(4);
lineSet.setThickness(3);
lineSet.setFill(getColorWitchAlpha(currency.getChartColor(), 0.5f));
lineSet.setColor(currency.getChartColor());
final LinearLayout.LayoutParams chartParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 500);
chartParams.setMargins(0, 15, 0, 15);
chartView.setLayoutParams(chartParams);
tip = new Tooltip(this, R.layout.tooltip_layout, R.id.value);
RelativeLayout.LayoutParams tipParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
tip.setLayoutParams(tipParams);
tip.setVerticalAlignment(Tooltip.Alignment.BOTTOM_TOP);
tip.setDimensions((int) Tools.fromDpToPx(75), (int) Tools.fromDpToPx(25));
tip.setClickable(false);
/*tip.setVerticalAlignment(Tooltip.Alignment.CENTER);
tip.setHorizontalAlignment(Tooltip.Alignment.CENTER);
tip.setDimensions((int) Tools.fromDpToPx(4), (int) Tools.fromDpToPx(4));
tip.setClickable(false);*/
final Tooltip tip2 = tip;
chartView.addData(lineSet);
chartView.setFadingEdgeLength(15);
chartView.setLongClickable(true);
//tip.prepare(chartView.getEntriesArea(0).get(0), (float) dataChartList.get(0).getOpen());
chartView.setTooltips(tip);
chartView.setTooltips(tip2);
Runnable launchAction = new Runnable() {
@Override
public void run() {
tip.prepare(chartView.getEntriesArea(0).get((int) indexMin/10), (float) dataChartList.get(indexMin).getOpen());
tip2.prepare(chartView.getEntriesArea(0).get((int) indexMax/10), (float) dataChartList.get(indexMax).getOpen());
chartView.showTooltip(tip, true);
//chartView.showTooltip(tip2, true);
}
};
chartView.show(new Animation().fromAlpha(0).withEndAction(launchAction));
chartLayout.addView(chartView);
return lineSet;
}
private int getColorWitchAlpha(int color, float ratio)
@ -337,34 +589,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
transactionLayout.addView(view);
}
//final ArrayAdapter<HashMap<Integer, Double>> transactionAdapter = new ArrayAdapter<HashMap<Integer, Double>>(CurrencyDetailsActivity.this, android.R.layout.simple_list_item_1, transactionList);
/*Iterator transactionsIterator = transactionList.keySet().iterator();
transactionList.se
while(transactionsIterator.hasNext())
{
final TextView txtView = new TextView(this);
Integer key = (Integer) transactionsIterator.next();
txtView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
txtView.setTag(key);
txtView.setText("Amount : " + transactionList.get(key));
txtView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TextView thisTxtView = (TextView) view;
databaseManager.deleteTransactionFromId(Integer.parseInt(thisTxtView.getTag().toString()));
Log.d(CurrencyDetailsActivity.this.getResources().getString(R.string.debug), "Id : " + thisTxtView.getTag());
drawTransactionList();
}
});
transactionLayout.addView(txtView);
}*/
}
}

View File

@ -4,7 +4,6 @@ import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Icon;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@ -16,7 +15,6 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.graphics.Palette;
import android.support.v7.widget.CardView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.Menu;
@ -24,17 +22,13 @@ import android.view.MenuItem;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.daimajia.swipe.SwipeLayout;
import com.db.chart.view.LineChartView;
import com.nauk.coinfolio.DataManagers.BalanceManager;
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
import com.nauk.coinfolio.DataManagers.DatabaseManager;
import com.nauk.coinfolio.LayoutManagers.HomeLayoutGenerator;
import com.nauk.coinfolio.DataManagers.PreferencesManager;
import com.nauk.coinfolio.R;
@ -50,28 +44,28 @@ import java.util.List;
//Auto refresh with predefined intervals
//Adding manually currencies (date, purchased price)
//Multiple portfolio (exchanges & custom)
//Add currency details (market cap, 1h, 3h, 3d, 1w, 1m, 3m, 1y)
//Add currency details (market cap, 1h, 3h, 1d, 3d, 1w, 1m, 3m, 1y)
//Add roadmap to buy a coin
//Add reddit link ?
//
public class HomeActivity extends AppCompatActivity {
private PreferencesManager preferencesManager;
private HomeLayoutGenerator layoutGenerator;
private BalanceManager balanceManager;
private int coinCounter;
private int iconCounter;
private HomeLayoutGenerator layoutGenerator;
private LinearLayout currencyLayout;
private Toolbar toolbar;
private long lastTimestamp;
private boolean detailsChecker;
private boolean isDetailed;
private CollapsingToolbarLayout toolbarLayout;
private SwipeRefreshLayout refreshLayout;
private LinearLayout currencyLayout;
private TextView toolbarSubtitle;
private boolean view;
private Dialog loadingDialog;
private boolean iconChecker;
private PreferencesManager preferencesManager;
private DatabaseManager databaseManager;
private long lastTimestamp;
private Handler handler;
private Runnable updateRunnable;
@ -79,27 +73,52 @@ public class HomeActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/**Interface setup**/
//Setup main interface
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_currency_summary);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
preferencesManager = new PreferencesManager(this);
view = preferencesManager.getDetailOption();
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
generateSplash();
//Objects initializatoin
preferencesManager = new PreferencesManager(this);
layoutGenerator = new HomeLayoutGenerator(this);
balanceManager = new BalanceManager(this);
handler = new Handler();
updateRunnable = new Runnable() {
@Override
public void run() {
if (refreshLayout.isRefreshing())
{
refreshLayout.setRefreshing(false);
showErrorSnackbar();
}
if (loadingDialog.isShowing())
{
loadingDialog.dismiss();
showErrorSnackbar();
}
}
};
isDetailed = preferencesManager.getDetailOption();
//Layouts setup
refreshLayout = findViewById(R.id.swiperefresh);
toolbarLayout = findViewById(R.id.toolbar_layout);
toolbarSubtitle = findViewById(R.id.toolbarSubtitle);
currencyLayout = findViewById(R.id.currencyListLayout);
ImageButton addCurrencyButton = findViewById(R.id.addCurrencyButton);
ImageButton detailsButton = findViewById(R.id.switch_button);
ImageButton settingsButton = findViewById(R.id.settings_button);
refreshLayout = findViewById(R.id.swiperefresh);
toolbarLayout = findViewById(R.id.toolbar_layout);
toolbarSubtitle = findViewById(R.id.toolbarSubtitle);
toolbarLayout.setExpandedTitleGravity(Gravity.CENTER);
toolbarLayout.setCollapsedTitleGravity(Gravity.CENTER);
toolbarLayout.setForegroundGravity(Gravity.CENTER);
@ -107,6 +126,7 @@ public class HomeActivity extends AppCompatActivity {
toolbarSubtitle.setText("US$0.00");
//Events setup
detailsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -123,12 +143,6 @@ public class HomeActivity extends AppCompatActivity {
}
});
layoutGenerator = new HomeLayoutGenerator(this);
balanceManager = new BalanceManager(this);
currencyLayout = findViewById(R.id.currencyListLayout);
refreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
@ -138,8 +152,6 @@ public class HomeActivity extends AppCompatActivity {
}
);
final ImageButton addCurrencyButton = findViewById(R.id.addCurrencyButton);
addCurrencyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -154,55 +166,26 @@ public class HomeActivity extends AppCompatActivity {
addIntent.putExtra("currencyListNames", nameList);
startActivity(addIntent);
/*Snackbar.make(findViewById(R.id.currencyListLayout), "This feature is not yet available...", Snackbar.LENGTH_LONG)
.show();*/
}
});
databaseManager = new DatabaseManager(this);
handler = new Handler();
updateRunnable = new Runnable() {
@Override
public void run() {
if (refreshLayout.isRefreshing())
{
refreshLayout.setRefreshing(false);
Snackbar.make(findViewById(R.id.currencyListLayout), "Error while updating data", Snackbar.LENGTH_LONG)
.setAction("Update", new View.OnClickListener() {
@Override
public void onClick(View view) {
updateAll(true);
}
})
.show();
}
if (loadingDialog.isShowing())
{
loadingDialog.dismiss();
Snackbar.make(findViewById(R.id.currencyListLayout), "Error while updating data", Snackbar.LENGTH_LONG)
.setAction("Update", new View.OnClickListener() {
@Override
public void onClick(View view) {
updateAll(true);
}
})
.show();
}
}
};
updateViewButtonIcon();
lastTimestamp = 0;
}
private void showErrorSnackbar()
{
Snackbar.make(findViewById(R.id.currencyListLayout), "Error while updating data", Snackbar.LENGTH_LONG)
.setAction("Update", new View.OnClickListener() {
@Override
public void onClick(View view) {
updateAll(true);
}
})
.show();
}
@Override
protected void onResume() {
super.onResume();
@ -210,13 +193,6 @@ public class HomeActivity extends AppCompatActivity {
Intent intent = getIntent();
updateAll(intent.getBooleanExtra("update", false));
/*if(System.currentTimeMillis()/1000 - lastTimestamp > 60 || intent.getBooleanExtra("update", false))
{
lastTimestamp = System.currentTimeMillis()/1000;
updateAll();
}*/
}
@Override
@ -245,15 +221,15 @@ public class HomeActivity extends AppCompatActivity {
private void switchView()
{
if(!view)
if(isDetailed)
{
view = true;
isDetailed = false;
adaptView();
}
else
{
view = false;
isDetailed = true;
adaptView();
}
@ -261,31 +237,28 @@ public class HomeActivity extends AppCompatActivity {
private void adaptView()
{
if(!view)
{
for(int i = 0; i < currencyLayout.getChildCount(); i++)
{
currencyLayout.getChildAt(i).findViewWithTag("chart_layout").setVisibility(View.GONE);
currencyLayout.getChildAt(i).findViewWithTag("separator_layout").setVisibility(View.GONE);
}
}
else
if(isDetailed)
{
currencyLayout.removeAllViews();
//layoutGenerator.setCurrencyList(balanceManager.getTotalBalance());
//layoutGenerator.resetCurrencyList();
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()) > 0.001 || currency.getDayPriceHistory() == null))
if(!currency.getSymbol().equals("USD") && ((currency.getBalance() * currency.getValue()) > 0.001 || currency.getHistoryMinutes() == null))
{
currencyLayout.addView(layoutGenerator.getInfoLayout(currency));
}
}
}
else
{
for(int i = 0; i < currencyLayout.getChildCount(); i++)
{
currencyLayout.getChildAt(i).findViewWithTag("chart_layout").setVisibility(View.GONE);
currencyLayout.getChildAt(i).findViewWithTag("separator_layout").setVisibility(View.GONE);
}
}
updateViewButtonIcon();
}
@ -297,11 +270,12 @@ public class HomeActivity extends AppCompatActivity {
if(System.currentTimeMillis()/1000 - lastTimestamp > 60 || mustUpdate)
{
lastTimestamp = System.currentTimeMillis() / 1000;
resetCounter();
balanceManager.updateExchangeKeys();
refreshLayout.setRefreshing(true);
resetCounters();
DataUpdater updater = new DataUpdater();
updater.execute();
refreshLayout.setRefreshing(true);
handler.postDelayed(updateRunnable, 10000);
}
@ -314,11 +288,11 @@ public class HomeActivity extends AppCompatActivity {
}
}
private void resetCounter()
private void resetCounters()
{
coinCounter = 0;
iconCounter = 0;
iconChecker = false;
detailsChecker = false;
}
private void getBitmapFromURL(String src, IconCallBack callBack) {
@ -344,11 +318,11 @@ public class HomeActivity extends AppCompatActivity {
{
iconCounter++;
if(iconCounter == balanceManager.getTotalBalance().size() - 1)
{
if(balanceManager.getTotalBalance() != null)
{
if(coinCounter == balanceManager.getTotalBalance().size() - 1 && iconChecker)
if(iconCounter == balanceManager.getTotalBalance().size() - 1)
{
if(coinCounter == balanceManager.getTotalBalance().size() - 1 && detailsChecker)
{
UiHeavyLoadCalculator uiHeavyLoadCalculator = new UiHeavyLoadCalculator();
uiHeavyLoadCalculator.execute();
@ -356,29 +330,10 @@ public class HomeActivity extends AppCompatActivity {
if(balanceManager.getTotalBalance().size() == 0)
{
refreshLayout.setRefreshing(false);
currencyLayout.removeAllViews();
if(loadingDialog.isShowing())
{
loadingDialog.dismiss();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
toolbarLayout.setTitle("US$0.00");
toolbarSubtitle.setText("US$0.00");
toolbarSubtitle.setTextColor(-1275068417);
}
});
updateNoBalance();
}
}
}
else
/*else
{
if(balanceManager.getTotalBalance().size() == 0)
{
@ -402,9 +357,33 @@ public class HomeActivity extends AppCompatActivity {
}
});
}
}*/
}
}
private void updateNoBalance()
{
refreshLayout.setRefreshing(false);
currencyLayout.removeAllViews();
if(loadingDialog.isShowing())
{
loadingDialog.dismiss();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
toolbarLayout.setTitle("US$0.00");
toolbarSubtitle.setText("US$0.00");
toolbarSubtitle.setTextColor(-1275068417);
}
});
}
private void countCoins(boolean isCoin, boolean isDetails)
{
if(isCoin)
@ -414,7 +393,7 @@ public class HomeActivity extends AppCompatActivity {
if(isDetails)
{
iconChecker = true;
detailsChecker = true;
}
if(balanceManager.getTotalBalance() != null)
@ -423,14 +402,14 @@ public class HomeActivity extends AppCompatActivity {
{
for (int i = 0; i < balanceManager.getTotalBalance().size(); i++)
{
final int index = i;
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
if(balanceManager.getIconUrl(balanceManager.getTotalBalance().get(i).getSymbol()) != null)
if(balanceManager.getIconUrl(localCurrency.getSymbol()) != null)
{
getBitmapFromURL(balanceManager.getIconUrl(balanceManager.getTotalBalance().get(i).getSymbol()), new IconCallBack() {
getBitmapFromURL(balanceManager.getIconUrl(localCurrency.getSymbol()), new IconCallBack() {
@Override
public void onSuccess(Bitmap bitmapIcon) {
balanceManager.getTotalBalance().get(index).setIcon(bitmapIcon);
localCurrency.setIcon(bitmapIcon);
countIcons();
}
});
@ -451,7 +430,7 @@ public class HomeActivity extends AppCompatActivity {
{
ImageButton imgButton = findViewById(R.id.switch_button);
if(view)
if(isDetailed)
{
imgButton.setBackground(this.getResources().getDrawable(R.drawable.ic_unfold_less_black_24dp));
preferencesManager.setDetailOption(true);
@ -521,28 +500,19 @@ public class HomeActivity extends AppCompatActivity {
balanceManager.sortCoins();
//layoutGenerator.setCurrencyList(balanceManager.getTotalBalance());
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
{
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
if(localCurrency.getIcon() != null)
{
//balanceManager.getTotalBalance().get(i).setIcon(getBitmapFromURL(balanceManager.getIconUrl(balanceManager.getTotalBalance().get(i).getSymbol())));
Palette.Builder builder = Palette.from(localCurrency.getIcon());
localCurrency.setChartColor(builder.generate().getDominantColor(0));
//layoutGenerator.addCurrencyToList(currency);
//currencyLayout.addView(layoutGenerator.getInfoLayout(i));
}
else
{
//currency.setChartColor(12369084);
localCurrency.setChartColor(12369084);
//currencyLayout.addView(layoutGenerator.getInfoLayout(i));
}
if(!localCurrency.getSymbol().equals("USD") && (localCurrency.getBalance() * localCurrency.getValue()) > 0.001)
@ -551,17 +521,12 @@ public class HomeActivity extends AppCompatActivity {
localCurrency.setId(balanceManager.getCurrencyId(localCurrency.getSymbol()));
totalValue += localCurrency.getValue() * localCurrency.getBalance();
totalFluctuation += (localCurrency.getValue() * localCurrency.getBalance()) * (localCurrency.getDayFluctuationPercentage() / 100);
//balanceManager.getTotalBalance().get(i).setIcon(getBitmapFromURL(balanceManager.getIconUrl(balanceManager.getTotalBalance().get(i).getSymbol())));
//currencyLayout.addView(layoutGenerator.getInfoLayout(i));
cardList.add(layoutGenerator.getInfoLayout(localCurrency));
}
if(!localCurrency.getSymbol().equals("USD") && localCurrency.getDayPriceHistory() == null)
if(!localCurrency.getSymbol().equals("USD") && localCurrency.getHistoryMinutes() == null)
{
//balanceManager.getTotalBalance().get(i).setIcon(getBitmapFromURL(balanceManager.getIconUrl(balanceManager.getTotalBalance().get(i).getSymbol())));
//currencyLayout.addView(layoutGenerator.getInfoLayout(i));
cardList.add(layoutGenerator.getInfoLayout(localCurrency));
}
@ -656,7 +621,7 @@ public class HomeActivity extends AppCompatActivity {
{
for(int i = 0; i < balanceManager.getTotalBalance().size(); i++)
{
balance.get(i).updateDayPriceHistory(getApplicationContext(), new Currency.CurrencyCallBack() {
balance.get(i).updateHistoryMinutes(getApplicationContext(), new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
countCoins(true, false);

View File

@ -3,6 +3,7 @@ package com.nauk.coinfolio.DataManagers.CurrencyData;
import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
@ -22,8 +23,10 @@ public class Currency implements Parcelable {
private double balance;
private float dayFluctuationPercentage;
private double dayFluctuation;
private List<CurrencyDataChart> dayPriceHistory;
private CurrencyDataRetriver dataRetriver;
private List<CurrencyDataChart> historyMinutes;
private List<CurrencyDataChart> historyHours;
private List<CurrencyDataChart> historyDays;
private CurrencyDataRetriever dataRetriver;
private Bitmap icon;
private int chartColor;
@ -36,7 +39,7 @@ public class Currency implements Parcelable {
this.balance = currency.balance;
this.dayFluctuationPercentage = currency.getDayFluctuationPercentage();
this.dayFluctuation = currency.getDayFluctuation();
this.dayPriceHistory = currency.dayPriceHistory;
this.historyMinutes = currency.historyMinutes;
this.dataRetriver = currency.getDataRetriver();
this.icon = currency.icon;
this.chartColor = currency.chartColor;
@ -61,13 +64,13 @@ public class Currency implements Parcelable {
this.symbol = symbol;
}
public void updateDayPriceHistory(android.content.Context context, final CurrencyCallBack callBack)
public void updateHistoryMinutes(android.content.Context context, final CurrencyCallBack callBack)
{
dataRetriver = new CurrencyDataRetriver(context);
dataRetriver.updateLastDayHistory(symbol, new CurrencyDataRetriver.DataChartCallBack() {
dataRetriver = new CurrencyDataRetriever(context);
dataRetriver.updateHistory(symbol, new CurrencyDataRetriever.DataChartCallBack() {
@Override
public void onSuccess(List<CurrencyDataChart> dataChart) {
setDayPriceHistory(dataChart);
setHistoryMinutes(dataChart);
updateDayFluctuation();
if(dataChart != null)
@ -81,27 +84,33 @@ public class Currency implements Parcelable {
callBack.onSuccess(Currency.this);
}
});
}, CurrencyDataRetriever.MINUTES);
}
public void updateName(android.content.Context context, final CurrencyCallBack callBack)
public void updateHistoryHours(android.content.Context context, final CurrencyCallBack callBack)
{
dataRetriver = new CurrencyDataRetriver(context);
dataRetriver.updateCurrencyName(symbol, new CurrencyDataRetriver.NameCallBack() {
dataRetriver = new CurrencyDataRetriever(context);
dataRetriver.updateHistory(symbol, new CurrencyDataRetriever.DataChartCallBack() {
@Override
public void onSuccess(String name) {
if(name != null)
{
setName(name);
}
else
{
setName("NameNotFound");
}
public void onSuccess(List<CurrencyDataChart> dataChart) {
setHistoryHours(dataChart);
callBack.onSuccess(Currency.this);
}
});
}, CurrencyDataRetriever.HOURS);
}
public void updateHistoryDays(android.content.Context context, final CurrencyCallBack callBack)
{
dataRetriver = new CurrencyDataRetriever(context);
dataRetriver.updateHistory(symbol, new CurrencyDataRetriever.DataChartCallBack() {
@Override
public void onSuccess(List<CurrencyDataChart> dataChart) {
setHistoryDays(dataChart);
callBack.onSuccess(Currency.this);
}
}, CurrencyDataRetriever.DAYS);
}
public void setId(int id)
@ -124,14 +133,24 @@ public class Currency implements Parcelable {
return chartColor;
}
public CurrencyDataRetriver getDataRetriver()
public CurrencyDataRetriever getDataRetriver()
{
return dataRetriver;
}
public List<CurrencyDataChart> getDayPriceHistory()
public List<CurrencyDataChart> getHistoryMinutes()
{
return dayPriceHistory;
return historyMinutes;
}
public List<CurrencyDataChart> getHistoryHours()
{
return historyHours;
}
public List<CurrencyDataChart> getHistoryDays()
{
return historyDays;
}
public String getName()
@ -179,9 +198,19 @@ public class Currency implements Parcelable {
balance = newBalance;
}
private void setDayPriceHistory(List<CurrencyDataChart> newDataChart)
private void setHistoryMinutes(List<CurrencyDataChart> newDataChart)
{
dayPriceHistory = newDataChart;
historyMinutes = newDataChart;
}
private void setHistoryHours(List<CurrencyDataChart> newDataChart)
{
historyHours = newDataChart;
}
private void setHistoryDays(List<CurrencyDataChart> newDataChart)
{
historyDays = newDataChart;
}
public void setIcon(Bitmap newIcon)
@ -196,11 +225,11 @@ public class Currency implements Parcelable {
private void updateDayFluctuation()
{
if(dayPriceHistory != null)
if(historyMinutes != null)
{
dayFluctuation = dayPriceHistory.get(dayPriceHistory.size() - 1).getOpen() - dayPriceHistory.get(0).getOpen();
dayFluctuation = historyMinutes.get(historyMinutes.size() - 1).getOpen() - historyMinutes.get(0).getOpen();
dayFluctuationPercentage = (float) (dayFluctuation / dayPriceHistory.get(0).getOpen() * 100);
dayFluctuationPercentage = (float) (dayFluctuation / historyMinutes.get(0).getOpen() * 100);
}
}
@ -223,7 +252,7 @@ public class Currency implements Parcelable {
dest.writeDouble(this.balance);
dest.writeFloat(this.dayFluctuationPercentage);
dest.writeDouble(this.dayFluctuation);
dest.writeList(this.dayPriceHistory);
dest.writeList(this.historyMinutes);
dest.writeParcelable(this.icon, flags);
dest.writeInt(this.chartColor);
}
@ -236,8 +265,8 @@ public class Currency implements Parcelable {
this.balance = in.readDouble();
this.dayFluctuationPercentage = in.readFloat();
this.dayFluctuation = in.readDouble();
this.dayPriceHistory = new ArrayList<CurrencyDataChart>();
in.readList(this.dayPriceHistory, CurrencyDataChart.class.getClassLoader());
this.historyMinutes = new ArrayList<CurrencyDataChart>();
in.readList(this.historyMinutes, CurrencyDataChart.class.getClassLoader());
this.icon = in.readParcelable(Bitmap.class.getClassLoader());
this.chartColor = in.readInt();
}

View File

@ -0,0 +1,134 @@
package com.nauk.coinfolio.DataManagers.CurrencyData;
import android.util.Log;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.nauk.coinfolio.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
/**
* Created by Tiji on 05/01/2018.
*/
public class CurrencyDataRetriever {
final static int MINUTES = 0;
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 RequestQueue requestQueue;
protected android.content.Context context;
CurrencyDataRetriever(android.content.Context context)
{
this.context = context;
requestQueue = Volley.newRequestQueue(context);
}
private void updateHistory(String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack, int timeUnit)
{
String requestUrl = null;
switch (timeUnit)
{
case MINUTES:
requestUrl = minuteHistoryUrl + "?fsym=" + symbolCurrencyFrom + "&tsym=" + symbolCyrrencyTo + "&limit=1440";
break;
case HOURS:
requestUrl = hourHistoryUrl + "?fsym=" + symbolCurrencyFrom + "&tsym=" + symbolCyrrencyTo + "&limit=744";
break;
case DAYS:
requestUrl = dayHistoryUrl + "?fsym=" + symbolCurrencyFrom + "&tsym=" + symbolCyrrencyTo + "&limit=365";
break;
}
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
callBack.onSuccess(processHistoryResult(response));
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
callBack.onSuccess(null);
}
});
requestQueue.add(stringRequest);
}
private List<CurrencyDataChart> processHistoryResult(String response)
{
List<CurrencyDataChart> dataChart = new ArrayList<>();
if(response.length() > 200)
{
response = response.substring(response.indexOf("Data\":[{") + 7, response.lastIndexOf("}],\"TimeTo"));
String[] tab = response.split(Pattern.quote("},{"));
for(int i = 0; i < tab.length; i++)
{
if(i == 0)
{
tab[i] = tab[i] + "}";
}
else
{
tab[i] = "{" + tab[i] + "}";
}
try {
JSONObject jsonObject = new JSONObject(tab[i]);
long timestamp = Long.parseLong(jsonObject.getString("time"));
double close = Double.parseDouble(jsonObject.getString("close"));
double high = Double.parseDouble(jsonObject.getString("high"));
double low = Double.parseDouble(jsonObject.getString("low"));
double open = Double.parseDouble(jsonObject.getString("open"));
dataChart.add(new CurrencyDataChart(timestamp, close, high, low, open));
} catch (JSONException e) {
Log.d(context.getResources().getString(R.string.debug_volley), "API Request error: " + e + " index: " + i);
}
}
}
else
{
dataChart = null;
}
return dataChart;
}
void updateHistory(String symbolCurrencyFrom, final DataChartCallBack callBack, int timeUnit)
{
if(!symbolCurrencyFrom.equals("USD"))
{
updateHistory(symbolCurrencyFrom, "USD", callBack, timeUnit);
}
}
public interface DataChartCallBack {
void onSuccess(List<CurrencyDataChart> dataChart);
}
}

View File

@ -1,181 +0,0 @@
package com.nauk.coinfolio.DataManagers.CurrencyData;
import android.util.Log;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.nauk.coinfolio.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
/**
* Created by Tiji on 05/01/2018.
*/
public class CurrencyDataRetriver {
String minuteHistoryUrl = "https://min-api.cryptocompare.com/data/histominute";
String hourHistoryUrl = "https://min-api.cryptocompare.com/data/histohour";
String dayHistoryUrl = "https://min-api.cryptocompare.com/data/histoday";
String nameUrl = "https://api.hitbtc.com/api/2/public/currency/";
RequestQueue requestQueue;
android.content.Context context;
public CurrencyDataRetriver(android.content.Context context)
{
this.context = context;
requestQueue = Volley.newRequestQueue(context);
}
public void updateLastHourHistory(String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack)
{
final String requestUrl = minuteHistoryUrl + "?fsym=" + symbolCurrencyFrom + "&tsym=" + symbolCyrrencyTo + "&limit=60";
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
callBack.onSuccess(processHourResult(response));
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue.add(stringRequest);
}
public void updateCurrencyName(String symbol, final NameCallBack callBack)
{
final String requestUrl = nameUrl + symbol;
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
response = response.substring(response.indexOf(",") + 13);
response = response.substring(0, response.indexOf(",") - 1);
callBack.onSuccess(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
callBack.onSuccess(null);
}
});
requestQueue.add(stringRequest);
}
public void updateLastDayHistory(String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack)
{
final String requestUrl = minuteHistoryUrl + "?fsym=" + symbolCurrencyFrom + "&tsym=" + symbolCyrrencyTo + "&limit=1440";
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
callBack.onSuccess(processHourResult(response));
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
callBack.onSuccess(null);
}
});
requestQueue.add(stringRequest);
}
private List<CurrencyDataChart> processHourResult(String response)
{
List<CurrencyDataChart> dataChart = new ArrayList<>();
if(response.length() > 200)
{
response = response.substring(response.indexOf("Data\":[{") + 7, response.lastIndexOf("}],\"TimeTo"));
String[] tab = response.split(Pattern.quote("},{"));
for(int i = 0; i < tab.length; i++)
{
if(i == 0)
{
tab[i] = tab[i] + "}";
}
else
{
tab[i] = "{" + tab[i] + "}";
}
try {
JSONObject jsonObject = new JSONObject(tab[i]);
long timestamp = Long.parseLong(jsonObject.getString("time"));
double close = Double.parseDouble(jsonObject.getString("close"));
double high = Double.parseDouble(jsonObject.getString("high"));
double low = Double.parseDouble(jsonObject.getString("low"));
double open = Double.parseDouble(jsonObject.getString("open"));
dataChart.add(new CurrencyDataChart(timestamp, close, high, low, open));
} catch (JSONException e) {
Log.d(context.getResources().getString(R.string.debug_volley), "API Request error: " + e + " index: " + i);
}
}
}
else
{
/*for(int i = 1; i <= 1440; i++)
{
dataChart.add(new CurrencyDataChart(i, 1, 1, 1, 1));
}*/
dataChart = null;
}
return dataChart;
}
public void updateLastHourHistory(String symbolCurrencyFrom, final DataChartCallBack callBack)
{
updateLastHourHistory(symbolCurrencyFrom, "USD", callBack);
}
public void updateLastDayHistory(String symbolCurrencyFrom, final DataChartCallBack callBack)
{
if(!symbolCurrencyFrom.equals("USD"))
{
updateLastDayHistory(symbolCurrencyFrom, "USD", callBack);
}
}
public interface DataChartCallBack {
void onSuccess(List<CurrencyDataChart> dataChart);
}
public interface CurrencyDetailCallBack {
void onSuccess();
}
public interface NameCallBack {
void onSuccess(String name);
}
}

View File

@ -6,27 +6,21 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.CardView;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.db.chart.model.LineSet;
import com.db.chart.model.Point;
import com.db.chart.renderer.AxisRenderer;
import com.db.chart.view.LineChartView;
import com.nauk.coinfolio.Activities.CurrencyDetailsActivity;
import com.nauk.coinfolio.Activities.HomeActivity;
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
import com.nauk.coinfolio.R;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
@ -184,9 +178,9 @@ public class HomeLayoutGenerator {
{
View toReturn;
if(currency.getDayPriceHistory() != null)
if(currency.getHistoryMinutes() != null)
{
LineChartView lineChartView = chartGenerator(currency.getDayPriceHistory(), currency.getChartColor());
LineChartView lineChartView = chartGenerator(currency.getHistoryMinutes(), currency.getChartColor());
chartLayout.setTag("chart_layout");
chartLayout.addView(lineChartView);
lineChartView.show();

View File

@ -18,6 +18,102 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/progressLayoutChart"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="15dp"
android:visibility="gone"
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleLarge"
android:layout_gravity="center"
android:background="@drawable/circular_progress_bar"/>
</LinearLayout>
<com.db.chart.view.LineChartView
android:id="@+id/chartView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="15dp" />
<LinearLayout
android:id="@+id/layoutChartButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:text="@string/button1h"/>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:text="@string/button3h"/>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:enabled="false"
android:text="@string/button1d"/>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:text="@string/button3d"/>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:text="@string/button1w"/>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:text="@string/button1m"/>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:text="@string/button3m"/>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:text="@string/button6m"/>
<Button
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="11.1"
android:text="@string/button1y"/>
</LinearLayout>
<ScrollView
android:id="@+id/svCharts"
android:layout_width="match_parent"

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corners"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<TextView
@ -12,5 +11,12 @@
android:layout_centerVertical="true"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="16sp"/>
android:textSize="16sp"
android:background="@drawable/rounded_corners" />
<Space
android:id="@+id/separationLine"
android:layout_width="3dp"
android:layout_height="match_parent" />
</RelativeLayout>

View File

@ -120,4 +120,15 @@
<string name="title_charts">Charts</string>
<string name="title_infos">Infos</string>
<string name="title_transactions">Transactions</string>
<!--Chart buttons texts-->
<string name="button1h">1h</string>
<string name="button3h">3h</string>
<string name="button1d">1d</string>
<string name="button3d">3d</string>
<string name="button1w">1w</string>
<string name="button1m">1M</string>
<string name="button3m">3M</string>
<string name="button6m">6M</string>
<string name="button1y">1y</string>
</resources>