Search in sources :

Example 36 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project bitcoin-wallet by bitcoin-wallet.

the class SendCoinsFragment method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.send_coins_fragment, container);
    payeeGroup = view.findViewById(R.id.send_coins_payee_group);
    payeeNameView = (TextView) view.findViewById(R.id.send_coins_payee_name);
    payeeVerifiedByView = (TextView) view.findViewById(R.id.send_coins_payee_verified_by);
    receivingAddressView = (AutoCompleteTextView) view.findViewById(R.id.send_coins_receiving_address);
    receivingAddressViewAdapter = new ReceivingAddressViewAdapter(activity);
    receivingAddressLoaderCallbacks = new ReceivingAddressLoaderCallbacks(activity, receivingAddressViewAdapter);
    receivingAddressView.setAdapter(receivingAddressViewAdapter);
    receivingAddressView.setOnFocusChangeListener(receivingAddressListener);
    receivingAddressView.addTextChangedListener(receivingAddressListener);
    receivingAddressView.setOnItemClickListener(receivingAddressListener);
    receivingStaticView = view.findViewById(R.id.send_coins_receiving_static);
    receivingStaticAddressView = (TextView) view.findViewById(R.id.send_coins_receiving_static_address);
    receivingStaticLabelView = (TextView) view.findViewById(R.id.send_coins_receiving_static_label);
    amountGroup = view.findViewById(R.id.send_coins_amount_group);
    final CurrencyAmountView btcAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_btc);
    btcAmountView.setCurrencySymbol(config.getFormat().code());
    btcAmountView.setInputFormat(config.getMaxPrecisionFormat());
    btcAmountView.setHintFormat(config.getFormat());
    final CurrencyAmountView localAmountView = (CurrencyAmountView) view.findViewById(R.id.send_coins_amount_local);
    localAmountView.setInputFormat(Constants.LOCAL_FORMAT);
    localAmountView.setHintFormat(Constants.LOCAL_FORMAT);
    amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView);
    amountCalculatorLink.setExchangeDirection(config.getLastExchangeDirection());
    directPaymentEnableView = (CheckBox) view.findViewById(R.id.send_coins_direct_payment_enable);
    directPaymentEnableView.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            if (paymentIntent.isBluetoothPaymentUrl() && isChecked && !bluetoothAdapter.isEnabled()) {
                // ask for permission to enable bluetooth
                startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH_FOR_DIRECT_PAYMENT);
            }
        }
    });
    hintView = (TextView) view.findViewById(R.id.send_coins_hint);
    directPaymentMessageView = (TextView) view.findViewById(R.id.send_coins_direct_payment_message);
    sentTransactionView = (FrameLayout) view.findViewById(R.id.send_coins_sent_transaction);
    sentTransactionAdapter = new TransactionsAdapter(activity, wallet, false, application.maxConnectedPeers(), null);
    sentTransactionViewHolder = sentTransactionAdapter.createTransactionViewHolder(sentTransactionView);
    sentTransactionView.addView(sentTransactionViewHolder.itemView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    privateKeyPasswordViewGroup = view.findViewById(R.id.send_coins_private_key_password_group);
    privateKeyPasswordView = (EditText) view.findViewById(R.id.send_coins_private_key_password);
    privateKeyBadPasswordView = view.findViewById(R.id.send_coins_private_key_bad_password);
    viewGo = (Button) view.findViewById(R.id.send_coins_go);
    viewGo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            validateReceivingAddress();
            if (everythingPlausible())
                handleGo();
            else
                requestFocusFirst();
            updateView();
        }
    });
    viewCancel = (Button) view.findViewById(R.id.send_coins_cancel);
    viewCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            handleCancel();
        }
    });
    return view;
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) PaymentIntent(de.schildbach.wallet.data.PaymentIntent) Intent(android.content.Intent) CurrencyAmountView(de.schildbach.wallet.ui.CurrencyAmountView) AutoCompleteTextView(android.widget.AutoCompleteTextView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CurrencyCalculatorLink(de.schildbach.wallet.ui.CurrencyCalculatorLink) CurrencyAmountView(de.schildbach.wallet.ui.CurrencyAmountView) FrameLayout(android.widget.FrameLayout) OnClickListener(android.view.View.OnClickListener) TransactionsAdapter(de.schildbach.wallet.ui.TransactionsAdapter) CompoundButton(android.widget.CompoundButton)

Example 37 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project platform_frameworks_base by android.

the class VectorDrawable01 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GridLayout container = new GridLayout(this);
    container.setColumnCount(5);
    container.setBackgroundColor(0xFF888888);
    final Button[] bArray = new Button[icon.length];
    CheckBox toggle = new CheckBox(this);
    toggle.setText("Toggle");
    toggle.setChecked(true);
    toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            ViewGroup vg = (ViewGroup) buttonView.getParent();
            for (int i = 0, count = vg.getChildCount(); i < count; i++) {
                View child = vg.getChildAt(i);
                if (child != buttonView) {
                    child.setEnabled(isChecked);
                }
            }
        }
    });
    container.addView(toggle);
    for (int i = 0; i < icon.length; i++) {
        Button button = new Button(this);
        bArray[i] = button;
        button.setWidth(200);
        button.setBackgroundResource(icon[i]);
        container.addView(button);
        VectorDrawable vd = (VectorDrawable) button.getBackground();
        vd.setAlpha((i + 1) * (0xFF / (icon.length + 1)));
    }
    setContentView(container);
}
Also used : GridLayout(android.widget.GridLayout) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) CheckBox(android.widget.CheckBox) ViewGroup(android.view.ViewGroup) View(android.view.View) CompoundButton(android.widget.CompoundButton) VectorDrawable(android.graphics.drawable.VectorDrawable)

