- Added balances views (still in progress...)

This commit is contained in:
Javier Varona 2017-10-09 22:45:48 -04:00
parent ea63139809
commit 570ec785f9
14 changed files with 421 additions and 9 deletions

View file

@ -20,6 +20,9 @@ public class ValidateExistBitsharesAccountRequest extends CryptoNetInfoRequest {
this.accountName = accountName;
}
public boolean getAccountExists(){
return this.accountExists;
}
public void setAccountExists(boolean value){
this.accountExists = value;

View file

@ -37,7 +37,7 @@ public class BitsharesAccountMnemonicValidationField extends ValidationField {
public void onCarryOut() {
if (!request.getMnemonicIsCorrect()){
setValidForValue(mixedValue, false);
setMessage(validator.getContext().getResources().getString(R.string.account_name_not_exist));
setMessage(validator.getContext().getResources().getString(R.string.error_invalid_account));
validator.validationFailed(field);
} else {
setValidForValue(mixedValue, true);

View file

@ -6,6 +6,7 @@ import android.widget.EditText;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequestListener;
import cy.agorise.crystalwallet.cryptonetinforequests.CryptoNetInfoRequests;
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateExistBitsharesAccountRequest;
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateImportBitsharesAccountRequest;
/**
@ -27,13 +28,13 @@ public class BitsharesAccountNameValidationField extends ValidationField {
this.startValidating();
final ValidationField field = this;
final ValidateImportBitsharesAccountRequest request = new ValidateImportBitsharesAccountRequest(newValue,"");
final ValidateExistBitsharesAccountRequest request = new ValidateExistBitsharesAccountRequest(newValue);
request.setListener(new CryptoNetInfoRequestListener() {
@Override
public void onCarryOut() {
if (!request.getAccountExists()){
setValidForValue(newValue, false);
setMessage(validator.getContext().getResources().getString(R.string.error_invalid_account));
setMessage(validator.getContext().getResources().getString(R.string.account_name_not_exist));
validator.validationFailed(field);
} else {
setValidForValue(newValue, true);

View file

@ -0,0 +1,38 @@
package cy.agorise.crystalwallet.views;
import android.arch.paging.PagedListAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import cy.agorise.crystalwallet.R;
/**
* Created by Henry Varona on 11/9/2017.
*/
public class BalanceListAdapter extends ListAdapter<CryptoNetBalance, BalanceViewHolder> {
public BalanceListAdapter() {
super(CryptoNetBalance.DIFF_CALLBACK);
}
@Override
public BalanceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.balance_list_item,parent,false);
return new BalanceViewHolder(v);
}
@Override
public void onBindViewHolder(BalanceViewHolder holder, int position) {
CryptoNetBalance balance = getItem(position);
if (balance != null) {
holder.bindTo(balance);
} else {
holder.clear();
}
}
}

View file

@ -0,0 +1,72 @@
package cy.agorise.crystalwallet.views;
import android.arch.paging.PagedList;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
/**
* Created by Henry Varona on 10/9/2017.
*/
public class BalanceListView extends RelativeLayout {
LayoutInflater mInflater;
View rootView;
RecyclerView listView;
BalanceListAdapter listAdapter;
BalanceListViewModel balanceListViewModel;
private int visibleThreshold = 5;
private boolean loading = true;
public BalanceListView(Context context){
super(context);
this.mInflater = LayoutInflater.from(context);
init();
}
public BalanceListView(Context context, AttributeSet attrs) {
super(context, attrs);
this.mInflater = LayoutInflater.from(context);
init();
}
public BalanceListView(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
this.mInflater = LayoutInflater.from(context);
init();
}
public void init(){
rootView = mInflater.inflate(R.layout.balance_list, this, true);
this.listView = rootView.findViewById(R.id.balanceListView);
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getContext());
this.listView.setLayoutManager(linearLayoutManager);
this.listView.setNestedScrollingEnabled(false);
}
public void setData(List<CryptoNetBalance> data){
if (this.listAdapter == null) {
this.listAdapter = new BalanceListAdapter();
this.listView.setAdapter(this.listAdapter);
}
if (data != null) {
this.listAdapter.setList(data);
}
}
}

View file

@ -0,0 +1,51 @@
package cy.agorise.crystalwallet.views;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
/**
* Created by Henry Varona on 17/9/2017.
*/
public class BalanceViewHolder extends RecyclerView.ViewHolder {
private TextView cryptoNetIcon;
private TextView cryptoNetName;
private CryptoNetBalanceListView cryptoNetBalanceListView;
public BalanceViewHolder(View itemView) {
super(itemView);
transactionFrom = (TextView) itemView.findViewById(R.id.fromText);
transactionTo = (TextView) itemView.findViewById(R.id.toText);
transactionAmount = (TextView) itemView.findViewById(R.id.amountText);
}
public void clear(){
transactionFrom.setText("loading...");
transactionTo.setText("");
transactionAmount.setText("");
}
public void bindTo(final CryptoCoinTransaction transaction/*, final OnTransactionClickListener listener*/) {
if (transaction == null){
transactionFrom.setText("loading...");
transactionTo.setText("");
transactionAmount.setText("");
} else {
transactionFrom.setText(transaction.getFrom());
transactionTo.setText(transaction.getTo());
transactionAmount.setText("" + transaction.getAmount());
/*itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onUserClick(user);
}
});*/
}
}
}

View file

@ -0,0 +1,37 @@
package cy.agorise.crystalwallet.views;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import cy.agorise.crystalwallet.R;
/**
* Created by Henry Varona on 11/9/2017.
*/
public class CryptoCoinBalanceListAdapter extends ListAdapter<CryptoCoinBalance, CryptoCoinBalanceViewHolder> {
public CryptoCoinBalanceListAdapter() {
super(CryptoCoinBalance.DIFF_CALLBACK);
}
@Override
public CryptoCoinBalanceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.crypto_coin_balance_list_item,parent,false);
return new CryptoCoinBalanceViewHolder(v);
}
@Override
public void onBindViewHolder(CryptoCoinBalanceViewHolder holder, int position) {
CryptoCoinBalance balance = getItem(position);
if (balance != null) {
holder.bindTo(balance);
} else {
holder.clear();
}
}
}

