本文整理汇总了Java中android.view.View.isEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java View.isEnabled方法的具体用法?Java View.isEnabled怎么用?Java View.isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.isEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findViewAt
import android.view.View; //导入方法依赖的package包/类
@Nullable
private View findViewAt(@NonNull final View view, final float x, final float y) {
if (!view.isShown() || !view.isEnabled() || !isViewAt(view, x, y)) {
return null;
}
if (view instanceof ViewGroup) {
final float transformedX = x - view.getLeft() - ViewCompat.getTranslationX(view);
final float transformedY = y - view.getTop() - ViewCompat.getTranslationY(view);
final ViewGroup viewGroup = (ViewGroup) view;
final int childCount = viewGroup.getChildCount();
for (int i = childCount - 1; i >= 0; i--) {
final View child = viewGroup.getChildAt(i);
final View foundView = findViewAt(child, transformedX, transformedY);
if (foundView != null) {
return foundView;
}
}
}
return view;
}
示例2: positionSelector
import android.view.View; //导入方法依赖的package包/类
protected void positionSelector(int position, View sel) {
if (position != -1) {
this.mSelectorPosition = position;
}
Rect selectorRect = this.mSelectorRect;
selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom());
if (sel instanceof SelectionBoundsAdjuster) {
((SelectionBoundsAdjuster) sel).adjustListItemSelectionBounds(selectorRect);
}
positionSelector(selectorRect.left, selectorRect.top, selectorRect.right, selectorRect.bottom);
boolean isChildViewEnabled = this.mIsChildViewEnabled;
if (sel.isEnabled() != isChildViewEnabled) {
this.mIsChildViewEnabled = !isChildViewEnabled;
if (getSelectedItemPosition() != -1) {
refreshDrawableState();
}
}
}
示例3: findClickableViewInChild
import android.view.View; //导入方法依赖的package包/类
private boolean findClickableViewInChild(View view, int x, int y) {
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
final Rect rect = new Rect();
child.getHitRect(rect);
final boolean contains = rect.contains(x, y);
if (contains) {
return findClickableViewInChild(child, x - rect.left, y - rect.top);
}
}
} else if (view != childView) {
return (view.isEnabled() && (view.isClickable() || view.isLongClickable() || view.isFocusableInTouchMode()));
}
return view.isFocusableInTouchMode();
}
示例4: positionSelector
import android.view.View; //导入方法依赖的package包/类
protected void positionSelector(int position, View sel) {
if (position != INVALID_POSITION) {
mSelectorPosition = position;
}
final Rect selectorRect = mSelectorRect;
selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(),
sel.getBottom());
if (sel instanceof SelectionBoundsAdjuster) {
((SelectionBoundsAdjuster) sel)
.adjustListItemSelectionBounds(selectorRect);
}
positionSelector(selectorRect.left, selectorRect.top,
selectorRect.right, selectorRect.bottom);
final boolean isChildViewEnabled = mIsChildViewEnabled;
if (sel.isEnabled() != isChildViewEnabled) {
mIsChildViewEnabled = !isChildViewEnabled;
if (getSelectedItemPosition() != INVALID_POSITION) {
refreshDrawableState();
}
}
}
示例5: positionSelectorCompat
import android.view.View; //导入方法依赖的package包/类
protected void positionSelectorCompat(int position, View sel) {
Rect selectorRect = this.mSelectorRect;
selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom());
selectorRect.left -= this.mSelectionLeftPadding;
selectorRect.top -= this.mSelectionTopPadding;
selectorRect.right += this.mSelectionRightPadding;
selectorRect.bottom += this.mSelectionBottomPadding;
try {
boolean isChildViewEnabled = this.mIsChildViewEnabled.getBoolean(this);
if (sel.isEnabled() != isChildViewEnabled) {
this.mIsChildViewEnabled.set(this, Boolean.valueOf(!isChildViewEnabled));
if (position != -1) {
refreshDrawableState();
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
示例6: setEnabledRecursive
import android.view.View; //导入方法依赖的package包/类
private void setEnabledRecursive(View v, boolean enabled) {
if (v == null)
return;
if (v.isEnabled() == enabled)
return;
v.setEnabled(enabled);
if (v instanceof ViewGroup) {
final ViewGroup vg = (ViewGroup) v;
for (int i = vg.getChildCount() - 1; i >= 0; i--) {
setEnabledRecursive(vg.getChildAt(i), enabled);
}
}
}
示例7: onItemClick
import android.view.View; //导入方法依赖的package包/类
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!view.isEnabled()) {
return;
}
mSelectedFolder = mListItems.get(position).mUri;
loadFolder(mSelectedFolder);
}
示例8: positionSelector
import android.view.View; //导入方法依赖的package包/类
void positionSelector(View sel) {
final Rect selectorRect = mSelectorRect;
selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom());
positionSelector(selectorRect.left, selectorRect.top, selectorRect.right,
selectorRect.bottom);
final boolean isChildViewEnabled = mIsChildViewEnabled;
if (sel.isEnabled() != isChildViewEnabled) {
mIsChildViewEnabled = !isChildViewEnabled;
refreshDrawableState();
}
}
示例9: positionSelector
import android.view.View; //导入方法依赖的package包/类
void positionSelector(View sel) {
Rect selectorRect = this.mSelectorRect;
selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom());
positionSelector(selectorRect.left, selectorRect.top, selectorRect.right, selectorRect
.bottom);
boolean isChildViewEnabled = this.mIsChildViewEnabled;
if (sel.isEnabled() != isChildViewEnabled) {
this.mIsChildViewEnabled = !isChildViewEnabled;
refreshDrawableState();
}
}
示例10: updateViewColor
import android.view.View; //导入方法依赖的package包/类
private void updateViewColor(View v)
{
final int attrId = v.isEnabled() ? R.attr.colorDialogContent : R.attr.colorDialogDisabledElement;
if (v instanceof ImageButton)
{
ViewUtils.setImageButtonColorAttr(getContext(), (ImageButton) v, attrId);
}
else if (v instanceof TextView)
{
final TextView b = (TextView) v;
b.setTextColor(CompatUtils.getThemeColorAttr(getContext(), attrId));
}
}
示例11: onLongPress
import android.view.View; //导入方法依赖的package包/类
private void onLongPress() {
clearCallbacks();
View src = this.mSrc;
if (src.isEnabled() && !src.isLongClickable() && onForwardingStarted()) {
src.getParent().requestDisallowInterceptTouchEvent(true);
long now = SystemClock.uptimeMillis();
MotionEvent e = MotionEvent.obtain(now, now, 3, 0.0f, 0.0f, 0);
src.onTouchEvent(e);
e.recycle();
this.mForwarding = true;
this.mWasLongPress = true;
}
}
示例12: get
import android.view.View; //导入方法依赖的package包/类
@Override public Boolean get(View view) {
return view.isEnabled();
}
示例13: findTouchTargetViewWithPointerEvents
import android.view.View; //导入方法依赖的package包/类
/**
* Returns the touch target View of the event given, or null if neither the given View nor any of
* its descendants are the touch target.
*/
private static @Nullable View findTouchTargetViewWithPointerEvents(
float eventCoords[], View view) {
PointerEvents pointerEvents = view instanceof ReactPointerEventsView ?
((ReactPointerEventsView) view).getPointerEvents() : PointerEvents.AUTO;
// Views that are disabled should never be the target of pointer events. However, their children
// can be because some views (SwipeRefreshLayout) use enabled but still have children that can
// be valid targets.
if (!view.isEnabled()) {
if (pointerEvents == PointerEvents.AUTO) {
pointerEvents = PointerEvents.BOX_NONE;
} else if (pointerEvents == PointerEvents.BOX_ONLY) {
pointerEvents = PointerEvents.NONE;
}
}
if (pointerEvents == PointerEvents.NONE) {
// This view and its children can't be the target
return null;
} else if (pointerEvents == PointerEvents.BOX_ONLY) {
// This view is the target, its children don't matter
return view;
} else if (pointerEvents == PointerEvents.BOX_NONE) {
// This view can't be the target, but its children might.
if (view instanceof ViewGroup) {
View targetView = findTouchTargetView(eventCoords, (ViewGroup) view);
if (targetView != view) {
return targetView;
}
// PointerEvents.BOX_NONE means that this react element cannot receive pointer events.
// However, there might be virtual children that can receive pointer events, in which case
// we still want to return this View and dispatch a pointer event to the virtual element.
// Note that this currently only applies to Nodes/FlatViewGroup as it's the only class that
// is both a ViewGroup and ReactCompoundView (ReactTextView is a ReactCompoundView but not a
// ViewGroup).
if (view instanceof ReactCompoundView) {
int reactTag = ((ReactCompoundView)view).reactTagForTouch(eventCoords[0], eventCoords[1]);
if (reactTag != view.getId()) {
// make sure we exclude the View itself because of the PointerEvents.BOX_NONE
return view;
}
}
}
return null;
} else if (pointerEvents == PointerEvents.AUTO) {
// Either this view or one of its children is the target
if (view instanceof ReactCompoundViewGroup) {
if (((ReactCompoundViewGroup) view).interceptsTouchEvent(eventCoords[0], eventCoords[1])) {
return view;
}
}
if (view instanceof ViewGroup) {
return findTouchTargetView(eventCoords, (ViewGroup) view);
}
return view;
} else {
throw new JSApplicationIllegalArgumentException(
"Unknown pointer event type: " + pointerEvents.toString());
}
}
示例14: onSingleTapUp
import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (mPressedView != null) {
if (mRecyclerView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) {
// 正在滚动中,不处理
return false;
}
LogUtil.e("onSingleTapUp1");
BaseWrappedViewHolder baseWrappedViewHolder = (BaseWrappedViewHolder) mRecyclerView.getChildViewHolder(mPressedView);
// 头部和底部view不处理
if (baseWrappedViewHolder != null) {
LogUtil.e("baseWrappedViewHolder");
if (isHeaderViewOrFooterView(baseWrappedViewHolder.getItemViewType())) {
LogUtil.e("isHeaderViewOrFooterView");
return false;
}
// 获取设置点击事件的item_view的id;
Set<Integer> ids = baseWrappedViewHolder.getClickableItemIds();
Set<Integer> nestIds = baseWrappedViewHolder.getNestIds();
LogUtil.e("nestIds");
if (ids != null && ids.size() > 0) {
LogUtil.e("ids.size()");
for (Integer id :
ids) {
final View childView = mPressedView.findViewById(id);
if (childView != null&&childView.getVisibility()==View.VISIBLE) {
// 判断点击位置是否在该view上和该view是否可点击
if (isOnRange(e, childView) && childView.isEnabled()) {
// 这里要排除掉嵌套的recyclerView的点击事件
if (nestIds != null && nestIds.contains(id)) {
LogUtil.e("nestIds");
return false;
}
// 设置item的热点
setChildHotSpot(childView, e);
childView.setPressed(true);
// 点击接口
LogUtil.e("触发item_child点击");
onItemChildClick(baseWrappedViewHolder, id, childView, baseWrappedViewHolder.getAdapterPosition() - mBaseWrappedAdapter.getHeaderViewCount());
// 恢复效果,提交,防止堵塞
resetView(childView);
return true;
} else {
LogUtil.e("isEnabled" + childView.isEnabled());
}
}
}
}
// 如果执行到这里,证明没有设置点击事件,所以设置itemView的点击事件
setChildHotSpot(mPressedView, e);
mPressedView.setPressed(true);
onItemClick(baseWrappedViewHolder, baseWrappedViewHolder.itemView.getId(), mPressedView, baseWrappedViewHolder.getAdapterPosition() - mBaseWrappedAdapter.getHeaderViewCount());
resetView(mPressedView);
}
}
return false;
}
示例15: onLongPress
import android.view.View; //导入方法依赖的package包/类
@Override
public void onLongPress(MotionEvent e) {
if (mPressedView != null) {
if (mRecyclerView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) {
return;
}
mPressedView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
BaseWrappedViewHolder baseWrappedViewHolder = (BaseWrappedViewHolder) mRecyclerView.getChildViewHolder(mPressedView);
if (baseWrappedViewHolder != null) {
boolean isLongClickConsume = false;
if (isHeaderViewOrFooterView(baseWrappedViewHolder.getItemViewType())) {
isLongClickConsume = true;
}
Set<Integer> ids = baseWrappedViewHolder.getLongClickableItemIds();
Set<Integer> nestIds = baseWrappedViewHolder.getNestIds();
if (ids != null && ids.size() > 0) {
for (Integer id :
ids) {
final View childView = mPressedView.findViewById(id);
if (childView != null) {
// 判断点击位置是否在该view上和该view是否可点击
if (isOnRange(e, childView) && childView.isEnabled()) {
// 这里要排除掉嵌套的recyclerView的点击事件
if (nestIds != null && nestIds.contains(id)) {
break;
}
// 设置item的热点
setChildHotSpot(childView, e);
childView.setPressed(true);
// 点击接口
onItemChildLongClick(baseWrappedViewHolder, id, childView, baseWrappedViewHolder.getAdapterPosition() - mBaseWrappedAdapter.getHeaderViewCount());
// 恢复效果,提交,防止堵塞
isLongClickConsume = true;
isPressing = true;
break;
}
}
}
}
if (!isLongClickConsume) {
setChildHotSpot(mPressedView, e);
mPressedView.setPressed(true);
onItemLongClick(baseWrappedViewHolder, mPressedView, baseWrappedViewHolder.getAdapterPosition() - mBaseWrappedAdapter.getHeaderViewCount());
isPressing = true;
}
}
}
}