androidx.appcompat.widget.AppCompatCheckBox Java Examples

The following examples show how to use androidx.appcompat.widget.AppCompatCheckBox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BoxItemAdapter.java    From box-android-browse-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates a new Box item view holder.
 *
 * @param itemView the item view
 */
public BoxItemViewHolder(View itemView) {
    super(itemView);
    itemView.setOnClickListener(this);
    if (mListener.getMultiSelectHandler() != null) {
        itemView.setOnLongClickListener(this);
    }
    mView = itemView;
    mThumbView = (ImageView) itemView.findViewById(R.id.box_browsesdk_thumb_image);
    mNameView = (TextView) itemView.findViewById(R.id.box_browsesdk_name_text);
    mMetaDescription = (TextView) itemView.findViewById(R.id.metaline_description);
    mProgressBar = (ProgressBar) itemView.findViewById((R.id.spinner));
    mSecondaryAction = (ImageButton) itemView.findViewById(R.id.secondaryAction);
    mItemCheckBox = (AppCompatCheckBox) itemView.findViewById(R.id.boxItemCheckBox);
    mSecondaryClickListener = new BoxItemClickListener();
    if (mSecondaryAction != null) {
        mSecondaryAction.setOnClickListener(mSecondaryClickListener);
    }
}
 
Example #2
Source File: DialogPaletteSettings.java    From microMathematics with GNU General Public License v3.0 6 votes vote down vote up
private void prepareGroup(Context context, LinearLayout itemLayout, String s, List<String> visibleGroups)
{
    final AppCompatCheckBox cb = itemLayout.findViewById(R.id.dialog_palette_settings_checkbox);
    cb.setTag(s);
    cb.setChecked(visibleGroups.contains(s));
    final LinearLayout buttonLayout = itemLayout.findViewById(R.id.dialog_palette_settings_buttons);
    for (int i = 0; i < buttonLayout.getChildCount(); i++)
    {
        if (buttonLayout.getChildAt(i) instanceof AppCompatImageButton)
        {
            final AppCompatImageButton b = (AppCompatImageButton) buttonLayout.getChildAt(i);
            b.setOnLongClickListener(this);
            ViewUtils.setImageButtonColorAttr(context, b, R.attr.colorDialogContent);
        }
    }
}
 
Example #3
Source File: DialogPaletteSettings.java    From microMathematics with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v)
{
    boolean isChanged = false;
    if (v.getId() == R.id.dialog_button_ok)
    {
        List<String> visibleGroups = new ArrayList<>();
        for (int i = 0; i < paletteView.getChildCount(); i++)
        {
            final LinearLayout itemLayout = (LinearLayout) paletteView.getChildAt(i);
            final AppCompatCheckBox cb = itemLayout.findViewById(R.id.dialog_palette_settings_checkbox);
            if (cb.isChecked())
            {
                visibleGroups.add(cb.getTag().toString());
            }
        }
        changeIf.onPaletteVisibleChange(visibleGroups);
    }
    closeDialog();
}
 
Example #4
Source File: FilterView.java    From mimi-reader with Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
    inflate(context, R.layout.post_filter_view, this);

    activeBoard = (AppCompatSpinner) findViewById(R.id.active_board);
    activeBoard.setOnItemSelectedListener(onBoardClicked());

    nameInput = (AppCompatEditText) findViewById(R.id.filter_name);
    filterInput = (AppCompatEditText) findViewById(R.id.filter_text);
    highlightCheckBox = (AppCompatCheckBox) findViewById(R.id.highlight_checkbox);

    saveButton = (AppCompatButton) findViewById(R.id.save_button);

    saveButton.setOnClickListener(this);
    findViewById(R.id.edit_button).setOnClickListener(this);
    findViewById(R.id.cancel_button).setOnClickListener(this);
}
 
Example #5
Source File: ContactSelectionFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    final View itemLayout =
            mInflater.inflate(R.layout.contact_select_list_item, parent, false);

    final ContactViewHolder holder = new ContactViewHolder();

    holder.textView1 = (TextView) itemLayout.findViewById(R.id.applozic_group_member_info);
    holder.textView2 = (TextView) itemLayout.findViewById(R.id.displayName);
    holder.contactNumberTextView = (TextView) itemLayout.findViewById(R.id.contactNumberTextView);
    holder.checkBox = (AppCompatCheckBox) itemLayout.findViewById(R.id.checkbox);
    holder.checkBox.setVisibility(View.VISIBLE);
    holder.alphabeticImage = (TextView) itemLayout.findViewById(R.id.alphabeticImage);
    holder.circleImageView = (CircleImageView) itemLayout.findViewById(R.id.contactImage);
    itemLayout.setTag(holder);
    return itemLayout;
}
 