View file

@ -0,0 +1,69 @@
package cy.agorise.crystalwallet.views;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import cy.agorise.crystalwallet.R;
/**
* Created by Henry Varona on 10/9/2017.
*/
public class CryptoCoinBalanceListView extends RelativeLayout {
LayoutInflater mInflater;
View rootView;
RecyclerView listView;
CryptoCoinBalanceListAdapter listAdapter;
CryptoCoinBalanceListViewModel CryptoCoinBalanceListViewModel;
private int visibleThreshold = 5;
private boolean loading = true;
public CryptoCoinBalanceListView(Context context){
super(context);
this.mInflater = LayoutInflater.from(context);
init();
}
public CryptoCoinBalanceListView(Context context, AttributeSet attrs) {
super(context, attrs);
this.mInflater = LayoutInflater.from(context);
init();
}
public CryptoCoinBalanceListView(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
this.mInflater = LayoutInflater.from(context);
init();
}
public void init(){
rootView = mInflater.inflate(R.layout.crypto_coin_balance_list, this, true);
this.listView = rootView.findViewById(R.id.cryptoCoinBalanceListView);
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getContext());
this.listView.setLayoutManager(linearLayoutManager);
this.listView.setNestedScrollingEnabled(false);
}
public void setData(List<CryptoCoinBalance> data){
if (this.listAdapter == null) {
this.listAdapter = new CryptoCoinBalanceListAdapter();
this.listView.setAdapter(this.listAdapter);
}
if (data != null) {
this.listAdapter.setList(data);
}
}
}

View file

@ -0,0 +1,49 @@
package cy.agorise.crystalwallet.views;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
/**
* Created by Henry Varona on 17/9/2017.
*/
public class CryptoCoinBalanceViewHolder extends RecyclerView.ViewHolder {
private TextView cryptoCoinName;
private TextView cryptoCoinBalance;
public CryptoCoinBalanceViewHolder(View itemView) {
super(itemView);
transactionFrom = (TextView) itemView.findViewById(R.id.fromText);
transactionTo = (TextView) itemView.findViewById(R.id.toText);
transactionAmount = (TextView) itemView.findViewById(R.id.amountText);
}
public void clear(){
transactionFrom.setText("loading...");
transactionTo.setText("");
transactionAmount.setText("");
}
public void bindTo(final CryptoCoinTransaction transaction/*, final OnTransactionClickListener listener*/) {
if (transaction == null){
transactionFrom.setText("loading...");
transactionTo.setText("");
transactionAmount.setText("");
} else {
transactionFrom.setText(transaction.getFrom());
transactionTo.setText(transaction.getTo());
transactionAmount.setText("" + transaction.getAmount());
/*itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onUserClick(user);
}
});*/
}
}
}

View file

@ -1,18 +1,14 @@
package cy.agorise.crystalwallet.views;
import android.arch.paging.PagedList;
import android.arch.paging.PagedListAdapter;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
import android.widget.RelativeLayout;
import java.util.List;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
@ -27,7 +23,7 @@ public class TransactionListView extends RelativeLayout {
View rootView;
RecyclerView listView;
TransactionListAdapter listAdapter;
BalanceListAdapter listAdapter;
TransactionListViewModel transactionListViewModel;
@ -80,7 +76,7 @@ public class TransactionListView extends RelativeLayout {
public void setData(PagedList<CryptoCoinTransaction> data){
if (this.listAdapter == null) {
this.listAdapter = new TransactionListAdapter();
this.listAdapter = new BalanceListAdapter();
this.listView.setAdapter(this.listAdapter);
}

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/balanceListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/ivCryptoNetIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/icon_help" />
<TextView
android:id="@+id/tvCryptoNetName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="unknown coin" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/cryptoCoinBalanceListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/tvCryptoCoinName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="unknown coin" />
<TextView
android:id="@+id/tvCryptoCoinBalanceAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="0.00000000" />
</RelativeLayout>
</LinearLayout>