Example 38 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project KISS by Neamar.

the class TogglesResult method display.

@SuppressWarnings({ "ResourceType", "deprecation" })
@Override
public View display(Context context, int position, View v) {
    // On first run, initialize handler
    if (togglesHandler == null)
        togglesHandler = new TogglesHandler(context);
    if (v == null)
        v = inflateFromId(context, R.layout.item_toggle);
    String togglePrefix = "<small><small>" + context.getString(R.string.toggles_prefix) + "</small></small>";
    TextView toggleName = (TextView) v.findViewById(R.id.item_toggle_name);
    toggleName.setText(TextUtils.concat(Html.fromHtml(togglePrefix), enrichText(togglePojo.displayName, context)));
    ImageView toggleIcon = (ImageView) v.findViewById(R.id.item_toggle_icon);
    toggleIcon.setImageDrawable(context.getResources().getDrawable(togglePojo.icon));
    toggleIcon.setColorFilter(getThemeFillColor(context), Mode.SRC_IN);
    // Use the handler to check or un-check button
    final CompoundButton toggleButton = (CompoundButton) v.findViewById(R.id.item_toggle_action_toggle);
    //set listener to null to avoid calling the listener of the older toggle item
    //(due to recycling)
    toggleButton.setOnCheckedChangeListener(null);
    Boolean state = togglesHandler.getState(togglePojo);
    if (state != null)
        toggleButton.setChecked(togglesHandler.getState(togglePojo));
    else
        toggleButton.setEnabled(false);
    toggleButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!togglesHandler.getState(togglePojo).equals(toggleButton.isChecked())) {
                // record launch manually
                recordLaunch(buttonView.getContext());
                togglesHandler.setState(togglePojo, toggleButton.isChecked());
                toggleButton.setEnabled(false);
                new AsyncTask<Void, Void, Void>() {

                    @Override
                    protected Void doInBackground(Void... params) {
                        try {
                            Thread.sleep(1500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void result) {
                        super.onPostExecute(result);
                        toggleButton.setEnabled(true);
                    }
                }.execute();
            }
        }
    });
    return v;
}
Also used : TogglesHandler(fr.neamar.kiss.toggles.TogglesHandler) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) AsyncTask(android.os.AsyncTask) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CompoundButton(android.widget.CompoundButton)

Example 39 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project KJFrameForAndroid by kymjs.

the class KJEmojiFragment method initWidget.

