MarketCap implementation & minor fixes
This commit is contained in:
parent
b7c2e57824
commit
a306f48c02
@ -40,7 +40,9 @@ dependencies {
|
||||
implementation 'com.squareup.retrofit2:converter-jackson:2.2.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
|
||||
implementation 'org.apache.commons:commons-lang3:3.6'
|
||||
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
|
||||
implementation 'com.mattprecious.swirl:swirl:1.1.0'
|
||||
//implementation 'com.github.lecho:hellocharts-library:1.5.8@aar'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
||||
|
@ -102,7 +102,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
||||
Intent intent = getIntent();
|
||||
|
||||
//symbol = intent.getStringExtra("symbol");
|
||||
currency = (Currency) intent.getParcelableExtra("currency");
|
||||
currency = intent.getParcelableExtra("currency");
|
||||
|
||||
databaseManager = new DatabaseManager(this);
|
||||
|
||||
@ -131,7 +131,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
||||
|
||||
setTitle(currency.getName());
|
||||
|
||||
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation_details);
|
||||
BottomNavigationView navigation = findViewById(R.id.navigation_details);
|
||||
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
|
||||
|
||||
hasBeenModified = false;
|
||||
@ -297,7 +297,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
||||
|
||||
chartView.reset();
|
||||
|
||||
chartView.setAxisBorderValues((float) valMin, (float) valMax);
|
||||
chartView.setAxisBorderValues(valMin, valMax);
|
||||
chartView.setYLabels(AxisRenderer.LabelPosition.NONE);
|
||||
chartView.setYAxis(false);
|
||||
chartView.setXAxis(false);
|
||||
|
@ -4,6 +4,8 @@ import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -14,11 +16,14 @@ import android.support.design.widget.BottomNavigationView;
|
||||
import android.support.design.widget.CollapsingToolbarLayout;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.widget.NestedScrollView;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
@ -27,18 +32,24 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import com.github.mikephil.charting.animation.Easing;
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.data.PieEntry;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.luseen.spacenavigation.SpaceItem;
|
||||
import com.luseen.spacenavigation.SpaceNavigationView;
|
||||
import com.luseen.spacenavigation.SpaceOnClickListener;
|
||||
import com.nauk.coinfolio.DataManagers.BalanceManager;
|
||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||
import com.nauk.coinfolio.DataManagers.MarketCapManager;
|
||||
import com.nauk.coinfolio.DataManagers.PreferencesManager;
|
||||
import com.nauk.coinfolio.LayoutManagers.HomeLayoutGenerator;
|
||||
import com.nauk.coinfolio.R;
|
||||
@ -47,6 +58,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
//Use WilliamChart for charts https://github.com/diogobernardino/WilliamChart
|
||||
@ -64,9 +76,11 @@ public class HomeActivity extends AppCompatActivity {
|
||||
private PreferencesManager preferencesManager;
|
||||
private HomeLayoutGenerator layoutGenerator;
|
||||
private BalanceManager balanceManager;
|
||||
private MarketCapManager marketCapManager;
|
||||
|
||||
private int coinCounter;
|
||||
private int iconCounter;
|
||||
private int marketCapCounter;
|
||||
private long lastTimestamp;
|
||||
private boolean detailsChecker;
|
||||
private boolean isDetailed;
|
||||
@ -117,10 +131,11 @@ public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
generateSplash();
|
||||
|
||||
//Objects initializatoin
|
||||
//Objects initialization
|
||||
preferencesManager = new PreferencesManager(this);
|
||||
layoutGenerator = new HomeLayoutGenerator(this);
|
||||
balanceManager = new BalanceManager(this);
|
||||
marketCapManager = new MarketCapManager(this);
|
||||
handler = new Handler();
|
||||
updateRunnable = new Runnable() {
|
||||
@Override
|
||||
@ -190,7 +205,21 @@ public class HomeActivity extends AppCompatActivity {
|
||||
new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
switch (viewFlipper.getDisplayedChild())
|
||||
{
|
||||
case 0:
|
||||
Log.d(getResources().getString(R.string.debug), "Watchlist");
|
||||
refreshLayout.setRefreshing(false);
|
||||
break;
|
||||
case 1:
|
||||
updateAll(false);
|
||||
break;
|
||||
case 2:
|
||||
Log.d(getResources().getString(R.string.debug), "Market cap");
|
||||
refreshLayout.setRefreshing(false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -221,7 +250,7 @@ public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
private void setupNavBar(Bundle savedInstanceState)
|
||||
{
|
||||
final SpaceNavigationView spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space);
|
||||
final SpaceNavigationView spaceNavigationView = findViewById(R.id.space);
|
||||
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
|
||||
spaceNavigationView.addSpaceItem(new SpaceItem("Charts", R.drawable.ic_show_chart_black_24dp));
|
||||
spaceNavigationView.addSpaceItem(new SpaceItem("Market Cap.", R.drawable.ic_pie_chart_black_24dp));
|
||||
@ -240,7 +269,7 @@ public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
nav.changeCurrentItem(-1);
|
||||
|
||||
((NestedScrollView) findViewById(R.id.nestedScrollViewLayout)).setNestedScrollingEnabled(true);
|
||||
findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(true);
|
||||
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(true, true);
|
||||
|
||||
findViewById(R.id.switch_button).setVisibility(View.VISIBLE);
|
||||
@ -255,8 +284,8 @@ public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
//0 : Unknown
|
||||
//1 : Market cap
|
||||
((NestedScrollView) findViewById(R.id.nestedScrollViewLayout)).setNestedScrollingEnabled(false);
|
||||
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(false, true);
|
||||
findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(false);
|
||||
|
||||
findViewById(R.id.switch_button).setVisibility(View.GONE);
|
||||
|
||||
@ -359,8 +388,6 @@ public class HomeActivity extends AppCompatActivity {
|
||||
updateViewButtonIcon();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateAll(boolean mustUpdate)
|
||||
{
|
||||
if(System.currentTimeMillis()/1000 - lastTimestamp > 60 || mustUpdate)
|
||||
@ -470,6 +497,77 @@ public class HomeActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void updateMarketCap()
|
||||
{
|
||||
marketCapCounter = 0;
|
||||
|
||||
marketCapManager.updateTopCurrencies(new MarketCapManager.VolleyCallBack() {
|
||||
@Override
|
||||
public void onSuccess()
|
||||
{
|
||||
countCompletedMarketCapRequest();
|
||||
}
|
||||
});
|
||||
|
||||
marketCapManager.updateMarketCap(new MarketCapManager.VolleyCallBack() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
countCompletedMarketCapRequest();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void countCompletedMarketCapRequest()
|
||||
{
|
||||
marketCapCounter++;
|
||||
|
||||
if(marketCapCounter == 2)
|
||||
{
|
||||
findViewById(R.id.progressBarMarketCap).setVisibility(View.GONE);
|
||||
|
||||
List<PieEntry> entries = new ArrayList<>();
|
||||
|
||||
PieChart pieChart = findViewById(R.id.marketCapPieChart);
|
||||
|
||||
float otherCurrenciesDominance = 0;
|
||||
|
||||
for(Iterator i = marketCapManager.getDominance().keySet().iterator(); i.hasNext(); )
|
||||
{
|
||||
String key = (String) i.next();
|
||||
Log.d(getResources().getString(R.string.debug), "Sym : " + key + " " + marketCapManager.getDominance().get(key));
|
||||
entries.add(new PieEntry(marketCapManager.getDominance().get(key), key));
|
||||
otherCurrenciesDominance += marketCapManager.getDominance().get(key);
|
||||
}
|
||||
|
||||
entries.add(new PieEntry(100-otherCurrenciesDominance, "Others"));
|
||||
|
||||
PieDataSet set = new PieDataSet(entries, "Market Cap Dominance");
|
||||
PieData data = new PieData(set);
|
||||
pieChart.setData(data);
|
||||
|
||||
pieChart.setDrawSlicesUnderHole(true);
|
||||
pieChart.setUsePercentValues(true);
|
||||
pieChart.setTouchEnabled(false);
|
||||
|
||||
pieChart.getDescription().setEnabled(false);
|
||||
pieChart.setCenterText(generateCenterSpannableText());
|
||||
pieChart.setVisibility(View.VISIBLE);
|
||||
pieChart.invalidate(); // refresh
|
||||
}
|
||||
}
|
||||
|
||||
private SpannableString generateCenterSpannableText() {
|
||||
|
||||
SpannableString s = new SpannableString("MPAndroidChart\ndeveloped by Philipp Jahoda");
|
||||
s.setSpan(new RelativeSizeSpan(1.7f), 0, 14, 0);
|
||||
s.setSpan(new StyleSpan(Typeface.NORMAL), 14, s.length() - 15, 0);
|
||||
s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, s.length() - 15, 0);
|
||||
s.setSpan(new RelativeSizeSpan(.8f), 14, s.length() - 15, 0);
|
||||
s.setSpan(new StyleSpan(Typeface.ITALIC), s.length() - 14, s.length(), 0);
|
||||
s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length() - 14, s.length(), 0);
|
||||
return s;
|
||||
}
|
||||
|
||||
private void countCoins(boolean isCoin, boolean isDetails)
|
||||
{
|
||||
if(isCoin)
|
||||
@ -486,21 +584,8 @@ public class HomeActivity extends AppCompatActivity {
|
||||
{
|
||||
if(coinCounter == balanceManager.getTotalBalance().size() && detailsChecker)
|
||||
{
|
||||
for (int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||
{
|
||||
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
|
||||
|
||||
if(balanceManager.getIconUrl(localCurrency.getSymbol()) != null)
|
||||
{
|
||||
getBitmapFromURL(balanceManager.getIconUrl(localCurrency.getSymbol()), new IconCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Bitmap bitmapIcon) {
|
||||
localCurrency.setIcon(bitmapIcon);
|
||||
countIcons();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
IconDownloader iconDownloader = new IconDownloader();
|
||||
iconDownloader.execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -559,6 +644,49 @@ public class HomeActivity extends AppCompatActivity {
|
||||
loadingDialog.show();
|
||||
}
|
||||
|
||||
private class IconDownloader extends AsyncTask<Void, Integer, Void>
|
||||
{
|
||||
@Override
|
||||
protected void onPreExecute()
|
||||
{
|
||||
super.onPreExecute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Integer... values)
|
||||
{
|
||||
super.onProgressUpdate(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params)
|
||||
{
|
||||
for (int i = 0; i < balanceManager.getTotalBalance().size(); i++)
|
||||
{
|
||||
final Currency localCurrency = balanceManager.getTotalBalance().get(i);
|
||||
|
||||
if(balanceManager.getIconUrl(localCurrency.getSymbol()) != null)
|
||||
{
|
||||
getBitmapFromURL(balanceManager.getIconUrl(localCurrency.getSymbol()), new IconCallBack() {
|
||||
@Override
|
||||
public void onSuccess(Bitmap bitmapIcon) {
|
||||
localCurrency.setIcon(bitmapIcon);
|
||||
countIcons();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class UiHeavyLoadCalculator extends AsyncTask<Void, Integer, Void>
|
||||
{
|
||||
|
||||
@ -765,7 +893,9 @@ public class HomeActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
balanceManager.updateMarketCap(new BalanceManager.VolleyCallBack() {
|
||||
updateMarketCap();
|
||||
|
||||
/*marketCapManager.updateTopCurrencies(new BalanceManager.VolleyCallBack() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
@ -774,7 +904,7 @@ public class HomeActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}});
|
||||
}});*/
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package com.nauk.coinfolio.Activities;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -21,7 +19,6 @@ import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.RingtonePreference;
|
||||
import android.security.keystore.KeyGenParameterSpec;
|
||||
import android.security.keystore.KeyPermanentlyInvalidatedException;
|
||||
|
@ -1,37 +1,26 @@
|
||||
package com.nauk.coinfolio.DataManagers;
|
||||
|
||||
import android.os.StrictMode;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.volley.AuthFailureError;
|
||||
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.JsonArrayRequest;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.binance.api.client.BinanceApiClientFactory;
|
||||
import com.binance.api.client.BinanceApiRestClient;
|
||||
import com.binance.api.client.domain.account.Account;
|
||||
import com.binance.api.client.domain.account.AssetBalance;
|
||||
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
|
||||
import com.nauk.coinfolio.DataManagers.ExchangeManager.BinanceManager;
|
||||
import com.nauk.coinfolio.DataManagers.ExchangeManager.HitBtcManager;
|
||||
import com.nauk.coinfolio.R;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
@ -296,27 +285,6 @@ public class BalanceManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMarketCap(final VolleyCallBack callBack)
|
||||
{
|
||||
StringRequest strRequest = new StringRequest(Request.Method.GET, detailUrl,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
if (response.length() > 0) {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
requestQueue.add(strRequest);
|
||||
}
|
||||
|
||||
public void updateDetails(final IconCallBack callBack)
|
||||
{
|
||||
StringRequest strRequest = new StringRequest(Request.Method.GET, detailUrl,
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.nauk.coinfolio.DataManagers.ExchangeManager;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.binance.api.client.BinanceApiClientFactory;
|
||||
import com.binance.api.client.BinanceApiRestClient;
|
||||
import com.binance.api.client.domain.account.Account;
|
||||
|
@ -0,0 +1,139 @@
|
||||
package com.nauk.coinfolio.DataManagers;
|
||||
|
||||
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 org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Created by Guitoune on 02/03/2018.
|
||||
*/
|
||||
|
||||
public class MarketCapManager {
|
||||
|
||||
private static final String topCurrenciesUrl = "https://api.coinmarketcap.com/v1/ticker/?limit=9";
|
||||
private static final String marketCapUrl = "https://api.coinmarketcap.com/v1/global/";
|
||||
private android.content.Context context;
|
||||
private RequestQueue requestQueue;
|
||||
private String topRequestResult[];
|
||||
private long marketCap;
|
||||
|
||||
public MarketCapManager(android.content.Context context)
|
||||
{
|
||||
this.context = context;
|
||||
|
||||
requestQueue = Volley.newRequestQueue(context);
|
||||
}
|
||||
|
||||
public void updateTopCurrencies(final VolleyCallBack callBack)
|
||||
{
|
||||
StringRequest strRequest = new StringRequest(Request.Method.GET, topCurrenciesUrl,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
if (response.length() > 0) {
|
||||
processTopCurrencies(response);
|
||||
}
|
||||
|
||||
callBack.onSuccess();
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
requestQueue.add(strRequest);
|
||||
}
|
||||
|
||||
public void updateMarketCap(final VolleyCallBack callBack)
|
||||
{
|
||||
StringRequest strRequest = new StringRequest(Request.Method.GET, marketCapUrl,
|
||||
new Response.Listener<String>() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
if (response.length() > 0) {
|
||||
processMarketCapData(response);
|
||||
}
|
||||
|
||||
callBack.onSuccess();
|
||||
}
|
||||
},
|
||||
new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
requestQueue.add(strRequest);
|
||||
}
|
||||
|
||||
private void processMarketCapData(String response)
|
||||
{
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response);
|
||||
|
||||
marketCap = new BigDecimal(jsonObject.getString("total_market_cap_usd")).longValue();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, Float> getDominance()
|
||||
{
|
||||
HashMap<String, Float> dominance = new HashMap<>();
|
||||
|
||||
for(int i = 0; i < topRequestResult.length; i++)
|
||||
{
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(topRequestResult[i]);
|
||||
|
||||
dominance.put(jsonObject.getString("symbol"), (Float.parseFloat(jsonObject.getString("market_cap_usd")) / marketCap)*100);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return dominance;
|
||||
}
|
||||
|
||||
private void processTopCurrencies(String response)
|
||||
{
|
||||
response = response.substring(response.indexOf('[')+1, response.lastIndexOf(']'));
|
||||
|
||||
topRequestResult = response.split(Pattern.quote("},"));
|
||||
|
||||
for(int i = 0; i < topRequestResult.length; i++)
|
||||
{
|
||||
try {
|
||||
topRequestResult[i] += "}";
|
||||
|
||||
JSONObject jsonObject = new JSONObject(topRequestResult[i]);
|
||||
|
||||
Log.d("coinfolio", "Symbol : " + jsonObject.getString("symbol") + " " + jsonObject.getString("rank"));
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface VolleyCallBack
|
||||
{
|
||||
void onSuccess();
|
||||
}
|
||||
}
|
@ -1,30 +1,15 @@
|
||||
package com.nauk.coinfolio.FingerprintToolkit;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mattprecious.swirl.SwirlView;
|
||||
import com.nauk.coinfolio.Activities.SettingsActivity;
|
||||
import com.nauk.coinfolio.R;
|
||||
|
||||
/**
|
||||
@ -49,7 +34,7 @@ public class FingerprintDialogFragment extends DialogFragment{
|
||||
|
||||
//getDialog().getWindow().setLayout(getResources().getDimensionPixelSize(R.dimen.fingerprint_dialog_width), getResources().getDimensionPixelSize(R.dimen.fingerprint_dialog_height));
|
||||
|
||||
((Button) view.findViewById(R.id.cancelButton)).setOnClickListener(new View.OnClickListener() {
|
||||
view.findViewById(R.id.cancelButton).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
|
@ -7,8 +7,6 @@ import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.app.DialogFragment;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by Guitoune on 28/02/2018.
|
||||
|
@ -36,8 +36,8 @@ public class CurrencyAdapter extends ArrayAdapter<Currency> {
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.custom_currency_row, parent, false);
|
||||
}
|
||||
TextView currencyName = (TextView) convertView.findViewById(R.id.currencyName);
|
||||
TextView currencySymbol = (TextView) convertView.findViewById(R.id.currencySymbol);
|
||||
TextView currencyName = convertView.findViewById(R.id.currencyName);
|
||||
TextView currencySymbol = convertView.findViewById(R.id.currencySymbol);
|
||||
if (currencyName != null)
|
||||
currencyName.setText(currency.getName());
|
||||
if(currencySymbol != null)
|
||||
|
@ -90,7 +90,7 @@ public class HomeLayoutGenerator {
|
||||
if(currency.getHistoryMinutes() != null)
|
||||
{
|
||||
List<Double> borders = getAxisBorders(currency);
|
||||
LineChartView chartView = (LineChartView) view.findViewById(R.id.LineChartView);
|
||||
LineChartView chartView = view.findViewById(R.id.LineChartView);
|
||||
|
||||
chartView.setAxisBorderValues(borders.get(0).floatValue(), borders.get(1).floatValue())
|
||||
.setYLabels(AxisRenderer.LabelPosition.NONE)
|
||||
@ -141,7 +141,7 @@ public class HomeLayoutGenerator {
|
||||
|
||||
if(currency.getHistoryMinutes() != null)
|
||||
{
|
||||
((LineChartView) view.findViewById(R.id.LineChartView)).setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.LineChartView).setVisibility(View.VISIBLE);
|
||||
((LineChartView) view.findViewById(R.id.LineChartView)).show();
|
||||
view.findViewById(R.id.errorTextView).setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
|
||||
</vector>
|
@ -79,7 +79,8 @@
|
||||
android:id="@+id/layoutProgressMarketCap"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible">
|
||||
android:visibility="visible"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBarMarketCap"
|
||||
@ -88,6 +89,11 @@
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circular_progress_bar" />
|
||||
<com.github.mikephil.charting.charts.PieChart
|
||||
android:id="@+id/marketCapPieChart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -4,7 +4,7 @@
|
||||
<item
|
||||
android:id="@+id/navigation_home"
|
||||
android:icon="@drawable/ic_show_chart_black_24dp"
|
||||
android:title="@string/title_charts" />
|
||||
android:title="@string/title_watchlist" />
|
||||
|
||||
<item
|
||||
android:id="@+id/navigation_dashboard"
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/navigation_something"
|
||||
android:icon="@drawable/ic_show_chart_black_24dp"
|
||||
android:title="@string/title_charts" />
|
||||
android:icon="@drawable/ic_remove_red_eye_black_24dp"
|
||||
android:title="@string/title_watchlist" />
|
||||
|
||||
<item
|
||||
android:id="@+id/navigation_view_list"
|
||||
|
@ -121,7 +121,7 @@
|
||||
<string name="activity_add_amount">Amount</string>
|
||||
<string name="activity_purchased_price">Purchased price</string>
|
||||
<string name="title_activity_currency_details">CurrencyDetailsActivity</string>
|
||||
<string name="title_charts">Charts</string>
|
||||
<string name="title_watchlist">Watchlist</string>
|
||||
<string name="title_infos">Infos</string>
|
||||
<string name="title_transactions">Transactions</string>
|
||||
<string name="title_home">Home</string>
|
||||
|
@ -19,6 +19,7 @@ allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user