diff --git a/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Watchlist.java b/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Watchlist.java index 940f48d..0b6c332 100644 --- a/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Watchlist.java +++ b/app/src/main/java/com/nauk/moodl/Activities/HomeActivityFragments/Watchlist.java @@ -271,45 +271,6 @@ public class Watchlist extends Fragment { } } - private LineData generateData(Currency currency) - { - LineDataSet dataSet; - List dataChartList = currency.getHistoryMinutes(); - ArrayList 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 ; - } - private String getIconUrl(String symbol) { String url; diff --git a/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/Currency.java b/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/Currency.java index 4258b1b..bb3e4c6 100644 --- a/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/Currency.java +++ b/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/Currency.java @@ -1,8 +1,10 @@ package com.nauk.moodl.DataManagers.CurrencyData; import android.graphics.Bitmap; +import android.graphics.Color; import android.os.Parcel; import android.os.Parcelable; +import android.util.Log; import org.json.JSONException; import org.json.JSONObject; @@ -231,6 +233,19 @@ public class Currency implements Parcelable { } + private int getDarkenColor(int color) + { + int transColor; + int alpha = Color.alpha(color); + int r = Math.round(Color.red(color) * 0.8f); + int g = Math.round(Color.green(color) * 0.8f); + int b = Math.round(Color.blue(color) * 0.8f); + + transColor = Color.argb(alpha, r, g, b); + + return transColor ; + } + public void setId(int id) { this.id = id; @@ -243,6 +258,13 @@ public class Currency implements Parcelable { public void setChartColor(int chartColor) { + double lightness = 1 - (0.299 * Color.red(chartColor) + 0.587 * Color.green(chartColor) + 0.114 * Color.blue(chartColor)) / 255; + + if(lightness < 0.1) + { + chartColor = getDarkenColor(chartColor); + } + this.chartColor = chartColor; } diff --git a/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyDataRetriever.java b/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyDataRetriever.java index 8798d46..442faa4 100644 --- a/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyDataRetriever.java +++ b/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyDataRetriever.java @@ -186,6 +186,11 @@ public class CurrencyDataRetriever { { String requestUrl = null; + if(symbolCurrencyFrom.equals("MIOTA")) + { + symbolCurrencyFrom = "IOT"; + } + switch (timeUnit) { case MINUTES: