use of android.widget.Checkable in project developmentDependencyLibrary by MatchlessBrother.
the class StickyHVAListViewAdapter method getView.
public ItemAView getView(int position, View convertView, ViewGroup parent) {
ItemAView itemAView = (convertView == null) ? new ItemAView(mContext) : (ItemAView) convertView;
View item = mStickyHeadersAdapter.getView(position, itemAView.mItem, parent);
View header = null;
if (previousPositionHasSameHeader(position))
recycleStickyHeadersViewIfExist(itemAView);
else
header = configureHeader(itemAView, position);
if ((item instanceof Checkable) && !(itemAView instanceof ItemCheckableView))
itemAView = new ItemCheckableView(mContext);
else if (!(item instanceof Checkable) && (itemAView instanceof ItemCheckableView))
itemAView = new ItemAView(mContext);
itemAView.updateView(item, header, mDivider, mDividerHeight);
return itemAView;
}
use of android.widget.Checkable in project incubator-weex by apache.
the class WXPickersModule method performSinglePick.
private void performSinglePick(final List<String> items, final Map<String, Object> options, final JSCallback callback) {
selected = getOption(options, KEY_INDEX, 0);
final int textColor = getColor(options, KEY_TEXT_COLOR, Color.TRANSPARENT);
final int selectionColor = getColor(options, KEY_SELECTION_COLOR, Color.TRANSPARENT);
final ArrayAdapter adapter = new ArrayAdapter<String>(mWXSDKInstance.getContext(), android.R.layout.simple_list_item_single_choice, items) {
@NonNull
@Override
public View getView(int position, View convertView, @Nullable ViewGroup parent) {
View itemView = super.getView(position, convertView, parent);
if (itemView != null && itemView instanceof Checkable) {
boolean needSelected = position == selected;
((Checkable) itemView).setChecked(needSelected);
if (needSelected) {
itemView.setBackgroundColor(selectionColor);
} else {
itemView.setBackgroundColor(Color.TRANSPARENT);
}
}
if (itemView instanceof TextView && textColor != Color.TRANSPARENT) {
((TextView) itemView).setTextColor(textColor);
}
return itemView;
}
};
final AlertDialog dialog = new AlertDialog.Builder(mWXSDKInstance.getContext()).setAdapter(adapter, null).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// which == -1
Map<String, Object> ret = new HashMap<>(2);
ret.put(RESULT, SUCCESS);
ret.put(DATA, selected);
callback.invoke(ret);
}
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// which == -2
Map<String, Object> ret = new HashMap<>(2);
ret.put(RESULT, CANCEL);
ret.put(DATA, -1);
callback.invoke(ret);
}
}).setCustomTitle(makeTitleView(mWXSDKInstance.getContext(), options)).create();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// pre create the content view on dialog.
// if not , the content view will not be created until dialog.show() called
dialog.create();
}
final ListView listView = dialog.getListView();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selected = position;
adapter.notifyDataSetChanged();
}
});
dialog.getWindow().getDecorView().post(WXThread.secure(new Runnable() {
@Override
public void run() {
Button confirm = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
Button cancel = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
if (confirm != null) {
String confirmTitle = getOption(options, KEY_CONFIRM_TITLE, null);
int confirmColor = getColor(options, KEY_CONFIRM_TITLE_COLOR, Color.TRANSPARENT);
if (confirmTitle != null) {
confirm.setText(confirmTitle);
confirm.setAllCaps(false);
}
if (confirmColor != Color.TRANSPARENT) {
confirm.setTextColor(confirmColor);
confirm.setAllCaps(false);
}
}
if (cancel != null) {
String cancelTitle = getOption(options, KEY_CANCEL_TITLE, null);
int cancelColor = getColor(options, KEY_CANCEL_TITLE_COLOR, Color.TRANSPARENT);
if (cancelTitle != null) {
cancel.setText(cancelTitle);
}
if (cancelColor != Color.TRANSPARENT) {
cancel.setTextColor(cancelColor);
}
}
}
}));
dialog.show();
}
use of android.widget.Checkable in project android_packages_apps_Settings by SudaMod.
the class UsbModeChooserActivity method inflateOption.
private void inflateOption(final int mode, boolean selected, LinearLayout container, final boolean disallowedByAdmin) {
View v = mLayoutInflater.inflate(R.layout.restricted_radio_with_summary, container, false);
TextView titleView = (TextView) v.findViewById(android.R.id.title);
titleView.setText(getTitle(mode));
TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
updateSummary(summaryView, mode);
if (disallowedByAdmin) {
if (mEnforcedAdmin != null) {
setDisabledByAdmin(v, titleView, summaryView);
} else {
return;
}
}
v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (disallowedByAdmin && mEnforcedAdmin != null) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(UsbModeChooserActivity.this, mEnforcedAdmin);
return;
}
if (!ActivityManager.isUserAMonkey()) {
mBackend.setMode(mode);
}
mDialog.dismiss();
finish();
}
});
((Checkable) v).setChecked(selected);
container.addView(v);
}
use of android.widget.Checkable in project platform_packages_apps_Settings by BlissRoms.
the class UsbModeChooserActivity method inflateOption.
private void inflateOption(final int mode, boolean selected, LinearLayout container, final boolean disallowedByAdmin) {
View v = mLayoutInflater.inflate(R.layout.restricted_radio_with_summary, container, false);
TextView titleView = (TextView) v.findViewById(android.R.id.title);
titleView.setText(getTitle(mode));
TextView summaryView = (TextView) v.findViewById(android.R.id.summary);
updateSummary(summaryView, mode);
if (disallowedByAdmin) {
if (mEnforcedAdmin != null) {
setDisabledByAdmin(v, titleView, summaryView);
} else {
return;
}
}
v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (disallowedByAdmin && mEnforcedAdmin != null) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(UsbModeChooserActivity.this, mEnforcedAdmin);
return;
}
if (!ActivityManager.isUserAMonkey()) {
mBackend.setMode(mode);
}
mDialog.dismiss();
finish();
}
});
((Checkable) v).setChecked(selected);
container.addView(v);
}
use of android.widget.Checkable in project platform_packages_apps_Settings by BlissRoms.
the class CellDataPreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
View switchView = holder.findViewById(android.R.id.switch_widget);
switchView.setClickable(false);
((Checkable) switchView).setChecked(mChecked);
}
Aggregations