Search in sources :

Example 76 with Checkable

use of android.widget.Checkable in project HoloEverywhere by Prototik.

the class SwitchPreference method onBindView.

@Override
protected void onBindView(View view) {
    super.onBindView(view);
    View checkableView = view.findViewById(R.id.switchWidget);
    if (checkableView != null && checkableView instanceof Checkable) {
        ((Checkable) checkableView).setChecked(mChecked);
        sendAccessibilityEvent(checkableView);
        if (checkableView instanceof Switch) {
            final Switch switchView = (Switch) checkableView;
            switchView.setTextOn(mSwitchOn);
            switchView.setTextOff(mSwitchOff);
            switchView.setOnCheckedChangeListener(mListener);
        }
    }
    syncSummaryView(view);
}
Also used : Switch(org.holoeverywhere.widget.Switch) Checkable(android.widget.Checkable) View(android.view.View)

Example 77 with Checkable

use of android.widget.Checkable in project StickyListHeaders by emilsjolander.

the class AdapterWrapper method getView.

@Override
public WrapperView getView(int position, View convertView, ViewGroup parent) {
    WrapperView wv = (convertView == null) ? new WrapperView(mContext) : (WrapperView) convertView;
    View item = mDelegate.getView(position, wv.mItem, parent);
    View header = null;
    if (previousPositionHasSameHeader(position)) {
        recycleHeaderIfExists(wv);
    } else {
        header = configureHeader(wv, position);
    }
    if ((item instanceof Checkable) && !(wv instanceof CheckableWrapperView)) {
        // Need to create Checkable subclass of WrapperView for ListView to work correctly
        wv = new CheckableWrapperView(mContext);
    } else if (!(item instanceof Checkable) && (wv instanceof CheckableWrapperView)) {
        wv = new WrapperView(mContext);
    }
    wv.update(item, header, mDivider, mDividerHeight);
    return wv;
}
Also used : Checkable(android.widget.Checkable) View(android.view.View)

Example 78 with Checkable

use of android.widget.Checkable in project android-styled-dialogs by avast.

the class CheckableLinearLayout method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    // find checkable items
    int childCount = getChildCount();
    for (int i = 0; i < childCount; ++i) {
        View v = getChildAt(i);
        if (v instanceof Checkable) {
            mCheckablesSet.add((Checkable) v);
        }
    }
}
Also used : Checkable(android.widget.Checkable) View(android.view.View)

Example 79 with Checkable

use of android.widget.Checkable in project Klyph by jonathangerbaud.

the class HListView method setupChild.

/**
 * Add a view as a child and make sure it is measured (if necessary) and positioned properly.
 *
 * @param child
 *           The view to add
 * @param position
 *           The position of this child
 * @param x
 *           The x position relative to which this view will be positioned
 * @param flowDown
 *           If true, align left edge to x. If false, align right edge to x.
 * @param childrenTop
 *           Top edge where children should be positioned
 * @param selected
 *           Is this position selected?
 * @param recycled
 *           Has this view been pulled from the recycle bin? If so it does not need to be remeasured.
 */
private void setupChild(View child, int position, int x, boolean flowDown, int childrenTop, boolean selected, boolean recycled) {
    final boolean isSelected = selected && shouldShowSelector();
    final boolean updateChildSelected = isSelected != child.isSelected();
    final int mode = mTouchMode;
    final boolean isPressed = mode > TOUCH_MODE_DOWN && mode < TOUCH_MODE_SCROLL && mMotionPosition == position;
    final boolean updateChildPressed = isPressed != child.isPressed();
    final boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
    // Respect layout params that are already in the view. Otherwise make some up...
    // noinspection unchecked
    AbsHListView.LayoutParams p = (AbsHListView.LayoutParams) child.getLayoutParams();
    if (p == null) {
        p = (AbsHListView.LayoutParams) generateDefaultLayoutParams();
    }
    p.viewType = mAdapter.getItemViewType(position);
    if ((recycled && !p.forceAdd) || (p.recycledHeaderFooter && p.viewType == AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER)) {
        attachViewToParent(child, flowDown ? -1 : 0, p);
    } else {
        p.forceAdd = false;
        if (p.viewType == AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER) {
            p.recycledHeaderFooter = true;
        }
        addViewInLayout(child, flowDown ? -1 : 0, p, true);
    }
    if (updateChildSelected) {
        child.setSelected(isSelected);
    }
    if (updateChildPressed) {
        child.setPressed(isPressed);
    }
    if (mChoiceMode != ListView.CHOICE_MODE_NONE && mCheckStates != null) {
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(mCheckStates.get(position));
        } else if (android.os.Build.VERSION.SDK_INT >= 11) {
            child.setActivated(mCheckStates.get(position));
        }
    }
    if (needToMeasure) {
        int childHeightSpec = ViewGroup.getChildMeasureSpec(mHeightMeasureSpec, mListPadding.top + mListPadding.bottom, p.height);
        int lpWidth = p.width;
        int childWidthSpec;
        if (lpWidth > 0) {
            childWidthSpec = MeasureSpec.makeMeasureSpec(lpWidth, MeasureSpec.EXACTLY);
        } else {
            childWidthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
        }
        child.measure(childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    final int w = child.getMeasuredWidth();
    final int h = child.getMeasuredHeight();
    final int childLeft = flowDown ? x : x - w;
    if (needToMeasure) {
        final int childBottom = childrenTop + h;
        final int childRight = childLeft + w;
        child.layout(childLeft, childrenTop, childRight, childBottom);
    } else {
        child.offsetLeftAndRight(childLeft - child.getLeft());
        child.offsetTopAndBottom(childrenTop - child.getTop());
    }
    if (mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        if (recycled && (((AbsHListView.LayoutParams) child.getLayoutParams()).scrappedFromPosition) != position) {
            child.jumpDrawablesToCurrentState();
        }
    }
}
Also used : Checkable(android.widget.Checkable) Paint(android.graphics.Paint)

Aggregations

Checkable (android.widget.Checkable)79 View (android.view.View)47 TextView (android.widget.TextView)18 ViewGroup (android.view.ViewGroup)9 OnClickListener (android.view.View.OnClickListener)7 ImageView (android.widget.ImageView)7 Switch (android.widget.Switch)7 ResourceReference (com.android.ide.common.rendering.api.ResourceReference)6 Resources (android.content.res.Resources)5 Paint (android.graphics.Paint)5 Point (android.graphics.Point)4 SuppressLint (android.annotation.SuppressLint)3 AdapterView (android.widget.AdapterView)3 CheckBox (android.widget.CheckBox)3 ListView (android.widget.ListView)3 Spinner (android.widget.Spinner)3 Map (java.util.Map)3 Switch (org.holoeverywhere.widget.Switch)3 SimpleArrayMap (android.support.v4.util.SimpleArrayMap)2 AlertDialog (android.support.v7.app.AlertDialog)2