Code cleanup | Selection activty smoother

This commit is contained in:
Tanguy Herbron 2018-04-13 00:31:56 +02:00
parent cf8ec6c565
commit 334c867ea2
18 changed files with 485 additions and 303 deletions

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.nauk.coinfolio","split":"","minSdkVersion":"21"}}] [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.nauk.coinfolio","split":"","minSdkVersion":"23"}}]

@ -16,6 +16,7 @@ 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.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;
@ -43,6 +44,7 @@ import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener; import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency; import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart; import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDataChart;
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDetailsList;
import com.nauk.coinfolio.DataManagers.CurrencyData.Transaction; import com.nauk.coinfolio.DataManagers.CurrencyData.Transaction;
import com.nauk.coinfolio.DataManagers.DatabaseManager; import com.nauk.coinfolio.DataManagers.DatabaseManager;
import com.nauk.coinfolio.DataManagers.ExchangeManager.BinanceManager; import com.nauk.coinfolio.DataManagers.ExchangeManager.BinanceManager;
@ -83,6 +85,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
private BarChart barChart; private BarChart barChart;
private PreferencesManager preferencesManager; private PreferencesManager preferencesManager;
private BinanceManager binanceManager; private BinanceManager binanceManager;
private CurrencyDetailsList currencyDetailsList;
private boolean displayLineChart; private boolean displayLineChart;
@ -140,6 +143,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
databaseManager = new DatabaseManager(this); databaseManager = new DatabaseManager(this);
preferencesManager = new PreferencesManager(this); preferencesManager = new PreferencesManager(this);
currencyDetailsList = new CurrencyDetailsList(this);
displayLineChart = true; displayLineChart = true;
@ -183,6 +187,8 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
drawTransactionList(); drawTransactionList();
updateInfoTab();
initializeButtons(); initializeButtons();
initializeLineChart(lineChart); initializeLineChart(lineChart);
initializeCandleStickChart(candleStickChart); initializeCandleStickChart(candleStickChart);
@ -196,6 +202,13 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
TradeUpdater updater = new TradeUpdater(); TradeUpdater updater = new TradeUpdater();
updater.execute(); updater.execute();
Log.d("coinfolio", "Details loaded for " + currency.getId());
}
private void updateInfoTab()
{
((TextView) findViewById(R.id.txtViewTotalSupply)).setText("");
} }
private void setupActionBar() private void setupActionBar()

