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;
}
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);
}
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;
}
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());
}
});
}
}
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);
}
});
}
Aggregations