Search in sources :

Example 6 with ItemDividerDecorator

use of com.samourai.wallet.widgets.ItemDividerDecorator in project samourai-wallet-android by Samourai-Wallet.

the class UTXOSActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_utxos);
    toolbar = findViewById(R.id.toolbar_utxos);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (account == WhirlpoolMeta.getInstance(getApplicationContext()).getWhirlpoolPostmix()) {
        getSupportActionBar().setTitle(getText(R.string.unspent_outputs_post_mix));
    }
    noteAmounts = new TreeMap<String, Long>();
    tagAmounts = new TreeMap<String, Long>();
    df.setMinimumIntegerDigits(1);
    df.setMinimumFractionDigits(8);
    df.setMaximumFractionDigits(8);
    utxoList = findViewById(R.id.utxo_rv_list);
    utxoList.setItemViewCacheSize(24);
    utxoProgressBar = findViewById(R.id.utxo_progressBar);
    utxoSwipeRefresh = findViewById(R.id.utxo_swipe_container);
    adapter = new UTXOListAdapter();
    adapter.setHasStableIds(true);
    utxoList.setLayoutManager(new LinearLayoutManagerWrapper(this));
    utxoList.addItemDecoration(new ItemDividerDecorator(getDrawable(R.color.disabled_white)));
    utxoList.setAdapter(adapter);
    loadUTXOs(false);
    utxoSwipeRefresh.setOnRefreshListener(() -> {
        loadUTXOs(false);
    });
    if (!APIFactory.getInstance(getApplicationContext()).walletInit) {
        if (!shownWalletLoadingMessage) {
            Snackbar.make(utxoList.getRootView(), "Please wait... your wallet is still loading ", Snackbar.LENGTH_LONG).show();
            shownWalletLoadingMessage = true;
        }
    }
}
Also used : ItemDividerDecorator(com.samourai.wallet.widgets.ItemDividerDecorator) LinearLayoutManagerWrapper(com.samourai.wallet.util.LinearLayoutManagerWrapper)

Example 7 with ItemDividerDecorator

use of com.samourai.wallet.widgets.ItemDividerDecorator in project samourai-wallet-android by Samourai-Wallet.

the class WhirlpoolCyclesFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.whirlpool_cycles_list, container, false);
    adapter = new WhirlpoolCyclesFragmentAdapter(new ArrayList<>());
    cyclesList = view.findViewById(R.id.whirlpool_cycles_rv);
    cyclesList.setLayoutManager(new LinearLayoutManager(getContext()));
    cyclesList.setAdapter(adapter);
    Drawable drawable = this.getResources().getDrawable(R.drawable.divider_grey);
    cyclesList.addItemDecoration(new ItemDividerDecorator(drawable));
    return view;
}
Also used : ItemDividerDecorator(com.samourai.wallet.widgets.ItemDividerDecorator) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 8 with ItemDividerDecorator

use of com.samourai.wallet.widgets.ItemDividerDecorator in project samourai-wallet-android by Samourai-Wallet.

