android.widget.Checkable Java Examples

The following examples show how to use android.widget.Checkable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: ToggleButtonGroup   Author: nex3z   File: ToggleButtonGroup.java    License: Apache License 2.0 6 votes vote down vote up
public void onChildViewAdded(View parent, View child) {
    if (parent == ToggleButtonGroup.this && child instanceof Checkable) {
        if (child.getId() == View.NO_ID) {
            child.setId(generateIdForView(child));
        }
        if (child instanceof ToggleButton) {
            setStateTracker((ToggleButton) child);
        } else if (child instanceof CompoundButton) {
            setStateTracker((CompoundButton) child);
        }
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
Example #2
Source Project: Klyph   Author: jonathangerbaud   File: AbsHListView.java    License: MIT License 6 votes vote down vote up
/**
 * Perform a quick, in-place update of the checked or activated state on all visible item views. This should only be called when
 * a valid choice mode is active.
 */
private void updateOnScreenCheckedViews() {
	final int firstPos = mFirstPosition;
	final int count = getChildCount();
	final boolean useActivated = android.os.Build.VERSION.SDK_INT >= 11;
	for ( int i = 0; i < count; i++ ) {
		final View child = getChildAt( i );
		final int position = firstPos + i;

		if ( child instanceof Checkable ) {
			( (Checkable) child ).setChecked( mCheckStates.get( position ) );
		} else if ( useActivated ) {
			child.setActivated( mCheckStates.get( position ) );
		}
	}
}
 
Example #3
Source Project: letv   Author: JackChan1999   File: AbsHListView.java    License: Apache License 2.0 6 votes vote down vote up
private void updateOnScreenCheckedViews() {
    boolean useActivated;
    int firstPos = this.mFirstPosition;
    int count = getChildCount();
    if (VERSION.SDK_INT >= 11) {
        useActivated = true;
    } else {
        useActivated = false;
    }
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        int position = firstPos + i;
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        } else if (useActivated) {
            child.setActivated(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        }
    }
}
 
Example #4
Source Project: ToggleButtonGroup   Author: nex3z   File: SingleSelectToggleGroup.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void addView(View child, int index, LayoutParams params) {
    if (child instanceof Checkable) {
        final Checkable checkable = (Checkable) child;
        if (checkable.isChecked()) {
            if (mCheckedId != -1) {
                setCheckedStateForView(mCheckedId, false);
            }
            if (child.getId() == View.NO_ID) {
                child.setId(generateIdForView(child));
            }
            setCheckedId(child.getId());
        }
        if (child instanceof MarkerButton) {
            ((MarkerButton) child).setRadioStyle(true);
        }
    }

    super.addView(child, index, params);
}
 
Example #5
Source Project: budget-envelopes   Author: notriddle   File: DeleteView.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void setInnerView(View innerView) {
    if (mInnerView != null) {
        removeView(innerView);
    }
    mInnerView = innerView;
    addView(innerView);
    if (mInnerView instanceof Checkable) {
        ((Checkable)mInnerView).setChecked(mChecked);
    }
    if (mSwipeState == STATE_PRESSED) {
        cancelPressed();
        mSwipeState = STATE_READY;
    } else if (mSwipeState != STATE_READY) {
        cancelSwipe();
    }
}
 
Example #6
Source Project: United4   Author: nilesr   File: NotificationSettingsFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
    View res = getView();
    if (res == null) return;
    boolean enabled = ((Checkable) res.findViewById(R.id.notifications_enabled)).isChecked();
    P.set("notifications", enabled ? "true" : "false");
    res.findViewById(R.id.notify_all).setEnabled(enabled);
    res.findViewById(R.id.notify_direct).setEnabled(enabled);
    res.findViewById(R.id.notify_direct_and_created).setEnabled(enabled);
    res.findViewById(R.id.hour).setEnabled(enabled);
    res.findViewById(R.id.half_day).setEnabled(enabled);
    res.findViewById(R.id.day).setEnabled(enabled);
    if (enabled && b) {
        notify_which_listener.onCheckedChanged(null, true);
        notify_duration_listener.onCheckedChanged(null, true);
    }
}
 
Example #7
Source Project: Carbon   Author: ZieIony   File: RadioGroup.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (child instanceof Checkable) {
        final Checkable button = (Checkable) child;
        if (button.isChecked()) {
            mProtectFromCheckedChange = true;
            if (mCheckedId != -1) {
                setCheckedStateForView(mCheckedId, false);
            }
            mProtectFromCheckedChange = false;
            setCheckedId(child.getId());
        }
    }

    super.addView(child, index, params);
}
 
Example #8
@Override
public void onClick(View v) {

    int position = (int) v.getTag();

    if (v instanceof Checkable) {
        if (((Checkable) v).isChecked()) {
            setActiveUser(position);
        } else {
            ((Checkable) v).setChecked(true);
        }
    } else {
        showUserProfile(position);
    }

}
 
