diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/CurrencySelectionActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/CurrencySelectionActivity.java index a981d9e..ac2486a 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/CurrencySelectionActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/CurrencySelectionActivity.java @@ -3,6 +3,7 @@ package com.nauk.coinfolio.Activities; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.util.Log; import android.view.Menu; import android.view.View; import android.view.Window; @@ -46,9 +47,10 @@ public class CurrencySelectionActivity extends AppCompatActivity { searchAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { + Currency selectedCurrency = (Currency) adapterView.getItemAtPosition(i); Intent intent = new Intent(CurrencySelectionActivity.this, RecordTransactionActivity.class); - intent.putExtra("coin", searchAutoComplete.getText().toString()); - intent.putExtra("symbol", searchAutoComplete.getCompletionHint().toString()); + intent.putExtra("coin", selectedCurrency.getName()); + intent.putExtra("symbol", selectedCurrency.getSymbol()); startActivity(intent); finish(); } diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java index d1fdf27..4244b4a 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/HomeActivity.java @@ -150,7 +150,6 @@ public class HomeActivity extends AppCompatActivity { }); databaseManager = new DatabaseManager(this); - databaseManager.getAllCurrencyFromManualCurrency(); updateViewButtonIcon(); } @@ -232,7 +231,6 @@ public class HomeActivity extends AppCompatActivity { { currencyLayout.addView(layoutGenerator.getInfoLayout(currency, 12369084)); } - } } } @@ -409,7 +407,7 @@ public class HomeActivity extends AppCompatActivity { final List balance = balanceManager.getTotalBalance(); - if(balanceManager.getTotalBalance().size() < 0) + if(balanceManager.getTotalBalance().size() > 0) { for(int i = 0; i < balanceManager.getTotalBalance().size(); i++) { diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/RecordTransactionActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/RecordTransactionActivity.java index 10aa791..94c167c 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/RecordTransactionActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/RecordTransactionActivity.java @@ -12,11 +12,12 @@ import com.nauk.coinfolio.R; public class RecordTransactionActivity extends AppCompatActivity { - String coin; - String symbol; - TextView symbolTxtView; - Button validateButton; - DatabaseManager databaseManager; + private String coin; + private String symbol; + private TextView symbolTxtView; + private TextView amountTxtView; + private Button validateButton; + private DatabaseManager databaseManager; @Override protected void onCreate(Bundle savedInstanceState) { @@ -33,10 +34,16 @@ public class RecordTransactionActivity extends AppCompatActivity { validateButton = findViewById(R.id.validateButton); + amountTxtView = findViewById(R.id.currencyAmount); + validateButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - //databaseManager.addCurrencyToManualCurrency(); + databaseManager.addCurrencyToManualCurrency(symbol, Double.parseDouble(amountTxtView.getText().toString())); + Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + startActivity(intent); + finish(); } }); } diff --git a/app/src/main/java/com/nauk/coinfolio/DataManagers/BalanceManager.java b/app/src/main/java/com/nauk/coinfolio/DataManagers/BalanceManager.java index eb34738..a919bb2 100644 --- a/app/src/main/java/com/nauk/coinfolio/DataManagers/BalanceManager.java +++ b/app/src/main/java/com/nauk/coinfolio/DataManagers/BalanceManager.java @@ -43,12 +43,13 @@ public class BalanceManager { final private String binanceTimeUrl = "https://api.binance.com/api/v1/time"; private RequestQueue requestQueue; private List hitBalance; - private List otherBalances; + private List manualBalances; private List totalBalance; private android.content.Context context; private Map iconUrlList; private Map coinList; private PreferencesManager preferenceManager; + private DatabaseManager databaseManager; public BalanceManager(android.content.Context context) { @@ -56,7 +57,8 @@ public class BalanceManager { preferenceManager = new PreferencesManager(context); requestQueue = Volley.newRequestQueue(context); hitBalance = new ArrayList(); - otherBalances = new ArrayList(); + manualBalances = new ArrayList(); + databaseManager = new DatabaseManager(context); } public List getCurrenciesName() @@ -107,13 +109,15 @@ public class BalanceManager { return hitBalance; } - public List getOtherBalances() + public List getManualBalances() { - return otherBalances; + return manualBalances; } public void updateTotalBalance(final VolleyCallBack callBack) { + manualBalances = databaseManager.getAllCurrencyFromManualCurrency(); + if(privateHitKey != null && publicHitKey != null && preferenceManager.isHitBTCActivated()) { updateHitBalance(callBack); @@ -190,15 +194,15 @@ public class BalanceManager { totalBalance.addAll(hitBalance); - for(int i = 0; i < otherBalances.size(); i++) + for(int i = 0; i < manualBalances.size(); i++) { boolean isIn = false; for(int j = 0; j < totalBalance.size(); j++) { - if(otherBalances.get(i).getSymbol().equals(totalBalance.get(j).getSymbol())) + if(manualBalances.get(i).getSymbol().equals(totalBalance.get(j).getSymbol())) { - totalBalance.get(j).setBalance(totalBalance.get(j).getBalance() + otherBalances.get(i).getBalance()); + totalBalance.get(j).setBalance(totalBalance.get(j).getBalance() + manualBalances.get(i).getBalance()); isIn = true; } @@ -206,7 +210,7 @@ public class BalanceManager { if(!isIn) { - totalBalance.add(otherBalances.get(i)); + totalBalance.add(manualBalances.get(i)); } } @@ -284,7 +288,7 @@ public class BalanceManager { coinList.put(jsonObject.getString("Symbol"), jsonObject.getString("CoinName")); } catch (JSONException e) { - e.printStackTrace(); + Log.d(context.getResources().getString(R.string.debug), "ImageUrl not found."); } } diff --git a/app/src/main/java/com/nauk/coinfolio/DataManagers/DatabaseManager.java b/app/src/main/java/com/nauk/coinfolio/DataManagers/DatabaseManager.java index 01aa8c6..c4d6889 100644 --- a/app/src/main/java/com/nauk/coinfolio/DataManagers/DatabaseManager.java +++ b/app/src/main/java/com/nauk/coinfolio/DataManagers/DatabaseManager.java @@ -18,7 +18,7 @@ import java.util.List; public class DatabaseManager extends SQLiteOpenHelper{ - private static final int DATABASE_VERSION = 4; + private static final int DATABASE_VERSION = 5; private static final String DATABASE_NAME = "Currencies.db"; @@ -99,9 +99,7 @@ public class DatabaseManager extends SQLiteOpenHelper{ while(resultatList.moveToNext()) { - //Currency currency = new Currency(resultatList.getString(1), resultatList.getString(2)); - Log.d("CrystalVault", "Database result : " + resultatList.getString(1) + " " + resultatList.getString(2) + " " + resultatList.getCount()); - //currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(2))); + currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(3))); } resultatList.close(); diff --git a/app/src/main/java/com/nauk/coinfolio/LayoutManagers/CurrencyAdapter.java b/app/src/main/java/com/nauk/coinfolio/LayoutManagers/CurrencyAdapter.java index fda78eb..3cfcd35 100644 --- a/app/src/main/java/com/nauk/coinfolio/LayoutManagers/CurrencyAdapter.java +++ b/app/src/main/java/com/nauk/coinfolio/LayoutManagers/CurrencyAdapter.java @@ -54,7 +54,6 @@ public class CurrencyAdapter extends ArrayAdapter { return convertView; } - @Override public Filter getFilter() { return myFilter; diff --git a/app/src/main/res/layout/activity_record_transaction.xml b/app/src/main/res/layout/activity_record_transaction.xml index 1509b01..5ac28cc 100644 --- a/app/src/main/res/layout/activity_record_transaction.xml +++ b/app/src/main/res/layout/activity_record_transaction.xml @@ -18,6 +18,7 @@ android:textSize="25dp"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6198ca5..6a7d52c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,8 +2,8 @@ Coinfolio Settings Fais un don wallah - CrystalVault_debug - CrystalVault_debugVolley + Coinfolio_debug + Coinfolio_debugVolley Switch view Settings @@ -115,5 +115,5 @@ Amount - Purchased prive + Purchased price