下面列出了怎么用android.support.v7.widget.AppCompatCheckBox的API类实例代码及写法,或者点击链接到github查看源代码。
public ViewHolderWithRadioButtonCheckBox(View view) {
super(view);
mCheckBox = (AppCompatCheckBox) view.findViewById(R.id.check);
View.OnClickListener radioListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
long itemKeyId = getMKeys().get(getAdapterPosition()).getId();
if (mSelectedKeyIds.contains(itemKeyId)) {
mSelectedKeyIds.remove(itemKeyId);
} else {
mSelectedKeyIds.add(itemKeyId);
}
notifyItemRangeChanged(0, getMKeys().size());
}
};
mCheckBox.setOnClickListener(radioListener);
getMView().setOnClickListener(null);
}
public ProgressDialog(@NonNull Context context,@NonNull String title) {
super(context);
View dialog_view=LayoutInflater.from(context).inflate(R.layout.dialog_with_progress,null);
setView(dialog_view);
progressBar=dialog_view.findViewById(R.id.dialog_progress_bar);
att=dialog_view.findViewById(R.id.dialog_att);
att_left=dialog_view.findViewById(R.id.dialog_att_left);
att_right=dialog_view.findViewById(R.id.dialog_att_right);
((AppCompatCheckBox)dialog_view.findViewById(R.id.dialog_progress_keep_on)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
try{
if(isChecked){
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}catch (Exception e){e.printStackTrace();}
}
});
setTitle(title);
}
private void showBackupNameEditor() {
View v = getActivity().getLayoutInflater().inflate(R.layout.dialog_backup_layout, null);
String defName = StringUtils.getTimeFileName();
EditText tvFileName = v.findViewById(R.id.export_file_name);
tvFileName.setText(defName);
AppCompatCheckBox cb = v.findViewById(R.id.backup_include_settings);
new MaterialDialog.Builder(getActivity())
.title(R.string.backup_data_export_message)
.customView(v, false)
.positiveText(R.string.text_confirm)
.onPositive((dialog, which) -> {
String backupName;
if (TextUtils.isEmpty(backupName = tvFileName.getText().toString())) {
ToastUtils.makeToast(R.string.backup_data_export_name_empty);
backupName = defName;
}
Intent service = new Intent(getActivity(), DataBackupIntentService.class);
service.setAction(DataBackupIntentService.ACTION_DATA_EXPORT);
service.putExtra(DataBackupIntentService.INTENT_BACKUP_INCLUDE_SETTINGS, cb.isChecked());
service.putExtra(DataBackupIntentService.INTENT_BACKUP_NAME, backupName);
getActivity().startService(service);
}).build().show();
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.i("AlarmFrcheckListener", "buttonView=" + buttonView);
if (isChecked) {
confirmable = true;
if (buttonView.getId() == map[0]) {
checkedOnce(true);
} else {
checkedOnce(false);
}
} else {
for (int id : map) {
if (((AppCompatCheckBox) findViewById(id)).isChecked()) {
confirmable = true;
break;
}
confirmable = false;
}
}
mTvConfirm.setTextColor(confirmable ? context.getResources().getColor(R.color.base_blue)
: context.getResources().getColor(R.color.forbid_click_color));
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.afd_confirm) {
if (!((AppCompatCheckBox) findViewById(map[0])).isChecked()) {
fr = 0;
for (int i = 1; i < map.length; i++) {
if (((AppCompatCheckBox) findViewById(map[i])).isChecked()) {
fr <<= 3;
fr += i;
}
}
if (fr == 0) {
return;
}
repeat = true;
} else {
int week = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
fr = week - 1 > 0 ? week - 1 : 7;
repeat = false;
}
if (onResultListener != null) {
onResultListener.onResult(fr, repeat);
}
}
cancel();
}
private void init() {
mRgChoice.setVisibility(View.GONE);
mChoiceBox.setVisibility(View.VISIBLE);
mCdTitle.setText(title);
for (int i = 0; i < datas.length; i++) {
AppCompatCheckBox cb = new AppCompatCheckBox(mContext);
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-1, ScreenUtil.getInstance().dip2px(48));
cb.setLayoutParams(layoutParams);
cb.setGravity(Gravity.CENTER_VERTICAL);
cb.setId(i);
cb.setText(datas[i]);
cb.setTextSize(15);
cb.setTextColor(mContext.getResources().getColor(R.color.new_text_color_first));
cb.setPadding(ScreenUtil.getInstance().dip2px(16), 0, 0, 0);
if (i == 0)
cb.setChecked(true);
mChoiceBox.addView(cb);
}
}
@Override
protected void initUI() {
LinearLayout linearLayout=new LinearLayout(getContext());
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
checkBox=new AppCompatCheckBox(getContext());
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
TodoLayout.this.isChecked=isChecked;
}
});
editText=new BaseRichEditText(getContext());
editText.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,1.0f));
linearLayout.addView(checkBox);
linearLayout.addView(editText);
this.addView(linearLayout);
}
public void reportIssue (View v) {
if (enableGitHubLogin) {
final AppCompatCheckBox githubCheckbox = (AppCompatCheckBox) findViewById(R.id.gittyreporter_github_checkbox);
EditText userName = (EditText) findViewById(R.id.gittyreporter_login_username);
EditText userPassword = (EditText) findViewById(R.id.gittyreporter_login_password);
if (!githubCheckbox.isChecked()){
if (validateGitHubLogin()){
this.gitUser = userName.getText().toString();
this.gitPassword = userPassword.getText().toString();
sendBugReport();
}
} else {
this.gitUser = "";
this.gitPassword = "";
sendBugReport();
}
} else {
if (validateBugReport()) {
this.gitUser = "";
this.gitPassword = "";
sendBugReport();
}
}
}
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
// Allow super to try and create a view first
final View result = super.onCreateView(name, context, attrs);
if (result != null) {
return result;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
switch (name) {
case "EditText":
return new AppCompatEditText(this,attrs);
case "Spinner":
return new AppCompatSpinner(this,attrs);
case "CheckBox":
return new AppCompatCheckBox(this,attrs);
case "RadioButton":
return new AppCompatRadioButton(this,attrs);
case "CheckedTextView":
return new AppCompatCheckedTextView(this,attrs);
}
}
return null;
}
public void prepareSelection(View view, int position) {
if (((AppCompatCheckBox) view).isChecked()) {
++sCounter;
} else {
--sCounter;
}
updateToolbarText();
}
@Override
protected void convert(BaseViewHolder helper, EssFile item) {
if (item.getItemType() == EssFile.CAPTURE) {
helper.getView(R.id.media).setVisibility(View.GONE);
helper.getView(R.id.capture).setVisibility(View.VISIBLE);
helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(mImageResize- UiUtils.dpToPx(mContext,4), mImageResize));
helper.addOnClickListener(R.id.capture);
} else {
helper.getView(R.id.capture).setVisibility(View.GONE);
helper.getView(R.id.media).setVisibility(View.VISIBLE);
helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, mImageResize));
ImageView imageView = helper.getView(R.id.media_thumbnail);
RequestOptions options = new RequestOptions()
.centerCrop()
.override(mImageResize, mImageResize)
.placeholder(SelectOptions.getInstance().placeHolder == null ? mContext.getResources().getDrawable(R.mipmap.png_holder) : SelectOptions.getInstance().placeHolder);
Glide
.with(mContext)
.load(item.getUri())
.apply(options)
.into(imageView);
if(SelectOptions.getInstance().isSingle || SelectOptions.getInstance().maxCount == 1){
helper.setVisible(R.id.check_view,false);
}else {
AppCompatCheckBox checkBox = helper.getView(R.id.check_view);
helper.setVisible(R.id.check_view,true);
helper.addOnClickListener(R.id.check_view);
helper.addOnClickListener(R.id.media_thumbnail);
checkBox.setChecked(item.isChecked());
}
}
}
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;
}
private void initCheckBox() {
AppCompatCheckBox checkBox = findViewById(R.id.checkBox);
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
}
});
}
public AppCompatCheckBox getCheckBox(String str) {
AppCompatCheckBox cb = null;
switch (str) {
case "btnRaiseHand":
cb = btnRaiseHand;
break;
case "btnSwitchCamera":
cb = btnSwitchCamera;
break;
case "btnCloseCamera":
// cb=btnCloseCamera;
break;
case "btnMuteMic":
// cb=btnMuteMic;
break;
case "btnMuteSpeaker":
cb = btnMuteSpeaker;
break;
case "btnWhiteBoard":
cb = btnWhiteBoard;
break;
case "btn_modeSelect":
cb = btn_modeSelect;
break;
}
return cb;
}
@Override
protected void convert(BaseViewHolder helper, EssFile item) {
if (item.getItemType() == EssFile.CAPTURE) {
helper.getView(R.id.media).setVisibility(View.GONE);
helper.getView(R.id.capture).setVisibility(View.VISIBLE);
helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(mImageResize- UiUtils.dpToPx(mContext,4), mImageResize));
helper.addOnClickListener(R.id.capture);
} else {
helper.getView(R.id.capture).setVisibility(View.GONE);
helper.getView(R.id.media).setVisibility(View.VISIBLE);
helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, mImageResize));
ImageView imageView = helper.getView(R.id.media_thumbnail);
RequestOptions options = new RequestOptions()
.centerCrop()
.override(mImageResize, mImageResize)
.placeholder(SelectOptions.getInstance().placeHolder == null ? mContext.getResources().getDrawable(R.mipmap.png_holder) : SelectOptions.getInstance().placeHolder);
Glide
.with(mContext)
.load(item.getUri())
.apply(options)
.into(imageView);
if(SelectOptions.getInstance().isSingle || SelectOptions.getInstance().maxCount == 1){
helper.setVisible(R.id.check_view,false);
}else {
AppCompatCheckBox checkBox = helper.getView(R.id.check_view);
helper.setVisible(R.id.check_view,true);
helper.addOnClickListener(R.id.check_view);
helper.addOnClickListener(R.id.media_thumbnail);
checkBox.setChecked(item.isChecked());
}
}
}
/**
* 仅一次与其他周期互斥
**/
private void checkedOnce(boolean flag) {
if (flag) {
for (int i = 1; i < map.length; i++) {
((AppCompatCheckBox) findViewById(map[i])).setChecked(false);
}
} else {
((AppCompatCheckBox) findViewById(map[0])).setChecked(false);
}
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
checkBox = (AppCompatCheckBox)findViewById(R.id.checkbox);
textView = (AppCompatTextView)findViewById(R.id.tv1);
}
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
if (view == null) {
view = View.inflate(mContext, R.layout.tooltips_popup, null);
}
TextView content = view.findViewById( R.id.content);
TextView desc = view.findViewById( R.id.desc);
AppCompatCheckBox checkBox = view.findViewById( R.id.checkbox);
TextView button = view.findViewById( R.id.button);
content.setText(mBuilder.mContent);
button.setText(mBuilder.mButton);
if (mBuilder.mDesc != null) {
desc.setVisibility(View.VISIBLE);
desc.setText(mBuilder.mDesc);
if (mBuilder.mDescIcon != 0) {
int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
Drawable drawable = DrawableHelper.getTintedDrawable(mContext, mBuilder.mDescIcon, color);
desc.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
}
}
checkBox.setVisibility(mBuilder.mIsDontShowAgainVisible ? View.VISIBLE : View.GONE);
checkBox.setOnCheckedChangeListener((compoundButton, b) -> mCheckboxState = b);
button.setOnClickListener(v -> {
if (mBuilder.mCallback != null) {
mBuilder.mCallback.onButtonClick(mTooltip);
return;
}
mTooltip.dismiss();
});
return view;
}
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
// Allow super to try and create a view first
final View result = super.onCreateView(name, context, attrs);
if (result != null) {
return result;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// If we're running pre-L, we need to 'inject' our tint aware Views in place of the
// standard framework versions
switch (name) {
case "EditText":
return new AppCompatEditText(this, attrs);
case "Spinner":
return new AppCompatSpinner(this, attrs);
case "CheckBox":
return new AppCompatCheckBox(this, attrs);
case "RadioButton":
return new AppCompatRadioButton(this, attrs);
case "CheckedTextView":
return new AppCompatCheckedTextView(this, attrs);
}
}
return null;
}
private void coreInit() {
LinearLayout layout = new LinearLayout(getActivity());
layout.setOrientation(LinearLayout.VERTICAL);
mCoreCheckBox = new AppCompatCheckBox[CPU.getBigCoreRange().size()];
mCoreProgressBar = new ProgressBar[mCoreCheckBox.length];
mCoreUsageText = new AppCompatTextView[mCoreCheckBox.length];
mCoreFreqText = new AppCompatTextView[mCoreCheckBox.length];
for (int i = 0; i < mCoreCheckBox.length; i++) {
View view = inflater.inflate(R.layout.coreview, container, false);
mCoreCheckBox[i] = (AppCompatCheckBox) view.findViewById(R.id.core_checkbox);
mCoreCheckBox[i].setText(getString(R.string.core, i));
mCoreCheckBox[i].setOnClickListener(this);
mCoreProgressBar[i] = (ProgressBar) view.findViewById(R.id.progressbar);
mCoreProgressBar[i].setMax(CPU.getFreqs().size());
mCoreUsageText[i] = (AppCompatTextView) view.findViewById(R.id.usage);
mCoreFreqText[i] = (AppCompatTextView) view.findViewById(R.id.freq);
layout.addView(view);
}
CardViewItem.DCardView coreCard = new CardViewItem.DCardView();
coreCard.setTitle(getString(R.string.current_freq));
coreCard.setView(layout);
addView(coreCard);
}
private void coreLITTLEInit() {
LinearLayout layout = new LinearLayout(getActivity());
layout.setOrientation(LinearLayout.VERTICAL);
mCoreCheckBoxLITTLE = new AppCompatCheckBox[CPU.getLITTLECoreRange().size()];
mCoreProgressBarLITTLE = new ProgressBar[mCoreCheckBoxLITTLE.length];
mCoreUsageTextLITTLE = new AppCompatTextView[mCoreCheckBoxLITTLE.length];
mCoreFreqTextLITTLE = new AppCompatTextView[mCoreCheckBoxLITTLE.length];
for (int i = 0; i < mCoreCheckBoxLITTLE.length; i++) {
View view = inflater.inflate(R.layout.coreview, container, false);
mCoreCheckBoxLITTLE[i] = (AppCompatCheckBox) view.findViewById(R.id.core_checkbox);
mCoreCheckBoxLITTLE[i].setText(getString(R.string.core, i));
mCoreCheckBoxLITTLE[i].setOnClickListener(this);
mCoreProgressBarLITTLE[i] = (ProgressBar) view.findViewById(R.id.progressbar);
mCoreProgressBarLITTLE[i].setMax(CPU.getFreqs(CPU.getLITTLEcore()).size());
mCoreUsageTextLITTLE[i] = (AppCompatTextView) view.findViewById(R.id.usage);
mCoreFreqTextLITTLE[i] = (AppCompatTextView) view.findViewById(R.id.freq);
layout.addView(view);
}
CardViewItem.DCardView coreCard = new CardViewItem.DCardView();
coreCard.setTitle(getString(R.string.current_freq));
coreCard.setView(layout);
addView(coreCard);
}
public void init() {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
((AppCompatCheckBox) findViewById(R.id.enable_color_transition)).setOnCheckedChangeListener(this);
((AppCompatCheckBox) findViewById(R.id.enable_single_ripple)).setOnCheckedChangeListener(this);
((AppCompatCheckBox) findViewById(R.id.enable_stroke_ripple)).setOnCheckedChangeListener(this);
((AppCompatCheckBox) findViewById(R.id.enable_random_position)).setOnCheckedChangeListener(this);
((AppCompatCheckBox) findViewById(R.id.enable_random_color)).setOnCheckedChangeListener(this);
ripple = (ShapeRipple) findViewById(R.id.ripple);
ripple.setRippleShape(new Circle());
final DiscreteSeekBar rippleDuration = (DiscreteSeekBar) findViewById(R.id.ripple_duration);
final DiscreteSeekBar rippleCount = (DiscreteSeekBar) findViewById(R.id.ripple_count);
final DiscreteSeekBar rippleMaxSize = (DiscreteSeekBar) findViewById(R.id.ripple_max_size);
rippleDuration.setOnProgressChangeListener(this);
rippleCount.setOnProgressChangeListener(this);
rippleMaxSize.setOnProgressChangeListener(this);
ripple.post(new Runnable() {
@Override
public void run() {
rippleCount.setMax(ripple.getRippleCount() * 2);
rippleCount.setProgress(ripple.getRippleCount());
rippleMaxSize.setMax((int)ripple.getRippleMaximumRadius() * 3);
rippleMaxSize.setProgress((int)ripple.getRippleMaximumRadius());
rippleMaxSize.setMin((int)(ripple.getRippleMaximumRadius() * 0.25));
}
});
}
private void updateVisibilityFormat(ProductItem item)
{
Resources resources = cache.getActivity().getResources();
TextView productNameTextView = productItemCache.getProductNameTextView();
TextView productQuantityTextView = productItemCache.getQuantityTextView();
TextView quantityTextView = productItemCache.getQuantityTextView();
CardView productCard = productItemCache.getProductCard();
AppCompatCheckBox checkbox = (AppCompatCheckBox) productItemCache.getCheckbox();
if ( item.isChecked() )
{
int grey = resources.getColor(R.color.middlegrey);
productCard.setCardBackgroundColor(resources.getColor(R.color.transparent));
checkbox.setSupportButtonTintList(ColorStateList.valueOf(resources.getColor(R.color.middleblue)));
productNameTextView.setTextColor(grey);
quantityTextView.setTextColor(grey);
productNameTextView.setPaintFlags(productNameTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
productQuantityTextView.setPaintFlags(productQuantityTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
int black = resources.getColor(R.color.black);
productCard.setCardBackgroundColor(resources.getColor(R.color.white));
checkbox.setSupportButtonTintList(ColorStateList.valueOf(resources.getColor(R.color.colorAccent)));
productNameTextView.setTextColor(black);
quantityTextView.setTextColor(black);
productNameTextView.setPaintFlags(productNameTextView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
productQuantityTextView.setPaintFlags(productQuantityTextView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
}
}
private void updateVisibilityFormat(ProductItem item)
{
Resources resources = deleteProductItemCache.getProductCard().getContext().getResources();
TextView productNameTextView = deleteProductItemCache.getProductNameTextView();
TextView productQuantityTextView = deleteProductItemCache.getProductQuantityTextView();
AppCompatCheckBox checkBox = (AppCompatCheckBox) deleteProductItemCache.getCheckBox();
if ( item.isSelectedForDeletion() )
{
int transparent = resources.getColor(R.color.transparent);
int grey = resources.getColor(R.color.middlegrey);
deleteProductItemCache.getProductCard().setCardBackgroundColor(transparent);
productNameTextView.setTextColor(grey);
productQuantityTextView.setTextColor(grey);
checkBox.setSupportButtonTintList(ColorStateList.valueOf(grey));
productNameTextView.setPaintFlags(productNameTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
productQuantityTextView.setPaintFlags(productQuantityTextView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
int white = resources.getColor(R.color.white);
int black = resources.getColor(R.color.black);
deleteProductItemCache.getProductCard().setCardBackgroundColor(white);
productNameTextView.setTextColor(black);
productQuantityTextView.setTextColor(black);
checkBox.setSupportButtonTintList(ColorStateList.valueOf(black));
productNameTextView.setPaintFlags(productNameTextView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
productQuantityTextView.setPaintFlags(productQuantityTextView.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
}
}
private void coreInit() {
LinearLayout layout = new LinearLayout(getActivity());
layout.setOrientation(LinearLayout.VERTICAL);
mCoreCheckBox = new AppCompatCheckBox[CPU.getBigCoreRange().size()];
mCoreProgressBar = new ProgressBar[mCoreCheckBox.length];
mCoreUsageText = new AppCompatTextView[mCoreCheckBox.length];
mCoreFreqText = new AppCompatTextView[mCoreCheckBox.length];
for (int i = 0; i < mCoreCheckBox.length; i++) {
View view = inflater.inflate(R.layout.coreview, container, false);
mCoreCheckBox[i] = (AppCompatCheckBox) view.findViewById(R.id.core_checkbox);
mCoreCheckBox[i].setText(String.format(getString(R.string.core), i + 1));
mCoreCheckBox[i].setOnClickListener(this);
mCoreProgressBar[i] = (ProgressBar) view.findViewById(R.id.progressbar);
mCoreProgressBar[i].setMax(CPU.getFreqs().size());
mCoreUsageText[i] = (AppCompatTextView) view.findViewById(R.id.usage);
mCoreFreqText[i] = (AppCompatTextView) view.findViewById(R.id.freq);
layout.addView(view);
}
CardViewItem.DCardView coreCard = new CardViewItem.DCardView();
coreCard.setTitle(getString(R.string.current_freq));
coreCard.setView(layout);
addView(coreCard);
}
private void coreLITTLEInit() {
LinearLayout layout = new LinearLayout(getActivity());
layout.setOrientation(LinearLayout.VERTICAL);
mCoreCheckBoxLITTLE = new AppCompatCheckBox[CPU.getLITTLECoreRange().size()];
mCoreProgressBarLITTLE = new ProgressBar[mCoreCheckBoxLITTLE.length];
mCoreUsageTextLITTLE = new AppCompatTextView[mCoreCheckBoxLITTLE.length];
mCoreFreqTextLITTLE = new AppCompatTextView[mCoreCheckBoxLITTLE.length];
for (int i = 0; i < mCoreCheckBoxLITTLE.length; i++) {
View view = inflater.inflate(R.layout.coreview, container, false);
mCoreCheckBoxLITTLE[i] = (AppCompatCheckBox) view.findViewById(R.id.core_checkbox);
mCoreCheckBoxLITTLE[i].setText(getString(R.string.core, i + 1));
mCoreCheckBoxLITTLE[i].setOnClickListener(this);
mCoreProgressBarLITTLE[i] = (ProgressBar) view.findViewById(R.id.progressbar);
mCoreProgressBarLITTLE[i].setMax(CPU.getFreqs(CPU.getLITTLEcore()).size());
mCoreUsageTextLITTLE[i] = (AppCompatTextView) view.findViewById(R.id.usage);
mCoreFreqTextLITTLE[i] = (AppCompatTextView) view.findViewById(R.id.freq);
layout.addView(view);
}
CardViewItem.DCardView coreCard = new CardViewItem.DCardView();
coreCard.setTitle(getString(R.string.current_freq));
coreCard.setView(layout);
addView(coreCard);
}
private View initViewDefault(LayoutInflater inflater, ViewGroup parent) {
RadioGroup radioGroup = new RadioGroup(inflater.getContext());
radioGroup.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
radioGroup.setDividerDrawable(ContextCompat.getDrawable(parent.getContext(),
R.drawable.rsb_divider_empty_8dp));
for (int i = 0; i < choices.length; i++) {
Choice<T> item = choices[i];
// Create & add the View to our body-view
AppCompatCheckBox checkBox = (AppCompatCheckBox) inflater.inflate(R.layout.rsb_item_checkbox,
radioGroup,
false);
checkBox.setText(item.getText());
checkBox.setId(i);
radioGroup.addView(checkBox);
// Set initial state
if (currentSelected.contains(item.getValue())) {
checkBox.setChecked(true);
}
// Update result when value changes
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
currentSelected.add(item.getValue());
} else {
currentSelected.remove(item.getValue());
}
});
}
return radioGroup;
}
private void init() {
inflate(getContext(), R.layout.expandable_list_item_view, this);
mRoot = (RelativeLayout) findViewById(R.id.expandable_list_item_view_root);
mText = (TextView) findViewById(R.id.expandable_list_item_view_text);
mCheckbox = (AppCompatCheckBox) findViewById(R.id.expandable_list_item_view_checkbox);
mViewSeparator = findViewById(R.id.expandable_list_item_view_separator);
this.mRoot.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mCheckbox.setChecked(!mCheckbox.isChecked());
}
});
}
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
// Allow super to try and create a view first
final View result = super.onCreateView(name, context, attrs);
if (result != null) {
return result;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// If we're running pre-L, we need to 'inject' our tint aware Views in place of the
// standard framework versions
switch (name) {
case "EditText":
return new AppCompatEditText(this, attrs);
case "Spinner":
return new AppCompatSpinner(this, attrs);
case "CheckBox":
return new AppCompatCheckBox(this, attrs);
case "RadioButton":
return new AppCompatRadioButton(this, attrs);
case "CheckedTextView":
return new AppCompatCheckedTextView(this, attrs);
}
}
return null;
}
public UpFilesListHolder(@NonNull View itemView) {
super(itemView);
mFileName = (AppCompatTextView) itemView.findViewById(R.id.filename);
mCheckBox = (AppCompatCheckBox) itemView.findViewById(R.id.checkbox);
mFileSize = (AppCompatTextView) itemView.findViewById(R.id.filesize);
mThumbnail = (AppCompatImageView) itemView.findViewById(R.id.thumbnail);
}