the class BalanceActivity method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_balance);
    balanceViewModel = ViewModelProviders.of(this).get(BalanceViewModel.class);
    makePaynymAvatarcache();
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    TxRecyclerView = findViewById(R.id.rv_txes);
    progressBar = findViewById(R.id.progressBar);
    toolbar = findViewById(R.id.toolbar);
    mCollapsingToolbar = findViewById(R.id.toolbar_layout);
    txSwipeLayout = findViewById(R.id.tx_swipe_container);
    setSupportActionBar(toolbar);
    TxRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    Drawable drawable = this.getResources().getDrawable(R.drawable.divider);
    TxRecyclerView.addItemDecoration(new ItemDividerDecorator(drawable));
    menuFab = findViewById(R.id.fab_menu);
    txs = new ArrayList<>();
    whirlpoolFab = findViewById(R.id.whirlpool_fab);
    sendFab = findViewById(R.id.send_fab);
    receiveFab = findViewById(R.id.receive_fab);
    paynymFab = findViewById(R.id.paynym_fab);
    findViewById(R.id.whirlpool_fab).setOnClickListener(view -> {
        Intent intent = new Intent(BalanceActivity.this, WhirlpoolMain.class);
        startActivity(intent);
        menuFab.toggle(true);
    });
    sendFab.setOnClickListener(view -> {
        Intent intent = new Intent(BalanceActivity.this, SendActivity.class);
        intent.putExtra("via_menu", true);
        intent.putExtra("_account", account);
        startActivity(intent);
        menuFab.toggle(true);
    });
    JSONObject payload = PayloadUtil.getInstance(BalanceActivity.this).getPayload();
    if (account == 0 && payload != null && payload.has("prev_balance")) {
        try {
            setBalance(payload.getLong("prev_balance"), false);
        } catch (Exception e) {
            setBalance(0L, false);
        }
    } else {
        setBalance(0L, false);
    }
    receiveFab.setOnClickListener(view -> {
        menuFab.toggle(true);
        try {
            HD_Wallet hdw = HD_WalletFactory.getInstance(BalanceActivity.this).get();
            if (hdw != null) {
                Intent intent = new Intent(BalanceActivity.this, ReceiveActivity.class);
                startActivity(intent);
            }
        } catch (IOException | MnemonicException.MnemonicLengthException e) {
        }
    });
    paynymFab.setOnClickListener(view -> {
        menuFab.toggle(true);
        Intent intent = new Intent(BalanceActivity.this, PayNymHome.class);
        startActivity(intent);
    });
    txSwipeLayout.setOnRefreshListener(() -> {
        refreshTx(false, true, false);
        txSwipeLayout.setRefreshing(false);
        progressBar.setVisibility(View.VISIBLE);
    });
    IntentFilter filter = new IntentFilter(ACTION_INTENT);
    LocalBroadcastManager.getInstance(BalanceActivity.this).registerReceiver(receiver, filter);
    IntentFilter filterDisplay = new IntentFilter(DISPLAY_INTENT);
    LocalBroadcastManager.getInstance(BalanceActivity.this).registerReceiver(receiverDisplay, filterDisplay);
    if (!PermissionsUtil.getInstance(BalanceActivity.this).hasPermission(Manifest.permission.READ_EXTERNAL_STORAGE) || !PermissionsUtil.getInstance(BalanceActivity.this).hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        PermissionsUtil.getInstance(BalanceActivity.this).showRequestPermissionsInfoAlertDialog(PermissionsUtil.READ_WRITE_EXTERNAL_PERMISSION_CODE);
    }
    if (!PermissionsUtil.getInstance(BalanceActivity.this).hasPermission(Manifest.permission.CAMERA)) {
        PermissionsUtil.getInstance(BalanceActivity.this).showRequestPermissionsInfoAlertDialog(PermissionsUtil.CAMERA_PERMISSION_CODE);
    }
    if (PrefsUtil.getInstance(BalanceActivity.this).getValue(PrefsUtil.PAYNYM_CLAIMED, false) == true && PrefsUtil.getInstance(BalanceActivity.this).getValue(PrefsUtil.PAYNYM_FEATURED_SEGWIT, false) == false) {
        doFeaturePayNymUpdate();
    } else if (PrefsUtil.getInstance(BalanceActivity.this).getValue(PrefsUtil.PAYNYM_CLAIMED, false) == false && PrefsUtil.getInstance(BalanceActivity.this).getValue(PrefsUtil.PAYNYM_REFUSED, false) == false) {
        doClaimPayNym();
    } else {
    }
    if (RicochetMeta.getInstance(BalanceActivity.this).getQueue().size() > 0) {
        if (ricochetQueueTask == null || ricochetQueueTask.getStatus().equals(AsyncTask.Status.FINISHED)) {
            ricochetQueueTask = new RicochetQueueTask();
            ricochetQueueTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
        }
    }
    if (!AppUtil.getInstance(BalanceActivity.this).isClipboardSeen()) {
        doClipboardCheck();
    }
    if (!AppUtil.getInstance(BalanceActivity.this.getApplicationContext()).isServiceRunning(WebSocketService.class)) {
        startService(new Intent(BalanceActivity.this.getApplicationContext(), WebSocketService.class));
    }
    setUpTor();
    initViewModel();
    progressBar.setVisibility(View.VISIBLE);
    if (account == 0) {
        final Handler delayedHandler = new Handler();
        delayedHandler.postDelayed(() -> {
            boolean notifTx = false;
            Bundle extras = getIntent().getExtras();
            if (extras != null && extras.containsKey("notifTx")) {
                notifTx = extras.getBoolean("notifTx");
            }
            refreshTx(notifTx, false, true);
            updateDisplay(false);
        }, 100L);
        getSupportActionBar().setIcon(R.drawable.ic_samourai_logo_toolbar);
        balanceViewModel.loadOfflineData();
    } else {
        getSupportActionBar().setIcon(R.drawable.ic_whirlpool);
        receiveFab.setVisibility(View.GONE);
        whirlpoolFab.setVisibility(View.GONE);
        paynymFab.setVisibility(View.GONE);
        new Handler().postDelayed(() -> updateDisplay(true), 600L);
    }
    boolean hadContentDescription = android.text.TextUtils.isEmpty(toolbar.getLogoDescription());
    String contentDescription = String.valueOf(!hadContentDescription ? toolbar.getLogoDescription() : "logoContentDescription");
    toolbar.setLogoDescription(contentDescription);
    ArrayList<View> potentialViews = new ArrayList<View>();
    toolbar.findViewsWithText(potentialViews, contentDescription, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
    View logoView = null;
    if (potentialViews.size() > 0) {
        logoView = potentialViews.get(0);
        if (account == 0) {
            logoView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent _intent = new Intent(BalanceActivity.this, BalanceActivity.class);
                    _intent.putExtra("_account", WhirlpoolMeta.getInstance(BalanceActivity.this).getWhirlpoolPostmix());
                    startActivity(_intent);
                }
            });
        } else {
            logoView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent _intent = new Intent(BalanceActivity.this, BalanceActivity.class);
                    _intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    startActivity(_intent);
                }
            });
        }
    }
    updateDisplay(false);
    checkDeepLinks();
}
Also used : HD_Wallet(com.samourai.wallet.hd.HD_Wallet) ItemDividerDecorator(com.samourai.wallet.widgets.ItemDividerDecorator) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) WebSocketService(com.samourai.wallet.service.WebSocketService) IntentFilter(android.content.IntentFilter) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) Handler(android.os.Handler) Intent(android.content.Intent) IOException(java.io.IOException) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) TextView(android.widget.TextView) JSONException(org.json.JSONException) ConcurrentModificationException(java.util.ConcurrentModificationException) DecryptionException(com.samourai.wallet.crypto.DecryptionException) IOException(java.io.IOException) MnemonicException(org.bitcoinj.crypto.MnemonicException) JSONObject(org.json.JSONObject)

Aggregations

ItemDividerDecorator (com.samourai.wallet.widgets.ItemDividerDecorator)8 Drawable (android.graphics.drawable.Drawable)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 ArrayList (java.util.ArrayList)3 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 LinearLayoutManagerWrapper (com.samourai.wallet.util.LinearLayoutManagerWrapper)2 ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 Toolbar (android.support.v7.widget.Toolbar)1 ImageView (android.widget.ImageView)1 DecryptionException (com.samourai.wallet.crypto.DecryptionException)1 HD_Wallet (com.samourai.wallet.hd.HD_Wallet)1