Example #9
Source Project: StickyListHeadersWithRefreshAndLoadMore   Author: soulrelay   File: AdapterWrapper.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #10
Source Project: android_9.0.0_r45   Author: lulululbj   File: CheckBoxPreference.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    View checkboxView = view.findViewById(com.android.internal.R.id.checkbox);
    if (checkboxView != null && checkboxView instanceof Checkable) {
        ((Checkable) checkboxView).setChecked(mChecked);
    }

    syncSummaryView(view);
}
 
Example #11
Source Project: NestedSelectionRadioGroup   Author: LatoAndroid   File: BaseRadioLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void setUpChildCheckStatus(View view, boolean checked) {
    view.setSelected(checked);
    if (view instanceof Checkable &&  !(view instanceof BaseRadioLayout)){
        ((Checkable) view).setChecked(checked);
        view.setFocusable(false);
        view.setClickable(false);
        view.setFocusableInTouchMode(false);
    }
    if (view instanceof ViewGroup){
        ViewGroup group = (ViewGroup) view;
        for (int i = 0; i < group.getChildCount(); i++) {
            setUpChildCheckStatus(group.getChildAt(i), checked);
        }
    }
}
 
Example #12
/**
 * Determines if the supplied {@link View} is one which would produce speech if it were to gain
 * accessibility focus.
 *
 * <p>NOTE: This method also evaluates the subtree of the {@code view} for children that should be
 * included in {@code view}'s spoken description.
 *
 * @param view The {@link View} to evaluate
 * @return {@code true} if a spoken description for {@code view} was determined, {@code false}
 *     otherwise.
 */
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN) // Calls hasNonActionableSpeakingChildren
private static boolean isSpeakingView(View view) {
  if (hasText(view)) {
    return true;
  } else if (view instanceof Checkable) {
    // Special case for checkable items, which screen readers may describe without text
    return true;
  } else if (hasNonActionableSpeakingChildren(view)) {
    return true;
  }

  return false;
}
 
Example #13
Source Project: imsdk-android   Author: qunarcorp   File: BaseViewHolder.java    License: MIT License 5 votes vote down vote up
/**
 * Sets the checked status of a checkable.
 *
 * @param viewId  The view id.
 * @param checked The checked status;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setChecked(@IdRes int viewId, boolean checked) {
    View view = getView(viewId);
    // View unable cast to Checkable
    if (view instanceof Checkable) {
        ((Checkable) view).setChecked(checked);
    }
    return this;
}
 
Example #14
@Override
public void onClick(View view) {
    if (view instanceof Checkable) {
        int position = (int) view.getTag();
        mFilterKeywordsManager.toggleKeyword(position);
    }
}
 
Example #15
Source Project: MultiChoiceAdapter   Author: ManuelPeinado   File: MultiChoiceAdapterHelperBase.java    License: Apache License 2.0 5 votes vote down vote up
public View getView(int position, View viewWithoutSelection) {
    if (viewWithoutSelection instanceof Checkable) {
        long handle = positionToSelectionHandle(position);
        boolean selected = isChecked(handle);
        ignoreCheckedListener = true;
        ((Checkable) viewWithoutSelection).setChecked(selected);
        ignoreCheckedListener = false;
    }
    if (itemIncludesCheckBox(viewWithoutSelection)) {
        initItemCheckbox(position, (ViewGroup) viewWithoutSelection);
    }
    return viewWithoutSelection;
}
 
Example #16
Source Project: onpc   Author: mkulesh   File: DragSortItemViewCheckable.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isChecked()
{
    View child = getChildAt(0);
    if (child instanceof Checkable)
        return ((Checkable) child).isChecked();
    else
        return false;
}
 
Example #17
Source Project: onpc   Author: mkulesh   File: DragSortItemViewCheckable.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setChecked(boolean checked)
{
    View child = getChildAt(0);
    if (child instanceof Checkable)
        ((Checkable) child).setChecked(checked);
}
 
Example #18
Source Project: onpc   Author: mkulesh   File: DragSortItemViewCheckable.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void toggle()
{
    View child = getChildAt(0);
    if (child instanceof Checkable)
        ((Checkable) child).toggle();
}
 
Example #19
Source Project: android-styled-dialogs   Author: avast   File: CheckableLinearLayout.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setChecked(boolean checked) {
    if (checked == this.mChecked) {
        return;
    }
    this.mChecked = checked;
    for (Checkable checkable : mCheckablesSet) {
        checkable.setChecked(checked);
    }
    refreshDrawableState();
}
 
Example #20
Source Project: MaterialPreference   Author: RikkaW   File: CheckBoxPreference.java    License: Apache License 2.0 5 votes vote down vote up
private void syncCheckboxView(View view) {
    if (view instanceof CompoundButton) {
        ((CompoundButton) view).setOnCheckedChangeListener(null);
    }
    if (view instanceof Checkable) {
        ((Checkable) view).setChecked(mChecked);
    }
    if (view instanceof CompoundButton) {
        ((CompoundButton) view).setOnCheckedChangeListener(mListener);
    }
}
 
Example #21
Source Project: litho   Author: facebook   File: TestItem.java    License: Apache License 2.0 5 votes vote down vote up
public boolean isChecked() {
  if (mContent instanceof Checkable) {
    return ((Checkable) mContent).isChecked();
  }

  throw new UnsupportedOperationException(
      "This Litho component can't be checked, we can't determine its check state.");
}
 
Example #22
Source Project: Field-Book   Author: PhenoApps   File: DragSortItemViewCheckable.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setChecked(boolean checked) {
    View child = getChildAt(0);
    if (child instanceof Checkable) {
        ((Checkable) child).setChecked(checked);
    }
}
 
Example #23
Source Project: document-viewer   Author: SufficientlySecure   File: SwitchPreferenceEx.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected Checkable getCheckableView(final View view) {
    if (view instanceof Checkable) {
        return (Checkable) view;
    } else if (view instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) view;
        for (int i = 0; i < group.getChildCount(); i++) {
            final View v = group.getChildAt(i);
            if (v instanceof Checkable) {
                return (Checkable) v;
            }
        }
    }
    return null;
}
 
Example #24
Source Project: AndroidRipper   Author: reverse-unina   File: ReflectionNoValuesExtractor.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Set Value of the Widget
 * 
 * @param v
 *            Widget
 * @param wd
 *            WidgetDescription instance
 */
