Update icon code
This commit is contained in:
parent
241362fe8c
commit
4986091644
@ -8,6 +8,7 @@ import android.support.v4.view.GravityCompat;
|
|||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -245,10 +246,19 @@ public class MarketCapitalization extends Fragment {
|
|||||||
|
|
||||||
if(marketCapCounter == 2)
|
if(marketCapCounter == 2)
|
||||||
{
|
{
|
||||||
|
updateIcons();
|
||||||
refreshDisplayedData();
|
refreshDisplayedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateIcons()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < marketCapManager.getTopCurrencies().size(); i++)
|
||||||
|
{
|
||||||
|
Log.d("moodl", "> " + marketCapManager.getTopCurrencies().get(i).getSymbol());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setupPieChart(PieData data)
|
private void setupPieChart(PieData data)
|
||||||
{
|
{
|
||||||
CustomPieChart pieChart = view.findViewById(R.id.marketCapPieChart);
|
CustomPieChart pieChart = view.findViewById(R.id.marketCapPieChart);
|
||||||
|
@ -615,7 +615,11 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
{
|
{
|
||||||
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
|
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
|
||||||
|
|
||||||
MoodlBox.getBitmapFromURL(balanceManager.getIconUrl(localCurrency.getSymbol()), localCurrency.getSymbol(), getResources(), getContext(), new HomeActivity.IconCallBack() {
|
String iconUrl = balanceManager.getIconUrl(localCurrency.getSymbol());
|
||||||
|
|
||||||
|
if(iconUrl != null)
|
||||||
|
{
|
||||||
|
MoodlBox.getBitmapFromURL(iconUrl, localCurrency.getSymbol(), getResources(), getContext(), new HomeActivity.IconCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Bitmap bitmapIcon) {
|
public void onSuccess(Bitmap bitmapIcon) {
|
||||||
localCurrency.setIcon(bitmapIcon);
|
localCurrency.setIcon(bitmapIcon);
|
||||||
@ -623,6 +627,15 @@ public class Summary extends Fragment implements HideBalanceSwitch {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_moodl);
|
||||||
|
icon = Bitmap.createScaledBitmap(icon, 50, 50, false);
|
||||||
|
|
||||||
|
localCurrency.setIcon(icon);
|
||||||
|
countIcons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,11 @@ public class Watchlist extends Fragment {
|
|||||||
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) {
|
||||||
MoodlBox.getBitmapFromURL(getIconUrl(sucessCurrency.getSymbol()), sucessCurrency.getSymbol(), getResources(), getContext(), new HomeActivity.IconCallBack() {
|
String iconUrl = getIconUrl(sucessCurrency.getSymbol());
|
||||||
|
|
||||||
|
if(iconUrl != null)
|
||||||
|
{
|
||||||
|
MoodlBox.getBitmapFromURL(iconUrl, sucessCurrency.getSymbol(), getResources(), getContext(), new HomeActivity.IconCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Bitmap bitmapIcon) {
|
public void onSuccess(Bitmap bitmapIcon) {
|
||||||
sucessCurrency.setIcon(bitmapIcon);
|
sucessCurrency.setIcon(bitmapIcon);
|
||||||
@ -360,6 +364,16 @@ public class Watchlist extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_moodl);
|
||||||
|
icon = Bitmap.createScaledBitmap(icon, 50, 50, false);
|
||||||
|
|
||||||
|
sucessCurrency.setIcon(icon);
|
||||||
|
updateChartColor(currency);
|
||||||
|
countWatchlist();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -136,7 +136,7 @@ public class CurrencyDataRetriever {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHistory(final String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack, int timeUnit)
|
void updateHistory(final String symbolCurrencyFrom, String symbolCyrrencyTo, final DataChartCallBack callBack, int timeUnit)
|
||||||
{
|
{
|
||||||
String requestUrl = getRequestUrl(timeUnit, symbolCurrencyFrom, symbolCyrrencyTo);
|
String requestUrl = getRequestUrl(timeUnit, symbolCurrencyFrom, symbolCyrrencyTo);
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ public class CurrencyDataRetriever {
|
|||||||
requestQueue.add(stringRequest);
|
requestQueue.add(stringRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePrice(String symbolCurrencyFrom, String symbolCurrencyTo, final CurrencyCallBack callBack)
|
void updatePrice(String symbolCurrencyFrom, String symbolCurrencyTo, final CurrencyCallBack callBack)
|
||||||
{
|
{
|
||||||
if(symbolCurrencyFrom.equals("MIOTA"))
|
if(symbolCurrencyFrom.equals("MIOTA"))
|
||||||
{
|
{
|
||||||
@ -314,61 +314,6 @@ public class CurrencyDataRetriever {
|
|||||||
return new CurrencyDataChart(timestamp, close, high, low, open, volumeFrom, volumeTo);
|
return new CurrencyDataChart(timestamp, close, high, low, open, volumeFrom, volumeTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getPriceTimestamp(String symbolCurrencyFrom, final DataChartCallBack callBack, long timestamp)
|
|
||||||
{
|
|
||||||
getPriceTimestamp(symbolCurrencyFrom, "USD", callBack, timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateHistory(String symbolCurrencyFrom, final DataChartCallBack callBack, int timeUnit)
|
|
||||||
{
|
|
||||||
if(symbolCurrencyFrom.equals("USD"))
|
|
||||||
{
|
|
||||||
callBack.onSuccess((List<CurrencyDataChart>) null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
updateHistory(symbolCurrencyFrom, "USD", callBack, timeUnit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updatePrice(String symbolCurrencyFrom, final CurrencyCallBack callBack)
|
|
||||||
{
|
|
||||||
if(symbolCurrencyFrom.equals("USD"))
|
|
||||||
{
|
|
||||||
callBack.onSuccess(null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
updatePrice(symbolCurrencyFrom, "USD", callBack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public void updateCryptocompareDetails(int id, final Currency.CurrencyCallBack callBack)
|
|
||||||
{
|
|
||||||
String requestUrl = getRequestUrl(timeUnit, symbolCurrencyFrom, symbolCyrrencyTo);
|
|
||||||
|
|
||||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, requestUrl,
|
|
||||||
new Response.Listener<String>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(String response) {
|
|
||||||
callBack.onSuccess();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Response.ErrorListener() {
|
|
||||||
@Override
|
|
||||||
public void onErrorResponse(VolleyError error) {
|
|
||||||
callBack.onSuccess();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
requestQueue.add(stringRequest);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void updateCoinMarketCapDetails()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface DataChartCallBack {
|
public interface DataChartCallBack {
|
||||||
void onSuccess(List<CurrencyDataChart> dataChart);
|
void onSuccess(List<CurrencyDataChart> dataChart);
|
||||||
void onSuccess(String price);
|
void onSuccess(String price);
|
||||||
|
@ -12,6 +12,9 @@ import android.view.animation.Transformation;
|
|||||||
|
|
||||||
import com.nauk.moodl.Activities.HomeActivity;
|
import com.nauk.moodl.Activities.HomeActivity;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -237,4 +240,17 @@ public class MoodlBox {
|
|||||||
|
|
||||||
callBack.onSuccess(result);
|
callBack.onSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getIconUrl(String imageUrl)
|
||||||
|
{
|
||||||
|
String url;
|
||||||
|
|
||||||
|
try {
|
||||||
|
url = "https://www.cryptocompare.com" + imageUrl + "?width=50";
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
url = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user