Search in sources :

Example 1 with OptionPicker

use of com.lingtuan.firefly.custom.picker.OptionPicker in project SmartMesh_Android by SmartMeshFoundation.

the class GesturePasswordLoginActivity method onConstellationPicker.

public void onConstellationPicker() {
    ArrayList<StorableWallet> storableWallets;
    if (type == 4) {
        storableWallets = WalletStorage.getInstance(NextApplication.mContext).getAll();
    } else {
        storableWallets = WalletStorage.getInstance(NextApplication.mContext).get();
    }
    if (storableWallets == null || storableWallets.size() <= 0) {
        return;
    }
    int index = -1;
    String[] nameArray = new String[storableWallets.size()];
    for (int i = 0; i < storableWallets.size(); i++) {
        String address = storableWallets.get(i).getPublicKey();
        if (storableWallets.get(i).isSelect()) {
            index = i;
        }
        if (!address.startsWith("0x")) {
            address = "0x" + address;
        }
        nameArray[i] = address.replace(address.substring(12, 30), "...");
    }
    OptionPicker picker = new OptionPicker(this, nameArray);
    // Do not disable loops
    picker.setCycleDisable(true);
    picker.setTopBackgroundColor(0xFFEEEEEE);
    picker.setTopHeight(40);
    picker.setTextSize(14);
    picker.setOffset(3);
    picker.setTopLineColor(getResources().getColor(R.color.textColorCard));
    picker.setTopLineHeight(1);
    picker.setCancelTextColor(getResources().getColor(R.color.textColorCard));
    picker.setCancelTextSize(13);
    picker.setSubmitTextColor(getResources().getColor(R.color.gesture_lock_select));
    picker.setSubmitTextSize(13);
    picker.setTextColor(getResources().getColor(R.color.black), getResources().getColor(R.color.textColorCard));
    WheelView.DividerConfig config = new WheelView.DividerConfig();
    // Line color
    config.setColor(getResources().getColor(R.color.tab_sep_line));
    // Line transparency
    config.setAlpha(140);
    // Line ratio
    config.setRatio(1);
    picker.setDividerConfig(config);
    picker.setBackgroundColor(0xFFE1E1E1);
    picker.setSelectedIndex(index);
    picker.setCanceledOnTouchOutside(true);
    picker.setOnOptionPickListener(new OptionPicker.OnOptionPickListener() {

        @Override
        public void onOptionPicked(int index, String item) {
            ArrayList<StorableWallet> storableWallets;
            if (type == 4) {
                storableWallets = WalletStorage.getInstance(NextApplication.mContext).getAll();
            } else {
                storableWallets = WalletStorage.getInstance(NextApplication.mContext).get();
            }
            for (int i = 0; i < storableWallets.size(); i++) {
                if (i != index) {
                    if (type == 4) {
                        WalletStorage.getInstance(NextApplication.mContext).getAll().get(i).setSelect(false);
                    } else {
                        WalletStorage.getInstance(getApplicationContext()).get().get(i).setSelect(false);
                    }
                } else {
                    if (type == 4) {
                        WalletStorage.getInstance(NextApplication.mContext).getAll().get(i).setSelect(true);
                    } else {
                        WalletStorage.getInstance(getApplicationContext()).get().get(i).setSelect(true);
                    }
                }
            }
            initWalletInfo();
            if (type != 4) {
                Utils.sendBroadcastReceiver(GesturePasswordLoginActivity.this, new Intent(Constants.WALLET_REFRESH_GESTURE), false);
            }
        }
    });
    picker.show();
}
Also used : OptionPicker(com.lingtuan.firefly.custom.picker.OptionPicker) WheelView(com.lingtuan.firefly.custom.picker.WheelView) StorableWallet(com.lingtuan.firefly.wallet.vo.StorableWallet) ArrayList(java.util.ArrayList) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 OptionPicker (com.lingtuan.firefly.custom.picker.OptionPicker)1 WheelView (com.lingtuan.firefly.custom.picker.WheelView)1 StorableWallet (com.lingtuan.firefly.wallet.vo.StorableWallet)1 ArrayList (java.util.ArrayList)1