protected void setValue(View v, WidgetDescription wd) {

	// Checkboxes, radio buttons and toggle buttons -> the value is the
	// checked state (true or false)
	if (v instanceof Checkable) {
		wd.setValue(String.valueOf(((Checkable) v).isChecked()));
	}

	// Textview, Editview et al. -> the value is the displayed text
	if (v instanceof TextView) {
		wd.setValue(((TextView) v).getText().toString());
		// wd.setValue("");
		return;
	}

	// Progress bars, seek bars and rating bars -> the value is the current
	// progress
	if (v instanceof ProgressBar) {
		//wd.setValue(String.valueOf(((ProgressBar) v).getProgress()));
		wd.setValue("");
	}

	if (v instanceof ImageView) {
		ImageView imgView = (ImageView) v;
		// TODO:
	}

}
 
Example #25
Source Project: FamilyChat   Author: Vanish136   File: RcvHolder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置View是否可选
 */
public RcvHolder setChecked(int viewId, boolean checked)
{
    Checkable view = (Checkable) findView(viewId);
    view.setChecked(checked);
    return this;
}
 
Example #26
Source Project: AndrOBD   Author: fr3ts0n   File: CheckableRelativeLayout.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void setChecked(boolean isChecked)
{
	this.isChecked = isChecked;
	for (Checkable c : checkableViews)
	{
		c.setChecked(isChecked);
	}
}
 
Example #27
Source Project: Android-Multiple-file-Selector-Dialog   Author: paulasiimwe   File: CheckableRelativeLayout.java    License: MIT License 5 votes vote down vote up
/**
 * Add to our checkable list all the children of the view that implement the
 * interface Checkable
 */
private void findCheckableChildren(View v) {
    if (v instanceof Checkable) {
        this.checkableViews.add((Checkable) v);
    }

    if (v instanceof ViewGroup) {
        final ViewGroup vg = (ViewGroup) v;
        final int childCount = vg.getChildCount();
        for (int i = 0; i < childCount; ++i) {
            findCheckableChildren(vg.getChildAt(i));
        }
    }
}
 
Example #28
Source Project: MultiView   Author: apptik   File: ItemSelectionSupport.java    License: Apache License 2.0 5 votes vote down vote up
@TargetApi(HONEYCOMB)
public void setViewChecked(View view, boolean checked) {
    if (view instanceof Checkable) {
        ((Checkable) view).setChecked(checked);
    } else if (Build.VERSION.SDK_INT >= HONEYCOMB) {
        view.setActivated(checked);
    }
}
 
Example #29
Source Project: SimpleDialogFragments   Author: eltos   File: AdvancedAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    // apply checked state
    if (convertView instanceof Checkable){
        ((Checkable) convertView).setChecked(isItemChecked(position));
        if (mNoAnimations){ // suppresses the check animation when filtering
            convertView.jumpDrawablesToCurrentState();
        }
    }

    return convertView;
}
 
Example #30
Source Project: UltimateAndroid   Author: cymcsg   File: DragSortListView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    DragSortItemView v;
    View child;
    // Log.d("mobeta",
    // "getView: position="+position+" convertView="+convertView);
    if (convertView != null) {
        v = (DragSortItemView) convertView;
        View oldChild = v.getChildAt(0);

        child = mAdapter.getView(position, oldChild, DragSortListView.this);
        if (child != oldChild) {
            // shouldn't get here if user is reusing convertViews
            // properly
            if (oldChild != null) {
                v.removeViewAt(0);
            }
            v.addView(child);
        }
    } else {
        child = mAdapter.getView(position, null, DragSortListView.this);
        if (child instanceof Checkable) {
            v = new DragSortItemViewCheckable(getContext());
        } else {
            v = new DragSortItemView(getContext());
        }
        v.setLayoutParams(new LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        v.addView(child);
    }

    // Set the correct item height given drag state; passed
    // View needs to be measured if measurement is required.
    adjustItem(position + getHeaderViewsCount(), v, true);

    return v;
}