- The send activity can be reached in the balance view

- Fixing the Currency Adapter Labels
This commit is contained in:
Javier Varona 2017-11-01 12:26:52 -04:00
parent 2590bb42ed
commit 60ef2eb4ba
5 changed files with 114 additions and 12 deletions

View file

@ -0,0 +1,85 @@
package cy.agorise.crystalwallet.activities;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.Observer;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnItemSelected;
import butterknife.OnTextChanged;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateBitsharesSendRequest;
import cy.agorise.crystalwallet.dao.CrystalDatabase;
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
import cy.agorise.crystalwallet.models.CryptoCurrency;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
import cy.agorise.crystalwallet.models.GrapheneAccount;
import cy.agorise.crystalwallet.viewmodels.validators.SendTransactionValidator;
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
import cy.agorise.crystalwallet.views.CryptoCurrencyAdapter;
public class ReceiveTransactionActivity extends AppCompatActivity {
@BindView(R.id.tvReceiveAddress)
TextView tvReceiveAddress;
private long cryptoNetAccountId;
private CryptoNetAccount cryptoNetAccount;
private GrapheneAccount grapheneAccount;
private CrystalDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.receive_transaction);
ButterKnife.bind(this);
this.cryptoNetAccountId = getIntent().getLongExtra("CRYPTO_NET_ACCOUNT_ID", -1);
if (this.cryptoNetAccountId != -1) {
db = CrystalDatabase.getAppDatabase(this);
this.cryptoNetAccount = db.cryptoNetAccountDao().getById(this.cryptoNetAccountId);
/*
* this is only for graphene accounts.
*
**/
this.grapheneAccount = new GrapheneAccount(this.cryptoNetAccount);
this.grapheneAccount.loadInfo(db.grapheneAccountInfoDao().getByAccountId(this.cryptoNetAccountId));
final LiveData<List<CryptoCoinBalance>> balancesList = db.cryptoCoinBalanceDao().getBalancesFromAccount(cryptoNetAccountId);
balancesList.observe(this, new Observer<List<CryptoCoinBalance>>() {
@Override
public void onChanged(@Nullable List<CryptoCoinBalance> cryptoCoinBalances) {
ArrayList<Long> assetIds = new ArrayList<Long>();
for (CryptoCoinBalance nextBalance : balancesList.getValue()) {
assetIds.add(nextBalance.getCryptoCurrencyId());
}
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
CryptoCurrencyAdapter assetAdapter = new CryptoCurrencyAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
//spAsset.setAdapter(assetAdapter);
}
});
//sendTransactionValidator = new SendTransactionValidator(this.getApplicationContext(), this.cryptoNetAccount, etFrom, etTo, spAsset, etAmount, etMemo);
//sendTransactionValidator.setListener(this);
} else {
this.finish();
}
}
}

View file

@ -38,6 +38,7 @@ import cy.agorise.crystalwallet.viewmodels.GrapheneAccountInfoViewModel;
import cy.agorise.crystalwallet.viewmodels.validators.SendTransactionValidator;
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
import cy.agorise.crystalwallet.viewmodels.validators.validationfields.ValidationField;
import cy.agorise.crystalwallet.views.CryptoCurrencyAdapter;
public class SendTransactionActivity extends AppCompatActivity implements UIValidatorListener {
@ -100,16 +101,12 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
@Override
public void onChanged(@Nullable List<CryptoCoinBalance> cryptoCoinBalances) {
ArrayList<Long> assetIds = new ArrayList<Long>();
ArrayList<String> assetLabels = new ArrayList<String>();
for (CryptoCoinBalance nextBalance : balancesList.getValue()) {
assetIds.add(nextBalance.getCryptoCurrencyId());
}
List<CryptoCurrency> cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds);
for (CryptoCurrency nextCurrency : cryptoCurrencyList) {
assetLabels.add(nextCurrency.getName());
}
ArrayAdapter<String> assetAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, assetLabels);
CryptoCurrencyAdapter assetAdapter = new CryptoCurrencyAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList);
spAsset.setAdapter(assetAdapter);
}
});

View file

@ -1,8 +1,6 @@
package cy.agorise.crystalwallet.views;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -26,6 +24,11 @@ public class CryptoCurrencyAdapter extends ArrayAdapter<CryptoCurrency> {
this.data = objects;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
return getView(position, convertView, parent);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvReceiveAddress"/>
</LinearLayout>

View file

@ -19,7 +19,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvFromError"/>
android:id="@+id/tvFromError"
android:textColor="@color/red" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -35,7 +36,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvToError"/>
android:id="@+id/tvToError"
android:textColor="@color/red" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -51,7 +53,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvAssetError"/>
android:id="@+id/tvAssetError"
android:textColor="@color/red" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -67,7 +70,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvAmountError"/>
android:id="@+id/tvAmountError"
android:textColor="@color/red" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -83,7 +87,8 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvMemoError"/>
android:id="@+id/tvMemoError"
android:textColor="@color/red" />
<Button
android:id="@+id/btnCancel"
android:layout_width="match_parent"