- Transaction search implemented
- Now the transaction list print contact name when the address match with that contact
This commit is contained in:
parent
17dfc3e074
commit
e9e495b366
9 changed files with 167 additions and 67 deletions
|
@ -11,6 +11,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinTransactionExtended;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Henry Varona on 12/9/2017.
|
* Created by Henry Varona on 12/9/2017.
|
||||||
|
@ -18,23 +19,28 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
@Dao
|
@Dao
|
||||||
public interface TransactionDao {
|
public interface TransactionDao {
|
||||||
|
|
||||||
|
static final String transactionsQuery = "SELECT cct.*, cna.name AS user_account_name, c.name AS contact_name FROM crypto_coin_transaction cct " +
|
||||||
|
"LEFT JOIN crypto_net_account cna ON cct.account_id = cna.id " +
|
||||||
|
"LEFT JOIN contact c ON c.id = (SELECT ca.contact_id FROM contact_address ca WHERE ca.address LIKE (CASE is_input WHEN 1 THEN cct.\"from\" ELSE cct.\"to\" END) LIMIT 1) " +
|
||||||
|
"WHERE user_account_name LIKE '%'||:search||'%' OR contact_name LIKE '%'||:search||'%' OR cct.\"from\" LIKE '%'||:search||'%' OR cct.\"to\" LIKE '%'||:search||'%'";
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_transaction")
|
@Query("SELECT * FROM crypto_coin_transaction")
|
||||||
LiveData<List<CryptoCoinTransaction>> getAll();
|
LiveData<List<CryptoCoinTransaction>> getAll();
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_transaction ORDER BY date DESC")
|
@Query(transactionsQuery + " ORDER BY date DESC")
|
||||||
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByDate();
|
LivePagedListProvider<Integer, CryptoCoinTransactionExtended> transactionsByDate(String search);
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_transaction ORDER BY amount DESC")
|
@Query(transactionsQuery + " ORDER BY amount DESC")
|
||||||
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByAmount();
|
LivePagedListProvider<Integer, CryptoCoinTransactionExtended> transactionsByAmount(String search);
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_transaction ORDER BY is_input DESC")
|
@Query(transactionsQuery + " ORDER BY is_input DESC")
|
||||||
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByIsInput();
|
LivePagedListProvider<Integer, CryptoCoinTransactionExtended> transactionsByIsInput(String search);
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_transaction ORDER BY `from` DESC")
|
@Query(transactionsQuery + " ORDER BY `from` DESC")
|
||||||
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByFrom();
|
LivePagedListProvider<Integer, CryptoCoinTransactionExtended> transactionsByFrom(String search);
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_transaction ORDER BY `to` DESC")
|
@Query(transactionsQuery + " ORDER BY `to` DESC")
|
||||||
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByTo();
|
LivePagedListProvider<Integer, CryptoCoinTransactionExtended> transactionsByTo(String search);
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_transaction WHERE account_id = :idAccount ORDER BY date DESC")
|
@Query("SELECT * FROM crypto_coin_transaction WHERE account_id = :idAccount ORDER BY date DESC")
|
||||||
LiveData<List<CryptoCoinTransaction>> getByIdAccountLiveData(long idAccount);
|
LiveData<List<CryptoCoinTransaction>> getByIdAccountLiveData(long idAccount);
|
||||||
|
|
|
@ -25,11 +25,6 @@ import cy.agorise.crystalwallet.viewmodels.validators.PinSecurityValidator;
|
||||||
|
|
||||||
public class NoneSecurityFragment extends Fragment {
|
public class NoneSecurityFragment extends Fragment {
|
||||||
|
|
||||||
GeneralSetting passwordGeneralSetting = new GeneralSetting();
|
|
||||||
GeneralSetting patternGeneralSetting = new GeneralSetting();
|
|
||||||
|
|
||||||
GeneralSettingListViewModel generalSettingListViewModel;
|
|
||||||
|
|
||||||
public NoneSecurityFragment() {
|
public NoneSecurityFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
@ -48,24 +43,6 @@ public class NoneSecurityFragment extends Fragment {
|
||||||
View v = inflater.inflate(R.layout.fragment_none_security, container, false);
|
View v = inflater.inflate(R.layout.fragment_none_security, container, false);
|
||||||
ButterKnife.bind(this, v);
|
ButterKnife.bind(this, v);
|
||||||
|
|
||||||
generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class);
|
|
||||||
LiveData<List<GeneralSetting>> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList();
|
|
||||||
|
|
||||||
generalSettingsLiveData.observe(this, new Observer<List<GeneralSetting>>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(@Nullable List<GeneralSetting> generalSettings) {
|
|
||||||
if (generalSettings != null){
|
|
||||||
for (GeneralSetting generalSetting:generalSettings) {
|
|
||||||
if (generalSetting.getName().equals(GeneralSetting.SETTING_PASSWORD)){
|
|
||||||
passwordGeneralSetting = generalSetting;
|
|
||||||
} else if (generalSetting.getName().equals(GeneralSetting.SETTING_PATTERN)){
|
|
||||||
patternGeneralSetting = generalSetting;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,14 +50,7 @@ public class NoneSecurityFragment extends Fragment {
|
||||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||||
super.setUserVisibleHint(isVisibleToUser);
|
super.setUserVisibleHint(isVisibleToUser);
|
||||||
if (isVisibleToUser) {
|
if (isVisibleToUser) {
|
||||||
setSecurityOff();
|
CrystalSecurityMonitor.getInstance(null).clearSecurity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecurityOff(){
|
|
||||||
generalSettingListViewModel.deleteGeneralSettings(passwordGeneralSetting,patternGeneralSetting);
|
|
||||||
|
|
||||||
CrystalSecurityMonitor.getInstance(null).setPasswordSecurity("");
|
|
||||||
CrystalSecurityMonitor.getInstance(null).setPatternEncrypted("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,12 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.text.Editable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -20,8 +22,10 @@ import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnTextChanged;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinTransactionExtended;
|
||||||
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
|
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
|
||||||
import cy.agorise.crystalwallet.views.TransactionListView;
|
import cy.agorise.crystalwallet.views.TransactionListView;
|
||||||
import cy.agorise.crystalwallet.views.TransactionOrderSpinnerAdapter;
|
import cy.agorise.crystalwallet.views.TransactionOrderSpinnerAdapter;
|
||||||
|
@ -34,12 +38,15 @@ public class TransactionsFragment extends Fragment {
|
||||||
@BindView(R.id.spTransactionsOrder)
|
@BindView(R.id.spTransactionsOrder)
|
||||||
Spinner spTransactionsOrder;
|
Spinner spTransactionsOrder;
|
||||||
|
|
||||||
|
@BindView(R.id.etTransactionSearch)
|
||||||
|
EditText etTransactionSearch;
|
||||||
|
|
||||||
RecyclerView balanceRecyclerView;
|
RecyclerView balanceRecyclerView;
|
||||||
FloatingActionButton fabSend;
|
FloatingActionButton fabSend;
|
||||||
FloatingActionButton fabReceive;
|
FloatingActionButton fabReceive;
|
||||||
|
|
||||||
TransactionListViewModel transactionListViewModel;
|
TransactionListViewModel transactionListViewModel;
|
||||||
LiveData<PagedList<CryptoCoinTransaction>> transactionsLiveData;
|
LiveData<PagedList<CryptoCoinTransactionExtended>> transactionsLiveData;
|
||||||
|
|
||||||
public TransactionsFragment() {
|
public TransactionsFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
|
@ -108,18 +115,24 @@ public class TransactionsFragment extends Fragment {
|
||||||
if (transactionsLiveData != null){
|
if (transactionsLiveData != null){
|
||||||
transactionsLiveData.removeObservers(this);
|
transactionsLiveData.removeObservers(this);
|
||||||
}
|
}
|
||||||
transactionListViewModel.initTransactionList(orderSelected.getField());
|
transactionListViewModel.initTransactionList(orderSelected.getField(),etTransactionSearch.getText().toString());
|
||||||
transactionsLiveData = transactionListViewModel.getTransactionList();
|
transactionsLiveData = transactionListViewModel.getTransactionList();
|
||||||
|
|
||||||
final Fragment fragment = this;
|
final Fragment fragment = this;
|
||||||
transactionsLiveData.observe(this, new Observer<PagedList<CryptoCoinTransaction>>() {
|
transactionsLiveData.observe(this, new Observer<PagedList<CryptoCoinTransactionExtended>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable PagedList<CryptoCoinTransaction> cryptoCoinTransactions) {
|
public void onChanged(@Nullable PagedList<CryptoCoinTransactionExtended> cryptoCoinTransactions) {
|
||||||
transactionListView.setData(cryptoCoinTransactions, fragment);
|
transactionListView.setData(cryptoCoinTransactions, fragment);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnTextChanged(value = R.id.etTransactionSearch,
|
||||||
|
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||||
|
void afterTransactionSearchChange(Editable editable) {
|
||||||
|
changeTransactionList();
|
||||||
|
}
|
||||||
|
|
||||||
public void initTransactionsOrderSpinner(){
|
public void initTransactionsOrderSpinner(){
|
||||||
List<TransactionOrderSpinnerAdapter.TransactionOrderSpinnerItem> spinnerValues = new ArrayList<TransactionOrderSpinnerAdapter.TransactionOrderSpinnerItem>();
|
List<TransactionOrderSpinnerAdapter.TransactionOrderSpinnerItem> spinnerValues = new ArrayList<TransactionOrderSpinnerAdapter.TransactionOrderSpinnerItem>();
|
||||||
spinnerValues.add(new TransactionOrderSpinnerAdapter.TransactionOrderSpinnerItem("date","Date",0,false));
|
spinnerValues.add(new TransactionOrderSpinnerAdapter.TransactionOrderSpinnerItem("date","Date",0,false));
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
package cy.agorise.crystalwallet.models;
|
||||||
|
|
||||||
|
import android.arch.persistence.room.ColumnInfo;
|
||||||
|
import android.arch.persistence.room.Embedded;
|
||||||
|
import android.arch.persistence.room.Entity;
|
||||||
|
import android.arch.persistence.room.ForeignKey;
|
||||||
|
import android.arch.persistence.room.Ignore;
|
||||||
|
import android.arch.persistence.room.Index;
|
||||||
|
import android.arch.persistence.room.PrimaryKey;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v7.recyclerview.extensions.DiffCallback;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a generic CryptoNet Transaction
|
||||||
|
*
|
||||||
|
* Created by Henry Varona on 15/5/2018.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
public class CryptoCoinTransactionExtended {
|
||||||
|
|
||||||
|
@Embedded
|
||||||
|
public CryptoCoinTransaction cryptoCoinTransaction;
|
||||||
|
|
||||||
|
@ColumnInfo(name="user_account_name")
|
||||||
|
public String userAccountName;
|
||||||
|
|
||||||
|
@ColumnInfo(name="contact_name")
|
||||||
|
public String contactName;
|
||||||
|
|
||||||
|
public String getUserAccountName(){
|
||||||
|
return this.userAccountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContactName(){
|
||||||
|
return this.contactName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFrom() { return this.cryptoCoinTransaction.getFrom(); }
|
||||||
|
|
||||||
|
public String getTo() { return this.cryptoCoinTransaction.getTo(); }
|
||||||
|
|
||||||
|
public long getAccountId() {
|
||||||
|
return this.cryptoCoinTransaction.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CryptoNetAccount getAccount() {
|
||||||
|
return this.cryptoCoinTransaction.getAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return this.cryptoCoinTransaction.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
return this.cryptoCoinTransaction.getDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getInput() {
|
||||||
|
return this.cryptoCoinTransaction.getInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConfirmed() { return this.cryptoCoinTransaction.isConfirmed(); }
|
||||||
|
|
||||||
|
public long getAmount() { return this.cryptoCoinTransaction.getAmount(); }
|
||||||
|
|
||||||
|
public int getIdCurrency() { return this.cryptoCoinTransaction.getIdCurrency(); }
|
||||||
|
|
||||||
|
public static final DiffCallback<CryptoCoinTransactionExtended> DIFF_CALLBACK = new DiffCallback<CryptoCoinTransactionExtended>() {
|
||||||
|
@Override
|
||||||
|
public boolean areItemsTheSame(
|
||||||
|
@NonNull CryptoCoinTransactionExtended oldTransaction, @NonNull CryptoCoinTransactionExtended newTransaction) {
|
||||||
|
return oldTransaction.getId() == newTransaction.getId();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean areContentsTheSame(
|
||||||
|
@NonNull CryptoCoinTransactionExtended oldTransaction, @NonNull CryptoCoinTransactionExtended newTransaction) {
|
||||||
|
return oldTransaction.equals(newTransaction);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
CryptoCoinTransactionExtended that = (CryptoCoinTransactionExtended) o;
|
||||||
|
|
||||||
|
if (this.cryptoCoinTransaction != null ? !this.cryptoCoinTransaction.equals(that.cryptoCoinTransaction) : that.cryptoCoinTransaction != null) return false;
|
||||||
|
if (this.userAccountName != null ? !this.userAccountName.equals(that.userAccountName) : that.userAccountName != null) return false;
|
||||||
|
if (this.contactName != null ? !this.contactName.equals(that.contactName) : that.contactName != null) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinTransactionExtended;
|
||||||
import cy.agorise.crystalwallet.views.TransactionListView;
|
import cy.agorise.crystalwallet.views.TransactionListView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +21,7 @@ import cy.agorise.crystalwallet.views.TransactionListView;
|
||||||
|
|
||||||
public class TransactionListViewModel extends AndroidViewModel {
|
public class TransactionListViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
private LiveData<PagedList<CryptoCoinTransaction>> transactionList;
|
private LiveData<PagedList<CryptoCoinTransactionExtended>> transactionList;
|
||||||
private CrystalDatabase db;
|
private CrystalDatabase db;
|
||||||
|
|
||||||
public TransactionListViewModel(Application application) {
|
public TransactionListViewModel(Application application) {
|
||||||
|
@ -35,25 +36,27 @@ public class TransactionListViewModel extends AndroidViewModel {
|
||||||
);*/
|
);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initTransactionList(String orderField){
|
public void initTransactionList(String orderField, String search){
|
||||||
LivePagedListProvider<Integer, CryptoCoinTransaction> livePagedListProvider = null;
|
LivePagedListProvider<Integer, CryptoCoinTransactionExtended> livePagedListProvider = null;
|
||||||
|
|
||||||
switch (orderField){
|
switch (orderField){
|
||||||
case "date":
|
case "date":
|
||||||
livePagedListProvider = this.db.transactionDao().transactionsByDate();
|
livePagedListProvider = this.db.transactionDao().transactionsByDate(search);
|
||||||
break;
|
break;
|
||||||
case "amount":
|
case "amount":
|
||||||
livePagedListProvider = this.db.transactionDao().transactionsByAmount();
|
livePagedListProvider = this.db.transactionDao().transactionsByAmount(search);
|
||||||
break;
|
break;
|
||||||
case "is_input":
|
case "is_input":
|
||||||
livePagedListProvider = this.db.transactionDao().transactionsByIsInput();
|
livePagedListProvider = this.db.transactionDao().transactionsByIsInput(search);
|
||||||
break;
|
break;
|
||||||
case "from":
|
case "from":
|
||||||
livePagedListProvider = this.db.transactionDao().transactionsByFrom();
|
livePagedListProvider = this.db.transactionDao().transactionsByFrom(search);
|
||||||
break;
|
break;
|
||||||
case "to":
|
case "to":
|
||||||
livePagedListProvider = this.db.transactionDao().transactionsByTo();
|
livePagedListProvider = this.db.transactionDao().transactionsByTo(search);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
livePagedListProvider = this.db.transactionDao().transactionsByDate(search);
|
||||||
}
|
}
|
||||||
if (livePagedListProvider != null) {
|
if (livePagedListProvider != null) {
|
||||||
this.transactionList = livePagedListProvider.create(0,
|
this.transactionList = livePagedListProvider.create(0,
|
||||||
|
@ -68,7 +71,7 @@ public class TransactionListViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<PagedList<CryptoCoinTransaction>> getTransactionList(){
|
public LiveData<PagedList<CryptoCoinTransactionExtended>> getTransactionList(){
|
||||||
return this.transactionList;
|
return this.transactionList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.List;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinTransactionExtended;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Henry Varona on 11/9/2017.
|
* Created by Henry Varona on 11/9/2017.
|
||||||
|
@ -29,12 +30,12 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
* that will be extended with the scroll of the user
|
* that will be extended with the scroll of the user
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TransactionListAdapter extends PagedListAdapter<CryptoCoinTransaction, TransactionViewHolder> {
|
public class TransactionListAdapter extends PagedListAdapter<CryptoCoinTransactionExtended, TransactionViewHolder> {
|
||||||
|
|
||||||
Fragment fragment;
|
Fragment fragment;
|
||||||
|
|
||||||
public TransactionListAdapter(Fragment fragment) {
|
public TransactionListAdapter(Fragment fragment) {
|
||||||
super(CryptoCoinTransaction.DIFF_CALLBACK);
|
super(CryptoCoinTransactionExtended.DIFF_CALLBACK);
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ public class TransactionListAdapter extends PagedListAdapter<CryptoCoinTransacti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(TransactionViewHolder holder, int position) {
|
public void onBindViewHolder(TransactionViewHolder holder, int position) {
|
||||||
CryptoCoinTransaction transaction = getItem(position);
|
CryptoCoinTransactionExtended transaction = getItem(position);
|
||||||
if (transaction != null) {
|
if (transaction != null) {
|
||||||
holder.bindTo(transaction);
|
holder.bindTo(transaction);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinTransactionExtended;
|
||||||
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
|
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +111,7 @@ public class TransactionListView extends RelativeLayout {
|
||||||
*
|
*
|
||||||
* @param data the transactions that will be showed to the user
|
* @param data the transactions that will be showed to the user
|
||||||
*/
|
*/
|
||||||
public void setData(PagedList<CryptoCoinTransaction> data, Fragment fragment){
|
public void setData(PagedList<CryptoCoinTransactionExtended> data, Fragment fragment){
|
||||||
//Initializes the adapter of the transaction list
|
//Initializes the adapter of the transaction list
|
||||||
if (this.listAdapter == null) {
|
if (this.listAdapter == null) {
|
||||||
this.listAdapter = new TransactionListAdapter(fragment);
|
this.listAdapter = new TransactionListAdapter(fragment);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.TimeZone;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.activities.CryptoCoinTransactionReceiptActivity;
|
import cy.agorise.crystalwallet.activities.CryptoCoinTransactionReceiptActivity;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinTransactionExtended;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
import cy.agorise.crystalwallet.models.GeneralSetting;
|
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||||
|
@ -112,7 +113,7 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
/*
|
/*
|
||||||
* Binds a transaction object with this element view
|
* Binds a transaction object with this element view
|
||||||
*/
|
*/
|
||||||
public void bindTo(final CryptoCoinTransaction transaction/*, final OnTransactionClickListener listener*/) {
|
public void bindTo(final CryptoCoinTransactionExtended transaction/*, final OnTransactionClickListener listener*/) {
|
||||||
if (transaction == null){
|
if (transaction == null){
|
||||||
clear();
|
clear();
|
||||||
} else {
|
} else {
|
||||||
|
@ -147,16 +148,24 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
LiveData<CryptoNetAccount> cryptoNetAccountLiveData = cryptoNetAccountViewModel.getCryptoNetAccount();
|
LiveData<CryptoNetAccount> cryptoNetAccountLiveData = cryptoNetAccountViewModel.getCryptoNetAccount();
|
||||||
|
|
||||||
cryptoNetAccountLiveData.observe(this.fragment, new Observer<CryptoNetAccount>() {
|
//cryptoNetAccountLiveData.observe(this.fragment, new Observer<CryptoNetAccount>() {
|
||||||
@Override
|
// @Override
|
||||||
public void onChanged(@Nullable CryptoNetAccount cryptoNetAccount) {
|
// public void onChanged(@Nullable CryptoNetAccount cryptoNetAccount) {
|
||||||
if (transaction.getInput()){
|
if (transaction.getInput()){
|
||||||
tvTo.setText(cryptoNetAccount.getName());
|
tvTo.setText(transaction.getUserAccountName());
|
||||||
|
|
||||||
|
if ((transaction.getContactName() != null)&&(!transaction.equals(""))){
|
||||||
|
tvFrom.setText(transaction.getContactName());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tvFrom.setText(cryptoNetAccount.getName());
|
tvFrom.setText(transaction.getUserAccountName());
|
||||||
|
|
||||||
|
if ((transaction.getContactName() != null)&&(!transaction.equals(""))){
|
||||||
|
tvTo.setText(transaction.getContactName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
});
|
//});
|
||||||
|
|
||||||
String finalAmountText = "";
|
String finalAmountText = "";
|
||||||
if (transaction.getInput()) {
|
if (transaction.getInput()) {
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
android:layout_width="40dip"
|
android:layout_width="40dip"
|
||||||
android:layout_height="40dip"
|
android:layout_height="40dip"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_toStartOf="@+id/spTransactionsOrder" />
|
android:layout_toStartOf="@+id/spTransactionsOrder"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/spTransactionsOrder"
|
android:id="@+id/spTransactionsOrder"
|
||||||
|
|
Loading…
Reference in a new issue