private void initWidget(View rootView) {
    // title
    mEmojiTitle = rootView.findViewById(R.id.emoji_title);
    mEt = (EditText) mEmojiTitle.findViewById(R.id.emoji_titile_input);
    mCBox = (CheckBox) mEmojiTitle.findViewById(R.id.emoji_title_menu);
    mCBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                showEmojiKeyBoard();
                hideSoftKeyboard();
            } else {
                hideEmojiKeyBoard();
                showSoftKeyboard();
            }
        }
    });
    // bottom
    mEmojiBottom = (RadioGroup) rootView.findViewById(R.id.emoji_bottom);
    // 减一是因为有一个删除按钮
    EMOJI_TAB_CONTENT = mEmojiBottom.getChildCount() - 1;
    mEmojiTabs = new View[EMOJI_TAB_CONTENT];
    if (EMOJI_TAB_CONTENT <= 1) {
        // 只有一个分类的时候就不显示了
        mEmojiBottom.setVisibility(View.GONE);
    }
    for (int i = 0; i < EMOJI_TAB_CONTENT; i++) {
        mEmojiTabs[i] = mEmojiBottom.getChildAt(i);
        mEmojiTabs[i].setOnClickListener(getBottomBarClickListener(i));
    }
    mEmojiBottom.findViewById(R.id.emoji_bottom_del).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            InputHelper.backspace(mEt);
        }
    });
    // content必须放在bottom下面初始化
    mEmojiContent = (LinearLayout) rootView.findViewById(R.id.emoji_content);
    LayoutParams params = (LayoutParams) mEmojiContent.getLayoutParams();
    params.height = EMOJI_TAB_CONTENT > 1 ? KJEmojiConfig.MORE_TYPE_HEIGHT : KJEmojiConfig.SINGLE_TYPE_HEIGHT;
    mEmojiContent.setLayoutParams(params);
    mEmojiPager = (ViewPager) mEmojiContent.findViewById(R.id.emoji_pager);
    adapter = new EmojiPagerAdapter(getFragmentManager());
    mEmojiPager.setAdapter(adapter);
    mKeyboardHelper = new SoftKeyboardStateHelper(getActivity().getWindow().getDecorView());
    mKeyboardHelper.addSoftKeyboardStateListener(this);
    if (getActivity() instanceof OnSendClickListener) {
        listener = (OnSendClickListener) getActivity();
        mEmojiTitle.findViewById(R.id.emoji_title_send).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                listener.onClickSendButton(mEt.getText());
            }
        });
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) LayoutParams(android.widget.LinearLayout.LayoutParams) OnClickListener(android.view.View.OnClickListener) View(android.view.View) SoftKeyboardStateHelper(org.kymjs.emoji.helper.SoftKeyboardStateHelper) CompoundButton(android.widget.CompoundButton) EmojiPagerAdapter(org.kymjs.emoji.adapter.EmojiPagerAdapter)

Example 40 with OnCheckedChangeListener

use of android.widget.CompoundButton.OnCheckedChangeListener in project KJFrameForAndroid by kymjs.

the class MineFragment method initWidget.

@Override
protected void initWidget(View parentView) {
    super.initWidget(parentView);
    mRlExit.setVisibility(View.GONE);
    mTvVersion.setText("当前版本" + SystemTool.getAppVersionName(outsideAty));
    mCbox.setChecked(PreferenceHelper.readBoolean(outsideAty, AppConfig.PUSH_SWITCH_FILE, AppConfig.PUSH_SWITCH_KEY));
    mCbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            PreferenceHelper.write(outsideAty, AppConfig.PUSH_SWITCH_FILE, AppConfig.PUSH_SWITCH_KEY, isChecked);
        }
    });
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) CompoundButton(android.widget.CompoundButton)

Aggregations

OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)63 CompoundButton (android.widget.CompoundButton)62 View (android.view.View)47 TextView (android.widget.TextView)40 ImageView (android.widget.ImageView)25 OnClickListener (android.view.View.OnClickListener)17 DialogInterface (android.content.DialogInterface)13 AlertDialog (android.app.AlertDialog)12 Button (android.widget.Button)12 OnClickListener (android.content.DialogInterface.OnClickListener)11 Cursor (android.database.Cursor)9 CheckBox (android.widget.CheckBox)9 LayoutInflater (android.view.LayoutInflater)8 Context (android.content.Context)7 Intent (android.content.Intent)7 Paint (android.graphics.Paint)7 AdapterView (android.widget.AdapterView)7 OnCancelListener (android.content.DialogInterface.OnCancelListener)6 TypedArray (android.content.res.TypedArray)6 Drawable (android.graphics.drawable.Drawable)5