Search in sources :

Example 11 with CheckedTextView

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);
}
Also used : TypedArray(android.content.res.TypedArray) LayoutInflater(android.view.LayoutInflater) Calendar(java.util.Calendar) ColorStateList(android.content.res.ColorStateList) DateFormatSymbols(java.text.DateFormatSymbols) Resources(android.content.res.Resources) View(android.view.View) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView)

Example 12 with CheckedTextView

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));
}
Also used : Spinner(android.widget.Spinner) CheckBox(android.widget.CheckBox) CheckedTextView(android.widget.CheckedTextView) RadioButton(android.widget.RadioButton) Checkable(android.widget.Checkable)

Example 13 with CheckedTextView

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();
}
Also used : SelectionOverride(com.google.android.exoplayer2.trackselection.MappingTrackSelector.SelectionOverride) CheckedTextView(android.widget.CheckedTextView) SuppressLint(android.annotation.SuppressLint) Pair(android.util.Pair) SelectionOverride(com.google.android.exoplayer2.trackselection.MappingTrackSelector.SelectionOverride)

Example 14 with CheckedTextView

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;
}
Also used : ViewGroup(android.view.ViewGroup) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) CheckedTextView(android.widget.CheckedTextView) View(android.view.View) CheckedTextView(android.widget.CheckedTextView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 15 with CheckedTextView

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()));
        }
    });
}
Also used : ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) CheckedTextView(android.widget.CheckedTextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

CheckedTextView (android.widget.CheckedTextView)26 View (android.view.View)17 TextView (android.widget.TextView)9 ListView (android.widget.ListView)6 AdapterView (android.widget.AdapterView)5 SuppressLint (android.annotation.SuppressLint)4 LayoutInflater (android.view.LayoutInflater)4 ArrayAdapter (android.widget.ArrayAdapter)3 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 TypedArray (android.content.res.TypedArray)2 Pair (android.util.Pair)2 ViewGroup (android.view.ViewGroup)2 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)2 SelectionOverride (com.google.android.exoplayer2.trackselection.MappingTrackSelector.SelectionOverride)2 GraphView (com.jjoe64.graphview.GraphView)2 Account (android.accounts.Account)1 Intent (android.content.Intent)1