@ -5,29 +5,34 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Looper; import android.os.Looper;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SearchView; import android.widget.SearchView;
import com.nauk.coinfolio.DataManagers.BalanceManager;
import com.nauk.coinfolio.DataManagers.CurrencyData.Currency; import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDetailsList;
import com.nauk.coinfolio.LayoutManagers.CurrencyListAdapter; import com.nauk.coinfolio.LayoutManagers.CurrencyListAdapter;
import com.nauk.coinfolio.R; import com.nauk.coinfolio.R;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
public class CurrencySelectionActivity extends AppCompatActivity implements SearchView.OnQueryTextListener{ public class CurrencySelectionActivity extends AppCompatActivity implements SearchView.OnQueryTextListener{
private String[] currencySymbols;
private String[] currencyNames;
private CurrencyListAdapter adapter; private CurrencyListAdapter adapter;
private ListView listView; private ListView listView;
private android.widget.Filter filter; private android.widget.Filter filter;
private Intent comingIntent; private CurrencyDetailsList currencyDetailsList;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -38,12 +43,14 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
setContentView(R.layout.activity_add_currency); setContentView(R.layout.activity_add_currency);
comingIntent = getIntent(); currencyDetailsList = new CurrencyDetailsList(this);
setTitle("Select a coin"); setTitle("Select a coin");
ListLoader listLoader = new ListLoader(); ListLoader listLoader = new ListLoader();
listLoader.execute(); listLoader.execute();
Log.d("coinfolio", "Started");
} }
private void setupSearchView() private void setupSearchView()
@ -58,18 +65,14 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
private void setupAdapter() private void setupAdapter()
{ {
String[] currencyFullName = new String[currencyNames.length]; List<String> currencyNames = currencyDetailsList.getCurrenciesName();
List<String> currencySymbols = currencyDetailsList.getCurrenciesSymbol();
for(int i = 0; i < currencyFullName.length; i++)
{
currencyFullName[i] = currencyNames[i] + " " + currencySymbols[i];
}
ArrayList<Currency> currencyArrayList = new ArrayList<>(); ArrayList<Currency> currencyArrayList = new ArrayList<>();
for(int i = 0; i < currencyNames.length; i++) for(int i = 0; i < currencyNames.size(); i++)
{ {
currencyArrayList.add(new Currency(currencyNames[i], currencySymbols[i])); currencyArrayList.add(new Currency(currencyNames.get(i), currencySymbols.get(i)));
} }
adapter = new CurrencyListAdapter(this, currencyArrayList); adapter = new CurrencyListAdapter(this, currencyArrayList);
@ -97,28 +100,33 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
filter = adapter.getFilter(); filter = adapter.getFilter();
} }
@Override private static void expand(final View v) {
public boolean onCreateOptionsMenu(Menu menu) v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
// Older versions of android (pre API 21) cancel animations for views with a height of 0.
v.getLayoutParams().height = 1;
v.setVisibility(View.VISIBLE);
Animation a = new Animation()
{ {
/*final AutoCompleteTextView searchAutoComplete = findViewById(R.id.search_bar);
searchAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { protected void applyTransformation(float interpolatedTime, Transformation t) {
Currency selectedCurrency = (Currency) adapterView.getItemAtPosition(i); v.getLayoutParams().height = interpolatedTime == 1
Intent intent = new Intent(CurrencySelectionActivity.this, RecordTransactionActivity.class); ? CardView.LayoutParams.WRAP_CONTENT
intent.putExtra("coin", selectedCurrency.getName()); : (int)(targetHeight * interpolatedTime);
intent.putExtra("symbol", selectedCurrency.getSymbol()); v.requestLayout();
startActivity(intent);
finish();
} }
});
searchAutoComplete.setAdapter(adapter);
searchAutoComplete.setThreshold(0);*/
@Override
public boolean willChangeBounds() {
return true; return true;
} }
};
// 1dp/ms
a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density));
v.startAnimation(a);
}
@Override @Override
public boolean onQueryTextChange(String text) public boolean onQueryTextChange(String text)
@ -161,9 +169,9 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
Looper.prepare(); Looper.prepare();
} }
currencySymbols = comingIntent.getStringArrayExtra("currencyListSymbols"); currencyDetailsList.update(new BalanceManager.IconCallBack() {
currencyNames = comingIntent.getStringArrayExtra("currencyListNames"); @Override
public void onSuccess() {
setupAdapter(); setupAdapter();
setupList(); setupList();
@ -172,6 +180,11 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
@Override @Override
public void run() { public void run() {
setupSearchView(); setupSearchView();
expand(findViewById(R.id.listContainerLayout));
findViewById(R.id.currencyListProgressBar).setVisibility(View.GONE);
}
});
} }
}); });
@ -181,8 +194,7 @@ public class CurrencySelectionActivity extends AppCompatActivity implements Sear
@Override @Override
protected void onPostExecute(Void result) protected void onPostExecute(Void result)
{ {
findViewById(R.id.coinsPreview).setVisibility(View.VISIBLE);
findViewById(R.id.currencyListProgressBar).setVisibility(View.GONE);
} }
} }
} }