Example #6
Source File: ContactSelectionFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {

    final Cursor cursor = mAdapter.getCursor();
    cursor.moveToPosition(position);
    Contact contact = contactDatabase.getContact(cursor, "_id");
    if (disableCheckBox) {
        isUserPresnt = ChannelService.getInstance(getActivity()).isUserAlreadyPresentInChannel(channel.getKey(), contact.getContactIds());
        if (!isUserPresnt) {
            Intent intent = new Intent();
            intent.putExtra(ChannelInfoActivity.USERID, contact.getUserId());
            getActivity().setResult(getActivity().RESULT_OK, intent);
            getActivity().finish();
        }
    } else {
        AppCompatCheckBox checkBox = (AppCompatCheckBox) view.findViewById(R.id.checkbox);
        checkBox.toggle();
        if (checkBox.isChecked()) {
            userIdList.add(contact.getContactIds());
        } else if (!checkBox.isChecked()) {
            userIdList.remove(contact.getContactIds());
        }
    }
}
 
Example #7
Source File: LSettingItem.java    From a with GNU General Public License v3.0 5 votes vote down vote up
private void initView(Context context) {
    mView = View.inflate(context, R.layout.settingitem, this);
    mRootLayout = (RelativeLayout) mView.findViewById(R.id.rootLayout);
    mUnderLine = (View) mView.findViewById(R.id.underline);
    mTvLeftText = (TextView) mView.findViewById(R.id.tv_lefttext);
    mTvRightText = (TextView) mView.findViewById(R.id.tv_righttext);
    mIvLeftIcon = (ImageView) mView.findViewById(R.id.iv_lefticon);
    mIvRightIcon = (ImageView) mView.findViewById(R.id.iv_righticon);
    mRightLayout = (FrameLayout) mView.findViewById(R.id.rightlayout);
    mRightIcon_check = (AppCompatCheckBox) mView.findViewById(R.id.rightcheck);
    mRightIcon_switch = (SwitchCompat) mView.findViewById(R.id.rightswitch);
    mTvIntroText = (TextView) mView.findViewById(R.id.tv_intro);
}
 
Example #8
Source File: ConsumeFragment.java    From AndroidGodEye with Apache License 2.0 5 votes vote down vote up
private Set<String> getModulesSelected() {
    Set<String> modules = new HashSet<>();
    for (int i = 0; i < mCbGroup.getChildCount(); i++) {
        AppCompatCheckBox cb = (AppCompatCheckBox) mCbGroup.getChildAt(i);
        if (cb.isChecked()) {
            modules.add(String.valueOf(cb.getText()));
        }
    }
    return modules;
}
 
Example #9
Source File: ConsumeFragment.java    From AndroidGodEye with Apache License 2.0 5 votes vote down vote up
public void onInstallModuleChanged() {
    mCbGroup.removeAllViews();
    Set<String> modules = GodEye.instance().getInstalledModuleNames();
    for (@GodEye.ModuleName String module : modules) {
        AppCompatCheckBox appCompatCheckBox = new AppCompatCheckBox(Objects.requireNonNull(ConsumeFragment.this.getActivity()));
        appCompatCheckBox.setText(module);
        mCbGroup.addView(appCompatCheckBox);
    }
}
 
Example #10
Source File: KcaResoureLogFragment.java    From kcanotify with GNU General Public License v3.0 5 votes vote down vote up
public View setView(final View v) {
    Log.e("KCA", "setView " + position);
    v.setTag("fragment_view");
    v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_box_%d", position), R.id.class)).setVisibility(View.VISIBLE);
    v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_box_%d", 1 - position), R.id.class)).setVisibility(GONE);

    for (int i = 0; i < 4; i++) {
        final int k = i;
        AppCompatCheckBox box = v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_%d_%d", position, i), R.id.class));
        box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                is_draw_enabled[k] = b;
                setChartDataVisibility(v, k);
            }
        });
        box.setChecked(is_draw_enabled[k]);
    }

    ((TextView) v.findViewById(R.id.reslog_item_label_0)).setText(getStringWithLocale(R.string.reslog_label_date));
    if (position == 0) {
        ((TextView) v.findViewById(R.id.reslog_item_label_1)).setText(getStringWithLocale(R.string.item_fuel));
        ((TextView) v.findViewById(R.id.reslog_item_label_2)).setText(getStringWithLocale(R.string.item_ammo));
        ((TextView) v.findViewById(R.id.reslog_item_label_3)).setText(getStringWithLocale(R.string.item_stel));
        ((TextView) v.findViewById(R.id.reslog_item_label_4)).setText(getStringWithLocale(R.string.item_baux));
    } else {
        ((TextView) v.findViewById(R.id.reslog_item_label_1)).setText(getStringWithLocale(R.string.item_bgtz));
        ((TextView) v.findViewById(R.id.reslog_item_label_2)).setText(getStringWithLocale(R.string.item_brnr));
        ((TextView) v.findViewById(R.id.reslog_item_label_3)).setText(getStringWithLocale(R.string.item_mmat));
        ((TextView) v.findViewById(R.id.reslog_item_label_4)).setText(getStringWithLocale(R.string.item_kmat));
    }

    ListView resource_data = v.findViewById(R.id.reslog_listview);
    resource_data.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    drawChart(v);
    return v;
}
 
