Fix IOTA history loading | Fix too ligh chart colors
This commit is contained in:
parent
84a8c98dd4
commit
e5ab35b9bd
@ -271,45 +271,6 @@ public class Watchlist extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
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 ;
|
||||
}
|
||||
|
||||
private String getIconUrl(String symbol)
|
||||
{
|
||||
String url;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,11 @@ public class CurrencyDataRetriever {
|
||||
{
|
||||
String requestUrl = null;
|
||||
|
||||
if(symbolCurrencyFrom.equals("MIOTA"))
|
||||
{
|
||||
symbolCurrencyFrom = "IOT";
|
||||
}
|
||||
|
||||
switch (timeUnit)
|
||||
{
|
||||
case MINUTES:
|
||||
|
Loading…
Reference in New Issue
Block a user