Search in sources :

Example 1 with TransactionListAdapter

use of com.odysee.app.adapter.TransactionListAdapter in project odysee-android by OdyseeTeam.

the class TransactionHistoryFragment method loadTransactions.

private void loadTransactions() {
    currentTransactionPage = currentTransactionPage == 0 ? 1 : currentTransactionPage;
    transactionsLoading = true;
    TransactionListTask task = new TransactionListTask(currentTransactionPage, TRANSACTION_PAGE_LIMIT, Lbryio.AUTH_TOKEN, loading, new TransactionListTask.TransactionListHandler() {

        @Override
        public void onSuccess(List<Transaction> transactions, boolean hasReachedEnd) {
            Context context = getContext();
            transactionsLoading = false;
            transactionsHaveReachedEnd = hasReachedEnd;
            if (context != null) {
                if (adapter == null) {
                    adapter = new TransactionListAdapter(transactions, context);
                    adapter.setListener(TransactionHistoryFragment.this);
                    if (transactionList != null) {
                        transactionList.setAdapter(adapter);
                    }
                } else {
                    adapter.addTransactions(transactions);
                }
            }
            checkNoTransactions();
        }

        @Override
        public void onError(Exception error) {
            transactionsLoading = false;
            checkNoTransactions();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : Context(android.content.Context) Transaction(com.odysee.app.model.Transaction) TransactionListTask(com.odysee.app.tasks.wallet.TransactionListTask) TransactionListAdapter(com.odysee.app.adapter.TransactionListAdapter)

Example 2 with TransactionListAdapter

use of com.odysee.app.adapter.TransactionListAdapter in project odysee-android by OdyseeTeam.

the class WalletFragment method fetchRecentTransactions.

private void fetchRecentTransactions(boolean forceFetch) {
    if (!Helper.isSignedIn(getContext())) {
        return;
    }
    if (hasFetchedRecentTransactions && !forceFetch) {
        return;
    }
    Helper.setViewVisibility(textNoRecentTransactions, View.GONE);
    AccountManager am = AccountManager.get(getContext());
    Account[] accounts = am.getAccounts();
    TransactionListTask task = new TransactionListTask(1, 5, am.peekAuthToken(Helper.getOdyseeAccount(accounts), "auth_token_type"), loadingRecentContainer, new TransactionListTask.TransactionListHandler() {

        @Override
        public void onSuccess(List<Transaction> transactions, boolean hasReachedEnd) {
            hasFetchedRecentTransactions = true;
            recentTransactionsAdapter = new TransactionListAdapter(transactions, getContext());
            recentTransactionsAdapter.setListener(new TransactionListAdapter.TransactionClickListener() {

                @Override
                public void onTransactionClicked(Transaction transaction) {
                }

                @Override
                public void onClaimUrlClicked(LbryUri uri) {
                    Context context = getContext();
                    if (uri != null && context instanceof MainActivity) {
                        MainActivity activity = (MainActivity) context;
                        if (uri.isChannel()) {
                            activity.openChannelUrl(uri.toString());
                        } else {
                            activity.openFileUrl(uri.toString());
                        }
                    }
                }
            });
            recentTransactionsList.setAdapter(recentTransactionsAdapter);
            displayNoRecentTransactions();
        }

        @Override
        public void onError(Exception error) {
            hasFetchedRecentTransactions = true;
            displayNoRecentTransactions();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : Context(android.content.Context) Account(android.accounts.Account) TransactionListTask(com.odysee.app.tasks.wallet.TransactionListTask) MainActivity(com.odysee.app.MainActivity) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeyException(java.security.InvalidKeyException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ApiCallException(com.odysee.app.exceptions.ApiCallException) ExecutionException(java.util.concurrent.ExecutionException) Transaction(com.odysee.app.model.Transaction) AccountManager(android.accounts.AccountManager) LbryUri(com.odysee.app.utils.LbryUri) TransactionListAdapter(com.odysee.app.adapter.TransactionListAdapter)

Aggregations

Context (android.content.Context)2 TransactionListAdapter (com.odysee.app.adapter.TransactionListAdapter)2 Transaction (com.odysee.app.model.Transaction)2 TransactionListTask (com.odysee.app.tasks.wallet.TransactionListTask)2 Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 MainActivity (com.odysee.app.MainActivity)1 ApiCallException (com.odysee.app.exceptions.ApiCallException)1 LbryUri (com.odysee.app.utils.LbryUri)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ExecutionException (java.util.concurrent.ExecutionException)1