Example #11
Source File: CheckBoxItem.java    From pandora with Apache License 2.0 4 votes vote down vote up
@Override
public void onBinding(int position, UniversalAdapter.ViewPool pool, Boolean data) {
    ((AppCompatCheckBox)pool.itemView).setChecked(data);
    ((AppCompatCheckBox)pool.itemView).setText(title);
}
 
Example #12
Source File: BoxFilterSearchResultsFragment.java    From box-android-browse-sdk with Apache License 2.0 4 votes vote down vote up
public FileTypeData(final BoxSearchFilters.ItemType type, RelativeLayout container, AppCompatCheckBox checkbox) {
    mItemType = type;
    mContainer = container;
    mCheckBox = checkbox;
}
 
Example #13
Source File: MaterialComponentsViewInflater.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
protected AppCompatCheckBox createCheckBox(Context context, AttributeSet attrs) {
  return new MaterialCheckBox(context, attrs);
}
 
Example #14
Source File: BasePreferenceData.java    From Status with Apache License 2.0 4 votes vote down vote up
public void onBindViewHolder(final ViewHolder holder, int position) {
    if (identifier != null) {
        final TextView title = holder.v.findViewById(R.id.title);
        TextView subtitle = holder.v.findViewById(R.id.subtitle);
        AppCompatCheckBox checkBox = holder.v.findViewById(R.id.checkBox);

        if (title != null)
            title.setText(identifier.getTitle());
        if (subtitle != null) {
            String text = identifier.getSubtitle();
            if (text.length() > 0) {
                subtitle.setVisibility(View.VISIBLE);
                subtitle.setText(text);
            } else subtitle.setVisibility(View.GONE);
        }

        if (checkBox != null) {
            checkBox.setVisibility(isNullable ? View.VISIBLE : View.GONE);
            if (isNullable) {
                Object value = identifier.getPreferenceValue(getContext());
                boolean isNonNull = value != null && !value.equals(nullValue);

                if (title != null)
                    title.setAlpha(isNonNull ? 1 : 0.5f);

                checkBox.setOnCheckedChangeListener(null);
                checkBox.setChecked(isNonNull);
                checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
                    if (title != null)
                        title.animate().alpha(isChecked ? 1 : 0.5f).start();

                    if (isChecked)
                        onClick(holder.itemView);
                    else {
                        identifier.setPreferenceValue(getContext(), null);
                        onPreferenceChange(null);
                    }

                    onBindViewHolder(holder, -1);
                });
            }
        }
    }

    holder.v.setOnClickListener(this);
}
 
Example #15
Source File: ConsumeFragment.java    From AndroidGodEye with Apache License 2.0 4 votes vote down vote up
private void toggleAllModule(boolean check) {
    for (int i = 0; i < mCbGroup.getChildCount(); i++) {
        AppCompatCheckBox cb = (AppCompatCheckBox) mCbGroup.getChildAt(i);
        cb.setChecked(check);
    }
}
 
Example #16
Source File: MainActivity.java    From HaoReader with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 菜单事件
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    SharedPreferences.Editor editor = getPreferences().edit();
    int id = item.getItemId();
    switch (id) {
        case R.id.action_add_local:
            requestPermissions(FILE_SELECT_RESULT);
            break;
        case R.id.action_add_url:
            InputDialog.show(getSupportFragmentManager(), "添加书籍网址", null, inputText -> mPresenter.addBookUrl(inputText));
            break;
        case R.id.action_list_grid:
            viewIsList = !viewIsList;
            editor.putBoolean("bookshelfIsList", viewIsList);
            if (editor.commit()) {
                Optional.ofNullable(findFragment(MainBookListFragment.class)).ifPresent(mainBookListFragment -> mainBookListFragment.upLayoutType(viewIsList));
            }
            break;
        case R.id.action_clearCaches:
            new AlertDialog.Builder(getSupportFragmentManager())
                    .setTitle(R.string.dialog_title)
                    .setView(R.layout.dialog_clear_cache_tip)
                    .setNegativeButton(R.string.cancel, null)
                    .setPositiveButton(R.string.ok, (dialog, which) -> {
                        AppCompatCheckBox checkBox = dialog.findViewById(R.id.checker_clear_chapter);
                        mPresenter.cleanCaches(checkBox.isChecked());
                    })
                    .show();
            break;
        case R.id.action_clearBookshelf:
            new AlertDialog.Builder(getSupportFragmentManager())
                    .setTitle(R.string.dialog_title)
                    .setMessage(R.string.clear_bookshelf_s)
                    .setNegativeButton(R.string.cancel, null)
                    .setPositiveButton(R.string.ok, (dialog, which) -> mPresenter.clearBookshelf())
                    .show();
            break;
        case R.id.action_web_start:
            WebService.startThis(this);
            break;
        case android.R.id.home:
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawers();
            } else {
                drawer.openDrawer(GravityCompat.START);
            }
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example #17
Source File: BoxItemAdapter.java    From box-android-browse-sdk with Apache License 2.0 2 votes vote down vote up
/**
 * Gets check box from the view represented by this view holder
 *
 * @return the check box
 */
public AppCompatCheckBox getCheckBox() {
    return mItemCheckBox;
}