Merge branch 'master' of https://github.com/Agorise/crystal-wallet-android
This commit is contained in:
commit
5146bc818c
8 changed files with 114 additions and 3 deletions
|
@ -47,7 +47,8 @@ public class IntroActivity extends AppCompatActivity {
|
||||||
if (accountSeedListViewModel.accountSeedsCount() == 0){
|
if (accountSeedListViewModel.accountSeedsCount() == 0){
|
||||||
//If the user doesn't have any seeds created, then
|
//If the user doesn't have any seeds created, then
|
||||||
//send the user to create/import an account
|
//send the user to create/import an account
|
||||||
Intent intent = new Intent(this, AccountSeedsManagementActivity.class);
|
//Intent intent = new Intent(this, AccountSeedsManagementActivity.class);
|
||||||
|
Intent intent = new Intent(this, ImportSeedActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(this, BoardActivity.class);
|
Intent intent = new Intent(this, BoardActivity.class);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cy.agorise.crystalwallet.dao;
|
package cy.agorise.crystalwallet.dao;
|
||||||
|
|
||||||
|
import android.arch.lifecycle.LiveData;
|
||||||
import android.arch.persistence.room.Dao;
|
import android.arch.persistence.room.Dao;
|
||||||
import android.arch.persistence.room.Insert;
|
import android.arch.persistence.room.Insert;
|
||||||
import android.arch.persistence.room.OnConflictStrategy;
|
import android.arch.persistence.room.OnConflictStrategy;
|
||||||
|
@ -23,6 +24,9 @@ public interface CryptoCurrencyEquivalenceDao {
|
||||||
@Query("SELECT * FROM crypto_currency_equivalence WHERE id = :id")
|
@Query("SELECT * FROM crypto_currency_equivalence WHERE id = :id")
|
||||||
CryptoCurrencyEquivalence getById(long id);
|
CryptoCurrencyEquivalence getById(long id);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM crypto_currency_equivalence WHERE from_crypto_currency_id = :fromCurrencyId AND to_crypto_currency_id = :toCurrencyId")
|
||||||
|
LiveData<CryptoCurrencyEquivalence> getByFromTo(long fromCurrencyId, long toCurrencyId);
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
public long[] insertCryptoCurrencyEquivalence(CryptoCurrencyEquivalence... currenciesEquivalences);
|
public long[] insertCryptoCurrencyEquivalence(CryptoCurrencyEquivalence... currenciesEquivalences);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package cy.agorise.crystalwallet.viewmodels;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.arch.lifecycle.AndroidViewModel;
|
||||||
|
import android.arch.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoNetBalance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Henry Varona on 27/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CryptoCurrencyEquivalenceListViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
|
private List<CryptoCurrencyEquivalence> cryptoCurrencyEquivalenceList;
|
||||||
|
private CrystalDatabase db;
|
||||||
|
|
||||||
|
public CryptoCurrencyEquivalenceListViewModel(Application application) {
|
||||||
|
super(application);
|
||||||
|
this.db = CrystalDatabase.getAppDatabase(application.getApplicationContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(){
|
||||||
|
this.cryptoCurrencyEquivalenceList = this.db.cryptoCurrencyEquivalenceDao().getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CryptoCurrencyEquivalence> getCryptoCurrencyEquivalenceList(){
|
||||||
|
return this.cryptoCurrencyEquivalenceList;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package cy.agorise.crystalwallet.viewmodels;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.arch.lifecycle.AndroidViewModel;
|
||||||
|
import android.arch.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Henry Varona on 4/11/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CryptoCurrencyEquivalenceViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
|
private LiveData<CryptoCurrencyEquivalence> cryptoCurrencyEquivalence;
|
||||||
|
private CrystalDatabase db;
|
||||||
|
|
||||||
|
public CryptoCurrencyEquivalenceViewModel(Application application) {
|
||||||
|
super(application);
|
||||||
|
this.db = CrystalDatabase.getAppDatabase(application.getApplicationContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(long fromCurrency, long toCurrency){
|
||||||
|
this.cryptoCurrencyEquivalence = this.db.cryptoCurrencyEquivalenceDao().getByFromTo(fromCurrency,toCurrency);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<CryptoCurrencyEquivalence> getCryptoCurrencyEquivalence(){
|
||||||
|
return this.cryptoCurrencyEquivalence;
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,7 +51,7 @@ public class CryptoCoinBalanceListView extends RelativeLayout {
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
rootView = mInflater.inflate(R.layout.crypto_coin_balance_list, this, true);
|
rootView = mInflater.inflate(R.layout.crypto_coin_balance_list, this, true);
|
||||||
this.listView = (RecyclerView) rootView.findViewById(R.id.cryptoCoinBalanceListView);
|
this.listView = (RecyclerView) rootView.findViewById(R.id.cryptoCoinBalanceListView);
|
||||||
|
|
||||||
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getContext());
|
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getContext());
|
||||||
this.listView.setLayoutManager(linearLayoutManager);
|
this.listView.setLayoutManager(linearLayoutManager);
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package cy.agorise.crystalwallet.views;
|
package cy.agorise.crystalwallet.views;
|
||||||
|
|
||||||
|
import android.arch.lifecycle.LifecycleOwner;
|
||||||
|
import android.arch.lifecycle.LiveData;
|
||||||
|
import android.arch.lifecycle.Observer;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -10,6 +14,7 @@ import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Henry Varona on 17/9/2017.
|
* Created by Henry Varona on 17/9/2017.
|
||||||
|
@ -18,12 +23,14 @@ import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||||
public class CryptoCoinBalanceViewHolder extends RecyclerView.ViewHolder {
|
public class CryptoCoinBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
private TextView cryptoCoinName;
|
private TextView cryptoCoinName;
|
||||||
private TextView cryptoCoinBalance;
|
private TextView cryptoCoinBalance;
|
||||||
|
private TextView cryptoCoinBalanceEquivalence;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public CryptoCoinBalanceViewHolder(View itemView) {
|
public CryptoCoinBalanceViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
cryptoCoinName = (TextView) itemView.findViewById(R.id.tvCryptoCoinName);
|
cryptoCoinName = (TextView) itemView.findViewById(R.id.tvCryptoCoinName);
|
||||||
cryptoCoinBalance = (TextView) itemView.findViewById(R.id.tvCryptoCoinBalanceAmount);
|
cryptoCoinBalance = (TextView) itemView.findViewById(R.id.tvCryptoCoinBalanceAmount);
|
||||||
|
cryptoCoinBalanceEquivalence = (TextView) itemView.findViewById(R.id.tvCryptoCoinBalanceEquivalence);
|
||||||
this.context = itemView.getContext();
|
this.context = itemView.getContext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,17 +38,36 @@ public class CryptoCoinBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
public void clear(){
|
public void clear(){
|
||||||
cryptoCoinName.setText("loading...");
|
cryptoCoinName.setText("loading...");
|
||||||
cryptoCoinBalance.setText("");
|
cryptoCoinBalance.setText("");
|
||||||
|
cryptoCoinBalanceEquivalence.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindTo(final CryptoCoinBalance balance/*, final OnTransactionClickListener listener*/) {
|
public void bindTo(final CryptoCoinBalance balance/*, final OnTransactionClickListener listener*/) {
|
||||||
if (balance == null){
|
if (balance == null){
|
||||||
cryptoCoinName.setText("loading...");
|
cryptoCoinName.setText("loading...");
|
||||||
cryptoCoinBalance.setText("");
|
cryptoCoinBalance.setText("");
|
||||||
|
cryptoCoinBalanceEquivalence.setText("");
|
||||||
} else {
|
} else {
|
||||||
CryptoCurrency currency = CrystalDatabase.getAppDatabase(this.context).cryptoCurrencyDao().getById(balance.getCryptoCurrencyId());
|
CryptoCurrency currency = CrystalDatabase.getAppDatabase(this.context).cryptoCurrencyDao().getById(balance.getCryptoCurrencyId());
|
||||||
|
CryptoCurrency currencyBitEur = CrystalDatabase.getAppDatabase(this.context).cryptoCurrencyDao().getByName("EUR");
|
||||||
|
|
||||||
|
LiveData<CryptoCurrencyEquivalence> currencyEquivalenceLiveData = CrystalDatabase.getAppDatabase(this.context)
|
||||||
|
.cryptoCurrencyEquivalenceDao().getByFromTo(
|
||||||
|
currency.getId(),
|
||||||
|
currencyBitEur.getId()
|
||||||
|
);
|
||||||
|
|
||||||
cryptoCoinName.setText(currency.getName());
|
cryptoCoinName.setText(currency.getName());
|
||||||
cryptoCoinBalance.setText(""+balance.getBalance());
|
cryptoCoinBalance.setText(""+balance.getBalance());
|
||||||
|
|
||||||
|
currencyEquivalenceLiveData.observe((LifecycleOwner) this.context, new Observer<CryptoCurrencyEquivalence>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable CryptoCurrencyEquivalence cryptoCurrencyEquivalence) {
|
||||||
|
if (cryptoCurrencyEquivalence != null){
|
||||||
|
CryptoCurrency toCurrency = CrystalDatabase.getAppDatabase(context).cryptoCurrencyDao().getById(cryptoCurrencyEquivalence.getToCurrencyId());
|
||||||
|
cryptoCoinBalanceEquivalence.setText(cryptoCurrencyEquivalence.getValue()+" "+toCurrency.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.activities.SendTransactionActivity;
|
import cy.agorise.crystalwallet.activities.SendTransactionActivity;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetBalance;
|
import cy.agorise.crystalwallet.models.CryptoNetBalance;
|
||||||
import cy.agorise.crystalwallet.viewmodels.CryptoCoinBalanceListViewModel;
|
import cy.agorise.crystalwallet.viewmodels.CryptoCoinBalanceListViewModel;
|
||||||
|
|
||||||
|
@ -99,6 +100,7 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
CryptoCoinBalanceListViewModel cryptoCoinBalanceListViewModel = ViewModelProviders.of(this.fragment).get(CryptoCoinBalanceListViewModel.class);
|
CryptoCoinBalanceListViewModel cryptoCoinBalanceListViewModel = ViewModelProviders.of(this.fragment).get(CryptoCoinBalanceListViewModel.class);
|
||||||
cryptoCoinBalanceListViewModel.init(balance.getAccountId());
|
cryptoCoinBalanceListViewModel.init(balance.getAccountId());
|
||||||
LiveData<List<CryptoCoinBalance>> cryptoCoinBalanceData = cryptoCoinBalanceListViewModel.getCryptoCoinBalanceList();
|
LiveData<List<CryptoCoinBalance>> cryptoCoinBalanceData = cryptoCoinBalanceListViewModel.getCryptoCoinBalanceList();
|
||||||
|
|
||||||
cryptoCoinBalanceListView.setData(null);
|
cryptoCoinBalanceListView.setData(null);
|
||||||
|
|
||||||
cryptoCoinBalanceData.observe((LifecycleOwner)this.itemView.getContext(), new Observer<List<CryptoCoinBalance>>() {
|
cryptoCoinBalanceData.observe((LifecycleOwner)this.itemView.getContext(), new Observer<List<CryptoCoinBalance>>() {
|
||||||
|
|
|
@ -27,6 +27,17 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:text="0.00000000" />
|
android:text="0.00000000"
|
||||||
|
android:textAlignment="textEnd" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvCryptoCoinBalanceEquivalence"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_below="@+id/tvCryptoCoinBalanceAmount"
|
||||||
|
android:ems="10"
|
||||||
|
android:text=""
|
||||||
|
android:textAlignment="textEnd" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in a new issue