Fix crash in details activity when started from a watchlisted coin
This commit is contained in:
parent
6fffb87e4f
commit
ee318266e9
@ -6,6 +6,7 @@ import android.graphics.Canvas;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -16,12 +17,16 @@ import android.support.v4.app.NavUtils;
|
|||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.ViewFlipper;
|
import android.widget.ViewFlipper;
|
||||||
|
|
||||||
@ -184,12 +189,12 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
drawTransactionList();
|
drawTransactionList();
|
||||||
|
|
||||||
updateInfoTab();
|
|
||||||
|
|
||||||
initializeButtons();
|
initializeButtons();
|
||||||
initializeLineChart(lineChart);
|
initializeLineChart(lineChart);
|
||||||
initializeCandleStickChart(candleStickChart);
|
initializeCandleStickChart(candleStickChart);
|
||||||
|
|
||||||
|
updateInfoTab();
|
||||||
|
|
||||||
updateChartTab(DAY, 1);
|
updateChartTab(DAY, 1);
|
||||||
|
|
||||||
BottomNavigationView navigation = findViewById(R.id.navigation_details);
|
BottomNavigationView navigation = findViewById(R.id.navigation_details);
|
||||||
@ -201,9 +206,54 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
updater.execute();
|
updater.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refreshInfoTab()
|
||||||
|
{
|
||||||
|
Drawable progressBarDrawable = ((ProgressBar) findViewById(R.id.percentageCoinEmited)).getProgressDrawable();
|
||||||
|
progressBarDrawable.mutate();
|
||||||
|
progressBarDrawable.setColorFilter(new PorterDuffColorFilter(currency.getChartColor(), PorterDuff.Mode.SRC_IN));
|
||||||
|
progressBarDrawable.invalidateSelf();
|
||||||
|
|
||||||
|
((ProgressBar) findViewById(R.id.percentageCoinEmited))
|
||||||
|
.setProgress((int) Math.round(currency.getMinedCoinSupply() / currency.getMaxCoinSupply() * 100));
|
||||||
|
|
||||||
|
((TextView) findViewById(R.id.txtViewAlgorithm))
|
||||||
|
.setText(currency.getAlgorithm());
|
||||||
|
((TextView) findViewById(R.id.txtViewProofType))
|
||||||
|
.setText(currency.getProofType());
|
||||||
|
((TextView) findViewById(R.id.txtViewDescription))
|
||||||
|
.setText(Html.fromHtml(currency.getDescription()));
|
||||||
|
((TextView) findViewById(R.id.txtViewDescription))
|
||||||
|
.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
((TextView) findViewById(R.id.txtViewPercentageCoinEmited))
|
||||||
|
.setText("Percentage of coin emited : " + numberConformer(currency.getMinedCoinSupply() / currency.getMaxCoinSupply() * 100) + "%");
|
||||||
|
|
||||||
|
if(currency.getMaxCoinSupply() == 0)
|
||||||
|
{
|
||||||
|
((TextView) findViewById(R.id.txtViewTotalSupply))
|
||||||
|
.setText(PlaceholderManager.getSymbolString("Infinity", getApplication()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((TextView) findViewById(R.id.txtViewTotalSupply))
|
||||||
|
.setText(PlaceholderManager.getSymbolString(numberConformer(currency.getMaxCoinSupply()), getApplication()));
|
||||||
|
}
|
||||||
|
((TextView) findViewById(R.id.txtViewCirculatingSupply))
|
||||||
|
.setText(PlaceholderManager.getSymbolString(numberConformer(currency.getMinedCoinSupply()), getApplication()));
|
||||||
|
}
|
||||||
|
|
||||||
private void updateInfoTab()
|
private void updateInfoTab()
|
||||||
{
|
{
|
||||||
((TextView) findViewById(R.id.txtViewTotalSupply)).setText("");
|
currency.updateSnapshot(this, new Currency.CurrencyCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(final Currency currency) {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
refreshInfoTab();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupActionBar()
|
private void setupActionBar()
|
||||||
@ -635,8 +685,15 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
str = String.format( Locale.UK, "%.4f", number).replaceAll("\\.?0*$", "");
|
str = String.format( Locale.UK, "%.4f", number).replaceAll("\\.?0*$", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!str.equals("Infinity"))
|
||||||
|
{
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for(int i = str.indexOf(".") - 1; i > 0; i--)
|
int i = str.indexOf(".") - 1;
|
||||||
|
if(i <= 0)
|
||||||
|
{
|
||||||
|
i = str.length() - 1;
|
||||||
|
}
|
||||||
|
for(; i > 0; i--)
|
||||||
{
|
{
|
||||||
counter++;
|
counter++;
|
||||||
if(counter == 3)
|
if(counter == 3)
|
||||||
@ -645,6 +702,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -716,9 +774,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
dataSet.setDrawHorizontalHighlightIndicator(false);
|
dataSet.setDrawHorizontalHighlightIndicator(false);
|
||||||
dataSet.setHighLightColor(currency.getChartColor());
|
dataSet.setHighLightColor(currency.getChartColor());
|
||||||
|
|
||||||
Drawable fillDrawable = ContextCompat.getDrawable(this, R.drawable.linear_chart_gradient);
|
|
||||||
fillDrawable.setColorFilter(getColorWithAlpha(currency.getChartColor(), 0.5f), PorterDuff.Mode.SRC_ATOP);
|
|
||||||
|
|
||||||
return new LineData(dataSet);
|
return new LineData(dataSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,6 +469,20 @@ public class Watchlist extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCurrencyId(String symbol)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
|
||||||
|
id = jsonObject.getInt("Id");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
private class WatchlistUpdater extends AsyncTask<Void, Integer, Void>
|
private class WatchlistUpdater extends AsyncTask<Void, Integer, Void>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -481,6 +495,7 @@ public class Watchlist extends Fragment {
|
|||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
for(final Currency currency : watchlistManager.getWatchlist())
|
for(final Currency currency : watchlistManager.getWatchlist())
|
||||||
{
|
{
|
||||||
|
currency.setId(getCurrencyId(currency.getSymbol()));
|
||||||
currency.updatePrice(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
currency.updatePrice(getActivity(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final Currency sucessCurrency) {
|
public void onSuccess(final Currency sucessCurrency) {
|
||||||
|
@ -5,16 +5,13 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.nauk.coinfolio.R;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static java.sql.Types.NULL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Tiji on 25/12/2017.
|
* Created by Tiji on 25/12/2017.
|
||||||
*/
|
*/
|
||||||
@ -34,11 +31,14 @@ public class Currency implements Parcelable {
|
|||||||
private CurrencyDataRetriever dataRetriver;
|
private CurrencyDataRetriever dataRetriver;
|
||||||
private Bitmap icon;
|
private Bitmap icon;
|
||||||
private int chartColor;
|
private int chartColor;
|
||||||
private int circulatingSupply;
|
private double maxCoinSupply;
|
||||||
|
private double minedCoinSupply;
|
||||||
|
private String description;
|
||||||
|
private String algorithm;
|
||||||
|
private String proofType;
|
||||||
private int totalSupply;
|
private int totalSupply;
|
||||||
private double marketCapitalization;
|
private double marketCapitalization;
|
||||||
private List<String> socialMediaLinks;
|
private List<String> socialMediaLinks;
|
||||||
private String algorithm;
|
|
||||||
//private String proofType
|
//private String proofType
|
||||||
|
|
||||||
public Currency() {}
|
public Currency() {}
|
||||||
@ -101,7 +101,7 @@ public class Currency implements Parcelable {
|
|||||||
{
|
{
|
||||||
dataRetriver = new CurrencyDataRetriever(context);
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
|
|
||||||
dataRetriver.updatePrice(symbol, toSymbol, new CurrencyDataRetriever.PriceCallBack() {
|
dataRetriver.updatePrice(symbol, toSymbol, new CurrencyDataRetriever.CurrencyCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Currency currencyInfo) {
|
public void onSuccess(Currency currencyInfo) {
|
||||||
if(currencyInfo != null)
|
if(currencyInfo != null)
|
||||||
@ -110,7 +110,6 @@ public class Currency implements Parcelable {
|
|||||||
setDayFluctuation(currencyInfo.getDayFluctuation());
|
setDayFluctuation(currencyInfo.getDayFluctuation());
|
||||||
setDayFluctuationPercentage(currencyInfo.getDayFluctuationPercentage());
|
setDayFluctuationPercentage(currencyInfo.getDayFluctuationPercentage());
|
||||||
}
|
}
|
||||||
Log.d("coinfolio", this.toString());
|
|
||||||
|
|
||||||
callBack.onSuccess(Currency.this);
|
callBack.onSuccess(Currency.this);
|
||||||
}
|
}
|
||||||
@ -134,6 +133,32 @@ public class Currency implements Parcelable {
|
|||||||
}, CurrencyDataRetriever.MINUTES);
|
}, CurrencyDataRetriever.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mergeWith(Currency currency)
|
||||||
|
{
|
||||||
|
dataRetriver = currency.dataRetriver;
|
||||||
|
maxCoinSupply = currency.maxCoinSupply;
|
||||||
|
minedCoinSupply = currency.minedCoinSupply;
|
||||||
|
description = currency.description;
|
||||||
|
algorithm = currency.algorithm;
|
||||||
|
proofType = currency.proofType;
|
||||||
|
totalSupply = currency.totalSupply;
|
||||||
|
marketCapitalization = currency.marketCapitalization;
|
||||||
|
socialMediaLinks = currency.socialMediaLinks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateSnapshot(android.content.Context context, final CurrencyCallBack callBack)
|
||||||
|
{
|
||||||
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
|
dataRetriver.updateSnapshot(id, new CurrencyDataRetriever.CurrencyCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Currency currencyInfo) {
|
||||||
|
Currency.this.mergeWith(currencyInfo);
|
||||||
|
|
||||||
|
callBack.onSuccess(Currency.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void updateHistoryHours(android.content.Context context, String toSymbol, final CurrencyCallBack callBack)
|
public void updateHistoryHours(android.content.Context context, String toSymbol, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
dataRetriver = new CurrencyDataRetriever(context);
|
dataRetriver = new CurrencyDataRetriever(context);
|
||||||
@ -290,6 +315,46 @@ public class Currency implements Parcelable {
|
|||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMaxCoinSupply() {
|
||||||
|
return maxCoinSupply;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxCoinSupply(double maxCoinSupply) {
|
||||||
|
this.maxCoinSupply = maxCoinSupply;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getMinedCoinSupply() {
|
||||||
|
return minedCoinSupply;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinedCoinSupply(double minedCoinSupply) {
|
||||||
|
this.minedCoinSupply = minedCoinSupply;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlgorithm() {
|
||||||
|
return algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlgorithm(String algorithm) {
|
||||||
|
this.algorithm = algorithm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProofType() {
|
||||||
|
return proofType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProofType(String proofType) {
|
||||||
|
this.proofType = proofType;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateDayFluctuation()
|
private void updateDayFluctuation()
|
||||||
{
|
{
|
||||||
if(historyMinutes != null)
|
if(historyMinutes != null)
|
||||||
@ -303,7 +368,23 @@ public class Currency implements Parcelable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return symbol + " " + value + " " + dayFluctuation;
|
Field[] fields = this.getClass().getDeclaredFields();
|
||||||
|
String currencyString = "Currency >";
|
||||||
|
|
||||||
|
for(Field field : fields)
|
||||||
|
{
|
||||||
|
currencyString += "\n\t";
|
||||||
|
|
||||||
|
try {
|
||||||
|
currencyString += field.getName();
|
||||||
|
currencyString += ": ";
|
||||||
|
currencyString += field.get(this);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return currencyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CurrencyCallBack {
|
public interface CurrencyCallBack {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.nauk.coinfolio.DataManagers.CurrencyData;
|
package com.nauk.coinfolio.DataManagers.CurrencyData;
|
||||||
|
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
@ -9,6 +8,7 @@ import com.android.volley.Response;
|
|||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import com.android.volley.toolbox.Volley;
|
import com.android.volley.toolbox.Volley;
|
||||||
|
import com.fasterxml.jackson.databind.util.JSONPObject;
|
||||||
import com.nauk.coinfolio.R;
|
import com.nauk.coinfolio.R;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -32,6 +32,7 @@ public class CurrencyDataRetriever {
|
|||||||
private String hourHistoryUrl = "https://min-api.cryptocompare.com/data/histohour";
|
private String hourHistoryUrl = "https://min-api.cryptocompare.com/data/histohour";
|
||||||
private String dayHistoryUrl = "https://min-api.cryptocompare.com/data/histoday";
|
private String dayHistoryUrl = "https://min-api.cryptocompare.com/data/histoday";
|
||||||
private String priceUrl = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=";
|
private String priceUrl = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=";
|
||||||
|
private String snapshotUrl = "https://www.cryptocompare.com/api/data/coinsnapshotfullbyid/?id=";
|
||||||
|
|
||||||
private RequestQueue requestQueue;
|
private RequestQueue requestQueue;
|
||||||
|
|
||||||
@ -44,6 +45,29 @@ public class CurrencyDataRetriever {
|
|||||||
requestQueue = Volley.newRequestQueue(context);
|
requestQueue = Volley.newRequestQueue(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateSnapshot(int id, final CurrencyCallBack callBack)
|
||||||
|
{
|
||||||
|
final String requestUrl = snapshotUrl + id;
|
||||||
|
|
||||||
|
Log.d("coinfolio", "Update snapshot for " + id);
|
||||||
|
|
||||||
|
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
|
||||||
|
new Response.Listener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
callBack.onSuccess(processSnapshotResult(response));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
requestQueue.add(stringRequest);
|
||||||
|
}
|
||||||
|
|
||||||
public void getPriceTimestamp(final String symbolCurrencyFrom, String symbolCurrencyTo, final DataChartCallBack callBack, long timestamp)
|
public void getPriceTimestamp(final String symbolCurrencyFrom, String symbolCurrencyTo, final DataChartCallBack callBack, long timestamp)
|
||||||
{
|
{
|
||||||
final String requestUrl = "https://min-api.cryptocompare.com/data/pricehistorical?fsym=" + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo + "&ts=" + timestamp;
|
final String requestUrl = "https://min-api.cryptocompare.com/data/pricehistorical?fsym=" + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo + "&ts=" + timestamp;
|
||||||
@ -52,7 +76,6 @@ public class CurrencyDataRetriever {
|
|||||||
new Response.Listener<String>() {
|
new Response.Listener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(String response) {
|
public void onResponse(String response) {
|
||||||
Log.d("coinfolio", response + " " + requestUrl);
|
|
||||||
callBack.onSuccess(processPriceTimestampResult(response));
|
callBack.onSuccess(processPriceTimestampResult(response));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -95,7 +118,7 @@ public class CurrencyDataRetriever {
|
|||||||
requestQueue.add(stringRequest);
|
requestQueue.add(stringRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePrice(final String symbolCurrencyFrom, String symbolCurrencyTo, final PriceCallBack callBack)
|
public void updatePrice(final String symbolCurrencyFrom, String symbolCurrencyTo, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
String requestUrl = priceUrl + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo;
|
String requestUrl = priceUrl + symbolCurrencyFrom + "&tsyms=" + symbolCurrencyTo;
|
||||||
|
|
||||||
@ -139,6 +162,9 @@ public class CurrencyDataRetriever {
|
|||||||
private Currency processPriceResult(String response)
|
private Currency processPriceResult(String response)
|
||||||
{
|
{
|
||||||
Currency currency = new Currency();
|
Currency currency = new Currency();
|
||||||
|
|
||||||
|
if(response.length() > 500)
|
||||||
|
{
|
||||||
response = response.substring(response.indexOf("TYPE") - 2, response.length() - 3);
|
response = response.substring(response.indexOf("TYPE") - 2, response.length() - 3);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -153,6 +179,28 @@ public class CurrencyDataRetriever {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Currency processSnapshotResult(String response)
|
||||||
|
{
|
||||||
|
Currency currency = new Currency();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(response);
|
||||||
|
jsonObject = new JSONObject(jsonObject.getString("Data"));
|
||||||
|
jsonObject = new JSONObject(jsonObject.getString("General"));
|
||||||
|
|
||||||
|
currency.setProofType(jsonObject.getString("ProofType"));
|
||||||
|
currency.setAlgorithm(jsonObject.getString("Algorithm"));
|
||||||
|
currency.setDescription(jsonObject.getString("Description"));
|
||||||
|
currency.setMaxCoinSupply(Double.parseDouble(jsonObject.getString("TotalCoinSupply")));
|
||||||
|
currency.setMinedCoinSupply(Double.parseDouble(jsonObject.getString("TotalCoinsMined")));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
return currency;
|
return currency;
|
||||||
}
|
}
|
||||||
@ -225,7 +273,7 @@ public class CurrencyDataRetriever {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePrice(String symbolCurrencyFrom, final PriceCallBack callBack)
|
public void updatePrice(String symbolCurrencyFrom, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
if(symbolCurrencyFrom.equals("USD"))
|
if(symbolCurrencyFrom.equals("USD"))
|
||||||
{
|
{
|
||||||
@ -268,7 +316,7 @@ public class CurrencyDataRetriever {
|
|||||||
void onSuccess(String price);
|
void onSuccess(String price);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface PriceCallBack {
|
public interface CurrencyCallBack {
|
||||||
void onSuccess(Currency currencyInfo);
|
void onSuccess(Currency currencyInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ public class BinanceManager {
|
|||||||
|
|
||||||
for(int i = 0; i < assets.size(); i++)
|
for(int i = 0; i < assets.size(); i++)
|
||||||
{
|
{
|
||||||
if(Double.parseDouble(assets.get(i).getFree()) > 0)
|
if(Double.parseDouble(assets.get(i).getFree()) > 0 || Double.parseDouble(assets.get(i).getLocked()) > 0)
|
||||||
{
|
{
|
||||||
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree())));
|
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,20 +368,30 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
android:id="@+id/infosLayout"
|
android:id="@+id/infosLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<ProgressBar
|
<LinearLayout
|
||||||
android:id="@+id/currencyPortfolioDominance"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_margin="6dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewPercentageCoinEmited"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/percentageCoinEmited"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="5dp"
|
||||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
android:visibility="invisible"
|
android:layout_margin="5dp"
|
||||||
android:background="@color/colorAccent"
|
android:background="@drawable/rounded_corners"/>
|
||||||
android:padding="@dimen/mdtp_ampm_left_padding"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -431,6 +441,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
@ -454,8 +465,75 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="0.5">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Algorithm"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewAlgorithm"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="0.5">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Proof type"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewProofType"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Description"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtViewDescription"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/transactionsLayout"
|
android:id="@+id/transactionsLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/navigation_dashboard"
|
android:id="@+id/navigation_dashboard"
|
||||||
android:icon="@drawable/ic_dashboard_black_24dp"
|
android:icon="@drawable/ic_dashboard_black_24dp"
|
||||||
android:enabled="false"
|
|
||||||
android:title="@string/title_infos" />
|
android:title="@string/title_infos" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
Loading…
Reference in New Issue
Block a user