use of android.widget.CheckedTextView in project SublimePicker by vikramkakkar.
the class SublimeTimePicker method initializeLayout.
private void initializeLayout() {
mContext = getContext();
setCurrentLocale(Locale.getDefault());
// process style attributes
final TypedArray a = mContext.obtainStyledAttributes(R.styleable.SublimeTimePicker);
final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final Resources res = mContext.getResources();
mSelectHours = res.getString(R.string.select_hours);
mSelectMinutes = res.getString(R.string.select_minutes);
DateFormatSymbols dfs = DateFormatSymbols.getInstance(mCurrentLocale);
String[] amPmStrings = dfs.getAmPmStrings();
if (amPmStrings.length == 2 && !TextUtils.isEmpty(amPmStrings[0]) && !TextUtils.isEmpty(amPmStrings[1])) {
mAmText = amPmStrings[0].length() > 2 ? amPmStrings[0].substring(0, 2) : amPmStrings[0];
mPmText = amPmStrings[1].length() > 2 ? amPmStrings[1].substring(0, 2) : amPmStrings[1];
} else {
// Defaults
mAmText = "AM";
mPmText = "PM";
}
final int layoutResourceId = R.layout.time_picker_layout;
final View mainView = inflater.inflate(layoutResourceId, this);
mHeaderView = mainView.findViewById(R.id.time_header);
// Set up hour/minute labels.
mHourView = (TextView) mainView.findViewById(R.id.hours);
mHourView.setOnClickListener(mClickListener);
ViewCompat.setAccessibilityDelegate(mHourView, new ClickActionDelegate(mContext, R.string.select_hours));
mSeparatorView = (TextView) mainView.findViewById(R.id.separator);
mMinuteView = (TextView) mainView.findViewById(R.id.minutes);
mMinuteView.setOnClickListener(mClickListener);
ViewCompat.setAccessibilityDelegate(mMinuteView, new ClickActionDelegate(mContext, R.string.select_minutes));
// Now that we have text appearances out of the way, make sure the hour
// and minute views are correctly sized.
mHourView.setMinWidth(computeStableWidth(mHourView, 24));
mMinuteView.setMinWidth(computeStableWidth(mMinuteView, 60));
// Set up AM/PM labels.
mAmPmLayout = mainView.findViewById(R.id.ampm_layout);
mAmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.am_label);
mAmLabel.setText(obtainVerbatim(amPmStrings[0]));
mAmLabel.setOnClickListener(mClickListener);
mPmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.pm_label);
mPmLabel.setText(obtainVerbatim(amPmStrings[1]));
mPmLabel.setOnClickListener(mClickListener);
ColorStateList headerTextColor = a.getColorStateList(R.styleable.SublimeTimePicker_spHeaderTextColor);
if (headerTextColor != null) {
mHourView.setTextColor(headerTextColor);
mSeparatorView.setTextColor(headerTextColor);
mMinuteView.setTextColor(headerTextColor);
mAmLabel.setTextColor(headerTextColor);
mPmLabel.setTextColor(headerTextColor);
}
// Set up header background, if available.
if (SUtils.isApi_22_OrHigher()) {
if (a.hasValueOrEmpty(R.styleable.SublimeTimePicker_spHeaderBackground)) {
SUtils.setViewBackground(mHeaderView, a.getDrawable(R.styleable.SublimeTimePicker_spHeaderBackground));
}
} else {
if (a.hasValue(R.styleable.SublimeTimePicker_spHeaderBackground)) {
SUtils.setViewBackground(mHeaderView, a.getDrawable(R.styleable.SublimeTimePicker_spHeaderBackground));
}
}
a.recycle();
mRadialTimePickerView = (RadialTimePickerView) mainView.findViewById(R.id.radial_picker);
setupListeners();
mAllowAutoAdvance = true;
// Set up for keyboard mode.
mDoublePlaceholderText = res.getString(R.string.time_placeholder);
mDeletedKeyFormat = res.getString(R.string.deleted_key);
mPlaceholderText = mDoublePlaceholderText.charAt(0);
mAmKeyCode = mPmKeyCode = -1;
generateLegalTimesTree();
// Initialize with current time
final Calendar calendar = Calendar.getInstance(mCurrentLocale);
final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
final int currentMinute = calendar.get(Calendar.MINUTE);
initialize(currentHour, currentMinute, false, /* 12h */
HOUR_INDEX);
}
use of android.widget.CheckedTextView in project double-espresso by JakeWharton.
the class ViewMatchersTest method testCheckBoxMatchers.
public void testCheckBoxMatchers() {
assertFalse(isChecked().matches(new Spinner(getInstrumentation().getTargetContext())));
assertFalse(isNotChecked().matches(new Spinner(getInstrumentation().getTargetContext())));
CheckBox checkBox = new CheckBox(getInstrumentation().getTargetContext());
checkBox.setChecked(true);
assertTrue(isChecked().matches(checkBox));
assertFalse(isNotChecked().matches(checkBox));
checkBox.setChecked(false);
assertFalse(isChecked().matches(checkBox));
assertTrue(isNotChecked().matches(checkBox));
RadioButton radioButton = new RadioButton(getInstrumentation().getTargetContext());
radioButton.setChecked(false);
assertFalse(isChecked().matches(radioButton));
assertTrue(isNotChecked().matches(radioButton));
radioButton.setChecked(true);
assertTrue(isChecked().matches(radioButton));
assertFalse(isNotChecked().matches(radioButton));
CheckedTextView checkedText = new CheckedTextView(getInstrumentation().getTargetContext());
checkedText.setChecked(false);
assertFalse(isChecked().matches(checkedText));
assertTrue(isNotChecked().matches(checkedText));
checkedText.setChecked(true);
assertTrue(isChecked().matches(checkedText));
assertFalse(isNotChecked().matches(checkedText));
Checkable checkable = new Checkable() {
@Override
public boolean isChecked() {
return true;
}
@Override
public void setChecked(boolean ignored) {
}
@Override
public void toggle() {
}
};
assertFalse(isChecked().matches(checkable));
assertFalse(isNotChecked().matches(checkable));
}
use of android.widget.CheckedTextView in project LeafPic by HoraApps.
the class TrackSelectionHelper method onClick.
// View.OnClickListener
@Override
public void onClick(View view) {
isDisabled = false;
@SuppressWarnings("unchecked") Pair<Integer, Integer> tag = (Pair<Integer, Integer>) view.getTag();
int groupIndex = tag.first;
int trackIndex = tag.second;
if (!trackGroupsAdaptive[groupIndex] || override == null || override.groupIndex != groupIndex) {
override = new SelectionOverride(FIXED_FACTORY, groupIndex, trackIndex);
} else {
// The group being modified is adaptive and we already have a non-null override.
boolean isEnabled = ((CheckedTextView) view).isChecked();
int overrideLength = override.length;
if (isEnabled) {
// Remove the track from the override.
if (overrideLength == 1) {
// The last track is being removed, so the override becomes empty.
override = null;
isDisabled = true;
} else {
setOverride(groupIndex, getTracksRemoving(override, trackIndex), false);
}
} else {
// Add the track to the override.
setOverride(groupIndex, getTracksAdding(override, trackIndex), false);
}
}
// Update the views with the new state.
updateViews();
}
use of android.widget.CheckedTextView in project LeafPic by HoraApps.
the class TrackSelectionHelper method buildView.
@SuppressLint("InflateParams")
private View buildView(LayoutInflater inflater) {
View view = inflater.inflate(R.layout.track_selection_dialog, null);
ViewGroup root = view.findViewById(R.id.root);
trackViews = new CheckedTextView[trackGroups.length][];
for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) {
TrackGroup group = trackGroups.get(groupIndex);
boolean groupIsAdaptive = trackGroupsAdaptive[groupIndex];
trackViews[groupIndex] = new CheckedTextView[group.length];
for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
if (trackIndex == 0) {
root.addView(inflater.inflate(R.layout.list_divider, root, false));
}
int trackViewLayoutId = groupIsAdaptive ? android.R.layout.simple_list_item_multiple_choice : android.R.layout.simple_list_item_single_choice;
CheckedTextView trackView = (CheckedTextView) inflater.inflate(trackViewLayoutId, root, false);
trackView.setText(buildTrackName(group.getFormat(trackIndex)));
if (trackInfo.getTrackFormatSupport(rendererIndex, groupIndex, trackIndex) == RendererCapabilities.FORMAT_HANDLED) {
trackView.setFocusable(true);
trackView.setTag(Pair.create(groupIndex, trackIndex));
trackView.setOnClickListener(this);
} else {
trackView.setFocusable(false);
trackView.setEnabled(false);
}
trackViews[groupIndex][trackIndex] = trackView;
root.addView(trackView);
}
}
updateViews();
return view;
}
use of android.widget.CheckedTextView in project nucleus by konmik.
the class MainFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
check1 = (CheckedTextView) view.findViewById(R.id.check1);
check2 = (CheckedTextView) view.findViewById(R.id.check2);
check1.setText(MainPresenter.NAME_1);
check2.setText(MainPresenter.NAME_2);
check1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getPresenter().request(MainPresenter.NAME_1);
}
});
check2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getPresenter().request(MainPresenter.NAME_2);
}
});
ListView listView = (ListView) view.findViewById(R.id.listView);
listView.setAdapter(adapter = new ArrayAdapter<>(getActivity(), R.layout.item));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ServerAPI.Item item = adapter.getItem(position);
((MainActivity) getActivity()).push(new ItemFragment(item.toString()));
}
});
}
Aggregations