@ -232,14 +232,6 @@ public class HomeActivity extends AppCompatActivity {
public void onClick(View view) { public void onClick(View view) {
Intent addIntent = new Intent(HomeActivity.this, CurrencySelectionActivity.class); Intent addIntent = new Intent(HomeActivity.this, CurrencySelectionActivity.class);
String[] symbolList = new String[balanceManager.getCurrenciesSymbol().size()];
symbolList = balanceManager.getCurrenciesSymbol().toArray(symbolList);
String[] nameList = new String[balanceManager.getCurrenciesName().size()];
nameList = balanceManager.getCurrenciesName().toArray(nameList);
addIntent.putExtra("currencyListSymbols", symbolList);
addIntent.putExtra("currencyListNames", nameList);
startActivity(addIntent); startActivity(addIntent);
} }
}); });
@ -324,8 +316,14 @@ public class HomeActivity extends AppCompatActivity {
private void switchMainView() private void switchMainView()
{ {
Log.d("coinfolio", "Should");
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(true, true);
findViewById(R.id.swiperefresh).setNestedScrollingEnabled(true);
findViewById(R.id.toolbar_layout).setFocusable(true); findViewById(R.id.toolbar_layout).setFocusable(true);
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(true, true); ((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(true, true);
((AppBarLayout) findViewById(R.id.app_bar)).setActivated(true);
findViewById(R.id.app_bar).setClickable(true);
findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(true); findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(true);
findViewById(R.id.app_bar).setEnabled(true); findViewById(R.id.app_bar).setEnabled(true);
@ -339,8 +337,14 @@ public class HomeActivity extends AppCompatActivity {
private void switchSecondaryViews(int itemIndex) private void switchSecondaryViews(int itemIndex)
{ {
Log.d("coinfolio", "Should not");
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(false, true);
findViewById(R.id.swiperefresh).setNestedScrollingEnabled(false);
findViewById(R.id.toolbar_layout).setFocusable(false); findViewById(R.id.toolbar_layout).setFocusable(false);
((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(false, true); ((AppBarLayout) findViewById(R.id.app_bar)).setExpanded(false, true);
((AppBarLayout) findViewById(R.id.app_bar)).setActivated(false);
findViewById(R.id.app_bar).setClickable(false);
findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(false); findViewById(R.id.nestedScrollViewLayout).setNestedScrollingEnabled(false);
findViewById(R.id.app_bar).setEnabled(false); findViewById(R.id.app_bar).setEnabled(false);

@ -26,7 +26,6 @@ public class RecordTransactionActivity extends AppCompatActivity {
private String coin; private String coin;
private String symbol; private String symbol;
private TextView symbolTxtView;
private EditText amountTxtView; private EditText amountTxtView;
private TextView purchasedDate; private TextView purchasedDate;
private Button validateButton; private Button validateButton;

@ -10,6 +10,7 @@ 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.nauk.coinfolio.DataManagers.CurrencyData.Currency; import com.nauk.coinfolio.DataManagers.CurrencyData.Currency;
import com.nauk.coinfolio.DataManagers.CurrencyData.CurrencyDetailsList;
import com.nauk.coinfolio.DataManagers.ExchangeManager.BinanceManager; import com.nauk.coinfolio.DataManagers.ExchangeManager.BinanceManager;
import com.nauk.coinfolio.DataManagers.ExchangeManager.HitBtcManager; import com.nauk.coinfolio.DataManagers.ExchangeManager.HitBtcManager;
import com.nauk.coinfolio.R; import com.nauk.coinfolio.R;
@ -46,6 +47,7 @@ public class BalanceManager {
private LinkedHashMap<String, String> coinInfosHashmap; private LinkedHashMap<String, String> coinInfosHashmap;
private PreferencesManager preferenceManager; private PreferencesManager preferenceManager;
private DatabaseManager databaseManager; private DatabaseManager databaseManager;
private CurrencyDetailsList currencyDetailsList;
private int balanceCounter; private int balanceCounter;
@ -65,33 +67,17 @@ public class BalanceManager {
databaseManager = new DatabaseManager(context); databaseManager = new DatabaseManager(context);
hitBtcManagers = new ArrayList<>(); hitBtcManagers = new ArrayList<>();
binanceManagers = new ArrayList<>(); binanceManagers = new ArrayList<>();
currencyDetailsList = new CurrencyDetailsList(context);
balanceCounter = 0; balanceCounter = 0;
} }
public List<String> getCurrenciesName()
{
List<String> currenciesName = new ArrayList<>();
for (String symbol : coinInfosHashmap.keySet())
{
try {
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
currenciesName.add(jsonObject.getString("CoinName"));
} catch (JSONException e) {
e.printStackTrace();
}
}
return currenciesName;
}
public List<String> getBiggestCurrencies() public List<String> getBiggestCurrencies()
{ {
List<String> currenciesDetails = new ArrayList<>(); List<String> currenciesDetails = new ArrayList<>();
int index = 0; int index = 0;
Iterator<String> coinIterator = coinInfosHashmap.keySet().iterator(); Iterator<String> coinIterator = currencyDetailsList.getCoinInfosHashmap().keySet().iterator();
while(index < 11) while(index < 11)
{ {
@ -103,28 +89,6 @@ public class BalanceManager {
return currenciesDetails; return currenciesDetails;
} }
public List<String> getOrders()
{
List<String> currenciesOrder = new ArrayList<>();
for(String symbol : coinInfosHashmap.keySet())
{
try {
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
currenciesOrder.add(jsonObject.getString("SortOrder"));
} catch (JSONException e) {
e.printStackTrace();
}
}
return currenciesOrder;
}
public List<String> getCurrenciesSymbol()
{
return new ArrayList<>(coinInfosHashmap.keySet());
}
public void updateExchangeKeys() public void updateExchangeKeys()
{ {
String publicKey = preferenceManager.getHitBTCPublicKey(); String publicKey = preferenceManager.getHitBTCPublicKey();
@ -289,7 +253,8 @@ public class BalanceManager {
public void updateDetails(final IconCallBack callBack) public void updateDetails(final IconCallBack callBack)
{ {
StringRequest strRequest = new StringRequest(Request.Method.GET, detailUrl, currencyDetailsList.update(callBack);
/*StringRequest strRequest = new StringRequest(Request.Method.GET, detailUrl,
new Response.Listener<String>() { new Response.Listener<String>() {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
@ -305,7 +270,7 @@ public class BalanceManager {
} }
}); });
requestQueue.add(strRequest); requestQueue.add(strRequest);*/
} }
public String getIconUrl(String symbol) public String getIconUrl(String symbol)
@ -313,7 +278,7 @@ public class BalanceManager {
String url; String url;
try { try {
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol)); JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50"; url = "https://www.cryptocompare.com" + jsonObject.getString("ImageUrl") + "?width=50";
} catch (NullPointerException e) { } catch (NullPointerException e) {
Log.d(context.getResources().getString(R.string.debug), symbol + " has no icon URL"); Log.d(context.getResources().getString(R.string.debug), symbol + " has no icon URL");
@ -331,7 +296,7 @@ public class BalanceManager {
String currencyName = null; String currencyName = null;
try { try {
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol)); JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
currencyName = jsonObject.getString("CoinName"); currencyName = jsonObject.getString("CoinName");
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
@ -345,7 +310,7 @@ public class BalanceManager {
int id = 0; int id = 0;
try { try {
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol)); JSONObject jsonObject = new JSONObject(currencyDetailsList.getCoinInfosHashmap().get(symbol));
id = jsonObject.getInt("Id"); id = jsonObject.getInt("Id");
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
@ -354,32 +319,6 @@ public class BalanceManager {
return id; return id;
} }
private void processDetailResult(String response, final IconCallBack callBack)
{
response = response.substring(response.indexOf("\"Data\"") + 7, response.lastIndexOf("},\"Type\":100}"));
String[] tab = response.split(Pattern.quote("},"));
coinInfosHashmap = new LinkedHashMap<>();
for(int i = 0; i < tab.length; i++)
{
tab[i] = tab[i].substring(tab[i].indexOf("\":{")+2, tab[i].length()) + "}";
try {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
JSONObject jsonObject = new JSONObject(tab[i]);
coinInfosHashmap.put(jsonObject.getString("Symbol"), tab[i]);
} catch (JSONException e) {
Log.d(context.getResources().getString(R.string.debug), "ImageUrl not found.");
}
}
sortDetails();
callBack.onSuccess();
}
private void sortDetails() private void sortDetails()
{ {
LinkedHashMap<String, String> sortedHashmap = new LinkedHashMap<>(); LinkedHashMap<String, String> sortedHashmap = new LinkedHashMap<>();

@ -28,21 +28,12 @@ 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;
public Currency(Currency currency) private int totalSupply;
{ private double marketCapitalization;
this.id = currency.id; private List<String> socialMediaLinks;
this.name = currency.name; private String algorithm;
this.symbol = currency.symbol; //private String proofType
this.value = currency.value;
this.balance = currency.balance;
this.dayFluctuationPercentage = currency.getDayFluctuationPercentage();
this.dayFluctuation = currency.getDayFluctuation();
this.historyMinutes = currency.historyMinutes;
this.dataRetriver = currency.getDataRetriver();
this.icon = currency.icon;
this.chartColor = currency.chartColor;
}
public Currency(String symbol, double balance) public Currency(String symbol, double balance)
{ {
@ -63,6 +54,8 @@ public class Currency implements Parcelable {
this.symbol = symbol; this.symbol = symbol;
} }
//public Currency(int id, String symbol, String name, String algorithm, String proofType, )
public void getTimestampPrice(android.content.Context context, final PriceCallBack callBack, long timestamp) public void getTimestampPrice(android.content.Context context, final PriceCallBack callBack, long timestamp)
{ {
dataRetriver = new CurrencyDataRetriever(context); dataRetriver = new CurrencyDataRetriever(context);
@ -137,6 +130,12 @@ public class Currency implements Parcelable {
}, CurrencyDataRetriever.DAYS); }, CurrencyDataRetriever.DAYS);
} }
public void updateDetails(android.content.Context context, final CurrencyCallBack callBack)
{
dataRetriver = new CurrencyDataRetriever(context);
}
public void setId(int id) public void setId(int id)
{ {
this.id = id; this.id = id;

@ -182,6 +182,32 @@ public class CurrencyDataRetriever {
} }
} }
/*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);

@ -0,0 +1,149 @@
package com.nauk.coinfolio.DataManagers.CurrencyData;
import android.os.StrictMode;
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 com.nauk.coinfolio.Activities.HomeActivity;
import com.nauk.coinfolio.DataManagers.BalanceManager;
import com.nauk.coinfolio.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.regex.Pattern;
/**
* Created by Tiji on 11/04/2018.
*/
public class CurrencyDetailsList {
final private static String DETAILURL = "https://www.cryptocompare.com/api/data/coinlist/";
private RequestQueue requestQueue;
private LinkedHashMap<String, String> coinInfosHashmap;
private android.content.Context context;
public CurrencyDetailsList(android.content.Context context)
{
this.context = context;
requestQueue = Volley.newRequestQueue(context);
}
public void update(final BalanceManager.IconCallBack callBack)
{
StringRequest strRequest = new StringRequest(Request.Method.GET, DETAILURL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
if (response.length() > 0) {
processDetailResult(response, callBack);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue.add(strRequest);
}
private void processDetailResult(String response, final BalanceManager.IconCallBack callBack)
{
response = response.substring(response.indexOf("\"Data\"") + 7, response.lastIndexOf("},\"Type\":100}"));
String[] tab = response.split(Pattern.quote("},"));
coinInfosHashmap = new LinkedHashMap<>();
for(int i = 0; i < tab.length; i++)
{
tab[i] = tab[i].substring(tab[i].indexOf("\":{")+2, tab[i].length()) + "}";
try {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
JSONObject jsonObject = new JSONObject(tab[i]);
coinInfosHashmap.put(jsonObject.getString("Symbol"), tab[i]);
} catch (JSONException e) {
Log.d(context.getResources().getString(R.string.debug), "ImageUrl not found.");
}
}
sortDetails();
callBack.onSuccess();
}
private void sortDetails()
{
LinkedHashMap<String, String> sortedHashmap = new LinkedHashMap<>();
List<String> listInfos = new ArrayList<>(coinInfosHashmap.values());
List<String> listSymbols = new ArrayList<>(coinInfosHashmap.keySet());
for(int i = 0; i < coinInfosHashmap.keySet().size(); i++)
{
try {
JSONObject jsonObject = new JSONObject(listInfos.get(i));
int index = jsonObject.getInt("SortOrder");
listInfos.add(index, listInfos.get(i));
listSymbols.add(index, listSymbols.get(i));
} catch (JSONException e) {
e.printStackTrace();
}
}
for(int i = 0; i < listInfos.size(); i++)
{
sortedHashmap.put(listSymbols.get(i), listInfos.get(i));
}
coinInfosHashmap = sortedHashmap;
}
public LinkedHashMap<String, String> getCoinInfosHashmap() {
return coinInfosHashmap;
}
public List<String> getCurrenciesName()
{
List<String> currenciesName = new ArrayList<>();
for (String symbol : coinInfosHashmap.keySet())
{
try {
JSONObject jsonObject = new JSONObject(coinInfosHashmap.get(symbol));
currenciesName.add(jsonObject.getString("CoinName"));
} catch (JSONException e) {
e.printStackTrace();
}
}
return currenciesName;
}
public Currency getCurrencyDetailsFromSymbol(String symbol)
{
//Currency currency = new Currency();
return null;
}
public List<String> getCurrenciesSymbol()
{
return new ArrayList<>(coinInfosHashmap.keySet());
}
}

@ -77,8 +77,6 @@ public class BinanceManager {
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(publicKey, privateKey); BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(publicKey, privateKey);
BinanceApiRestClient client = factory.newRestClient(); BinanceApiRestClient client = factory.newRestClient();
Log.d("coinfolio", symbol + pairSymbol);
if(!symbol.equals(pairSymbol)) if(!symbol.equals(pairSymbol))
{ {
try { try {
@ -102,16 +100,6 @@ public class BinanceManager {
return presentTrades; return presentTrades;
} }
public void setPublicKey(String publicKey)
{
this.publicKey = publicKey;
}
public void setPrivateKey(String privateKey)
{
this.privateKey = privateKey;
}
public List<Currency> getBalance() public List<Currency> getBalance()
{ {
return balance; return balance;

@ -110,16 +110,6 @@ public class HitBtcManager {
} }
} }
public void setPublicKey(String publicKey)
{
this.publicKey = publicKey;
}
private void setPrivateKey(String privateKey)
{
this.privateKey = privateKey;
}
public List<Currency> getBalance() public List<Currency> getBalance()
{ {
return balance; return balance;

@ -24,7 +24,6 @@ public class MarketCapManager {
private static final String topCurrenciesUrl = "https://api.coinmarketcap.com/v1/ticker/?limit=9"; 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 static final String marketCapUrl = "https://api.coinmarketcap.com/v1/global/";
private android.content.Context context;
private RequestQueue requestQueue; private RequestQueue requestQueue;
private String topRequestResult[]; private String topRequestResult[];
private long marketCap; private long marketCap;
@ -32,8 +31,6 @@ public class MarketCapManager {
public MarketCapManager(android.content.Context context) public MarketCapManager(android.content.Context context)
{ {
this.context = context;
requestQueue = Volley.newRequestQueue(context); requestQueue = Volley.newRequestQueue(context);
} }

@ -14,23 +14,14 @@ public class PreferencesManager {
private SharedPreferences settingPreferences; private SharedPreferences settingPreferences;
private SharedPreferences currencyList; private SharedPreferences currencyList;
private SharedPreferences preferencesList; private SharedPreferences preferencesList;
android.content.Context context;
public PreferencesManager(android.content.Context context) public PreferencesManager(android.content.Context context)
{ {
this.context = context;
settingPreferences = PreferenceManager.getDefaultSharedPreferences(context); settingPreferences = PreferenceManager.getDefaultSharedPreferences(context);
currencyList = context.getSharedPreferences(currencyListFile, 0); currencyList = context.getSharedPreferences(currencyListFile, 0);
preferencesList = context.getSharedPreferences(preferencesFile, 0); preferencesList = context.getSharedPreferences(preferencesFile, 0);
} }
public void addCurrency(String symbol, double balance)
{
SharedPreferences.Editor editor = currencyList.edit();
editor.putString(symbol, String.valueOf(balance));
editor.apply();
}
public void setDetailOption(boolean isExtended) public void setDetailOption(boolean isExtended)
{ {
SharedPreferences.Editor editor = preferencesList.edit(); SharedPreferences.Editor editor = preferencesList.edit();

@ -80,7 +80,7 @@ public class HomeLayoutGenerator {
return view; return view;
} }
public static void expand(final View v) { private static void expand(final View v) {
v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT); v.measure(CardView.LayoutParams.MATCH_PARENT, CardView.LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight(); final int targetHeight = v.getMeasuredHeight();
@ -108,7 +108,7 @@ public class HomeLayoutGenerator {
v.startAnimation(a); v.startAnimation(a);
} }
public static void collapse(final View v) { private static void collapse(final View v) {
final int initialHeight = v.getMeasuredHeight(); final int initialHeight = v.getMeasuredHeight();
Animation a = new Animation() Animation a = new Animation()

@ -19,11 +19,18 @@
android:layout_gravity="center|top" android:layout_gravity="center|top"
android:background="@color/listBackground"/> android:background="@color/listBackground"/>
<LinearLayout
android:id="@+id/listContainerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<ListView <ListView
android:id="@+id/coinsPreview" android:id="@+id/coinsPreview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"/>
android:visibility="gone"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/currencyListProgressBar" android:id="@+id/currencyListProgressBar"

@ -183,158 +183,149 @@
<LinearLayout <LinearLayout
android:id="@+id/llCharts" android:id="@+id/llCharts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="vertical"
android:layout_weight="0.16"> android:layout_weight="0.16">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="Beginning price" android:text="Beginning price"
android:layout_weight="0.75"/> android:layout_weight="0.5"
android:textStyle="bold"/>
<TextView <TextView
android:id="@+id/txtViewPriceStart" android:id="@+id/txtViewPriceStart"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight="0.5"/>
android:layout_weight="0.25"/>
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/separationLineSize"
android:background="@color/separationColor"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="vertical"
android:layout_weight="0.16"> android:layout_weight="0.16">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="Current price" android:text="Current price"
android:layout_weight="0.75"/> android:layout_weight="0.5"
android:textStyle="bold"/>
<TextView <TextView
android:id="@+id/txtViewPriceNow" android:id="@+id/txtViewPriceNow"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight="0.5"/>
android:layout_weight="0.25"/>
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/separationLineSize"
android:background="@color/separationColor"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="vertical"
android:layout_weight="0.16"> android:layout_weight="0.16">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="Delta" android:text="Delta"
android:layout_weight="0.75"/> android:layout_weight="0.5"
android:textStyle="bold"/>
<TextView <TextView
android:id="@+id/txtViewPercentage" android:id="@+id/txtViewPercentage"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight="0.5"/>
android:layout_weight="0.25"/>
</LinearLayout> </LinearLayout>
<View </LinearLayout>
android:layout_width="match_parent"
android:layout_height="@dimen/separationLineSize"
android:background="@color/separationColor"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:layout_weight="0.5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="0.16"> android:layout_weight="0.16">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="Total volume" android:text="Total volume"
android:layout_weight="0.75"/> android:layout_weight="0.5"
android:textStyle="bold"/>
<TextView <TextView
android:id="@+id/totalVolume" android:id="@+id/totalVolume"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight="0.5" />
android:layout_weight="0.25" />
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/separationLineSize"
android:background="@color/separationColor"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="vertical"
android:layout_weight="0.16"> android:layout_weight="0.16">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="Highest price" android:text="Highest price"
android:layout_weight="0.75" /> android:layout_weight="0.5"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/highestPrice" android:id="@+id/highestPrice"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight="0.5" />
android:layout_weight="0.25" />
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/separationLineSize"
android:background="@color/separationColor"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="vertical"
android:layout_weight="0.16"> android:layout_weight="0.16">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="Lowest price" android:text="Lowest price"
android:layout_weight="0.75"/> android:layout_weight="0.5"
android:textStyle="bold"/>
<TextView <TextView
android:id="@+id/lowestPrice" android:id="@+id/lowestPrice"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:layout_weight="0.5" />
android:layout_weight="0.25" />
</LinearLayout>
</LinearLayout> </LinearLayout>
@ -346,15 +337,88 @@
<LinearLayout <LinearLayout
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="match_parent"
android:orientation="vertical">
<ProgressBar <ProgressBar
android:id="@+id/progressBar" android:id="@+id/currencyPortfolioDominance"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="?android:attr/progressBarStyleLarge" style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_gravity="center" android:visibility="invisible"
android:background="@drawable/circular_progress_bar" /> android:background="@color/colorAccent"
android:padding="@dimen/mdtp_ampm_left_padding"/>
<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="Total supply"
android:textStyle="bold"/>
<TextView
android:id="@+id/txtViewTotalSupply"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</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="Circulating supply"
android:textStyle="bold"/>
<TextView
android:id="@+id/txtViewCirculatingSupply"
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_weight="0.5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Market capitalizaion"
android:textStyle="bold"/>
<TextView
android:id="@+id/txtViewMarketCapitalization"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

@ -61,7 +61,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/quick_button" android:text="@string/quick_button"
android:visibility="visible" android:visibility="visible"
android:layout_gravity="start"/> android:layout_gravity="start"
android:contentDescription="Switch view"/>
<ImageButton <ImageButton
android:id="@+id/settings_button" android:id="@+id/settings_button"
@ -69,7 +70,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/action_settings" android:text="@string/action_settings"
android:visibility="visible" android:visibility="visible"
android:layout_gravity="end"/> android:layout_gravity="end"
android:contentDescription="Settings"/>
</FrameLayout> </FrameLayout>

@ -19,4 +19,6 @@
<dimen name="separationLineSize">1dp</dimen> <dimen name="separationLineSize">1dp</dimen>
<dimen name="cardview_elevation">8dp</dimen> <dimen name="cardview_elevation">8dp</dimen>
<dimen name="toolbar_height">56dp</dimen>
<dimen name="toolbar_height_expand">70dp</dimen>
</resources> </resources>