android.view.View#NO_ID源码实例Demo

下面列出了android.view.View#NO_ID 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: DevUtils   文件: BarUtils.java
/**
 * 判断 Navigation Bar 是否可见
 * @param window {@link Window}
 * @return {@code true} yes, {@code false} no
 */
public static boolean isNavBarVisible(final Window window) {
    if (window != null) {
        boolean isVisible = false;
        ViewGroup decorView = (ViewGroup) window.getDecorView();
        for (int i = 0, count = decorView.getChildCount(); i < count; i++) {
            final View child = decorView.getChildAt(i);
            final int id = child.getId();
            if (id != View.NO_ID) {
                String resourceEntryName = Resources.getSystem().getResourceEntryName(id);
                if ("navigationBarBackground".equals(resourceEntryName)
                        && child.getVisibility() == View.VISIBLE) {
                    isVisible = true;
                    break;
                }
            }
        }
        if (isVisible) {
            int visibility = decorView.getSystemUiVisibility();
            isVisible = (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
        }
        return isVisible;
    }
    return false;
}
 
源代码2 项目: sealrtc-android   文件: BeautyBoxGroup.java
/** {@inheritDoc} */
@Override
public void onChildViewAdded(View parent, View child) {
    if (parent == BeautyBoxGroup.this && child instanceof BaseBeautyBox) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = View.generateViewId();
            child.setId(id);
        }
        ((BaseBeautyBox) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
源代码3 项目: material-components-android   文件: ChipGroup.java
@Override
public void onCheckedChanged(@NonNull CompoundButton buttonView, boolean isChecked) {
  // prevents from infinite recursion
  if (protectFromCheckedChange) {
    return;
  }

  List<Integer> checkedChipIds = getCheckedChipIds();
  if (checkedChipIds.isEmpty() && selectionRequired) {
    setCheckedStateForView(buttonView.getId(), true);
    setCheckedId(buttonView.getId(), false);
    return;
  }

  int id = buttonView.getId();

  if (isChecked) {
    if (checkedId != View.NO_ID && checkedId != id && singleSelection) {
      setCheckedStateForView(checkedId, false);
    }
    setCheckedId(id);
  } else if (checkedId == id) {
    setCheckedId(View.NO_ID);
  }
}
 
源代码4 项目: kolabnotes-android   文件: ToolButtonGroup.java
public void onChildViewAdded(View parent, View child) {
    if (parent == ToolButtonGroup.this && child instanceof ToolButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = generateViewId();
            child.setId(id);
        }
        ((ToolButton) child).setOnCheckedChangeListener(
                mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
源代码5 项目: sealrtc-android   文件: CheckGroup.java
/** {@inheritDoc} */
@Override
public void onChildViewAdded(View parent, View child) {
    if (parent == CheckGroup.this && child instanceof CheckBox) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = View.generateViewId();
            child.setId(id);
        }
        ((CheckBox) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
/**
 * Returns a String description of the given {@link View}. The default is to return the view's
 * resource entry name.
 *
 * @param view the {@link View} to describe
 * @return a String description of the given {@link View}
 */
public String describeView(@Nullable View view) {
  StringBuilder message = new StringBuilder();
  if ((view != null
      && view.getId() != View.NO_ID
      && view.getResources() != null
      && !ViewAccessibilityUtils.isViewIdGenerated(view.getId()))) {
    message.append("View ");
    try {
      message.append(view.getResources().getResourceEntryName(view.getId()));
    } catch (Exception e) {
      /* In some integrations (seen in Robolectric), the resources may behave inconsistently */
      message.append("with no valid resource name");
    }
  } else {
    message.append("View with no valid resource name");
  }
  return message.toString();
}
 
源代码7 项目: Edit-Spinner   文件: EditSpinner.java
public void showDropDown() {
    if (mPopup.getAnchorView() == null) {
        if (mDropDownAnchorId != View.NO_ID) {
            mPopup.setAnchorView(getRootView().findViewById(mDropDownAnchorId));
        } else {
            mPopup.setAnchorView(this);
        }
    }
    if (!isPopupShowing()) {
        // Make sure the list does not obscure the IME when shown for the first time.
        mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
    }

    requestFocus();
    mPopup.show();
    mPopup.getListView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);

    if (mOnShowListener != null) {
        mOnShowListener.onShow();
    }
}
 
public MenuItem setActionView(View view) {
    mActionView = view;
    mActionProvider = null;
    if (view != null && view.getId() == View.NO_ID && mId > 0) {
        view.setId(mId);
    }
    mMenu.onItemActionRequestChanged(this);
    return this;
}
 
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    int initialCheckedId = mInitialCheckedId != View.NO_ID ?
            mInitialCheckedId : mSilentInitialCheckedId;
    if (initialCheckedId != View.NO_ID) {
        setCheckedStateForView(initialCheckedId, true);
    }
}
 
@Override
public void startUpdate(@NonNull ViewGroup container) {
    if (container.getId() == View.NO_ID) {
        throw new IllegalStateException("ViewPager with adapter " + this
                + " requires a view id");
    }
}
 
/**
 * Called from {@link ReactRootView} when the whole view hierarchy looses focus.
 */
public void clearFocus() {
  if (mLastFocusedViewId != View.NO_ID) {
    dispatchEvent("blur", mLastFocusedViewId);
  }
  mLastFocusedViewId = View.NO_ID;
}
 
源代码12 项目: 365browser   文件: BrowserAccessibilityManager.java
@CalledByNative
private void handleNavigate() {
    if (mNativeObj == 0) return;
    mAccessibilityFocusId = View.NO_ID;
    mAccessibilityFocusRect = null;
    mUserHasTouchExplored = false;
    // Invalidate the host, since its child is now gone.
    sendWindowContentChangedOnView();
}
 
源代码13 项目: ToggleButtons   文件: ToggleGroup.java
/**
   * {@inheritDoc}
   */
  @Override
  protected void onFinishInflate() {
      super.onFinishInflate();

      // checks the appropriate radio button as requested in the XML file
int initialCheck = getExclusiveCheckedId();
      if (initialCheck != View.NO_ID) {
          mProtectFromCheckedChange = true;
          setCheckedStateForView(initialCheck, true);
          mProtectFromCheckedChange = false;
          addCheckedId(initialCheck);
      }
  }
 
/**
 * Called by ContentViewCore to notify us when the frame info is initialized,
 * the first time, since until that point, we can't use mRenderCoordinates to transform
 * web coordinates to screen coordinates.
 */
public void notifyFrameInfoInitialized() {
    if (mFrameInfoInitialized) return;

    mFrameInfoInitialized = true;
    // (Re-) focus focused element, since we weren't able to create an
    // AccessibilityNodeInfo for this element before.
    if (mAccessibilityFocusId != View.NO_ID) {
        sendAccessibilityEvent(mAccessibilityFocusId,
                               AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
    }
}
 
源代码15 项目: text_converter   文件: EditMenuViewHolder.java
@Nullable
public final <T extends View> T findViewById(@IdRes int id) {
    if (id == View.NO_ID) {
        return null;
    }
    return mRootView.findViewById(id);
}
 
源代码16 项目: kripton   文件: RecyclerView.java
private void resetFocusInfo() {
    mState.mFocusedItemId = NO_ID;
    mState.mFocusedItemPosition = NO_POSITION;
    mState.mFocusedSubChildId = View.NO_ID;
}
 
源代码17 项目: scene   文件: Utility.java
private static String getViewMessage(Scene scene, int marginOffset) {
    String tag = null;
    boolean isHidden = false;
    String status = null;
    if (scene.getParentScene() instanceof GroupScene) {
        GroupScene groupScene = (GroupScene) scene.getParentScene();
        tag = groupScene.findTagByScene(scene);
        isHidden = !groupScene.isShow(scene);
    } else if (scene.getParentScene() instanceof NavigationScene) {
        Lifecycle.State state = scene.getLifecycle().getCurrentState();
        if (state == Lifecycle.State.RESUMED) {
            status = "resumed";
        } else if (state == Lifecycle.State.STARTED) {
            status = "paused";
        } else if (state == Lifecycle.State.CREATED) {
            status = "stopped";
        }
    }

    String repeated = new String(new char[marginOffset]).replace("\0", "    ");
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(repeated + "[" + scene.getClass().getSimpleName() + "] ");

    if (tag != null) {
        stringBuilder.append("tag: " + tag + " ");
        if (isHidden) {
            stringBuilder.append("hidden ");
        }
    }

    if (status != null) {
        stringBuilder.append("status: " + status + " ");
    }

    String resourceId = null;
    if (scene.getApplicationContext() != null && scene.getView() != null && scene.getView().getId() != View.NO_ID) {
        resourceId = getIdName(scene.requireApplicationContext(), scene.getView().getId());
    }
    if (resourceId != null) {
        stringBuilder.append("viewId: " + resourceId + " ");
    }
    stringBuilder.append("\n");
    return stringBuilder.toString();
}
 
@CalledByNative
private void handleNavigate() {
    mAccessibilityFocusId = View.NO_ID;
    mUserHasTouchExplored = false;
    mFrameInfoInitialized = false;
}
 
源代码19 项目: guideshow   文件: ExploreByTouchHelper.java
/**
 * Constructs and returns an {@link AccessibilityNodeInfoCompat} for the
 * specified virtual view id, which includes the host view
 * ({@link View#NO_ID}).
 *
 * @param virtualViewId The virtual view id for the item for which to
 *            construct a node.
 * @return An {@link AccessibilityNodeInfoCompat} populated with information
 *         about the specified item.
 */
private AccessibilityNodeInfoCompat createNode(int virtualViewId) {
    switch (virtualViewId) {
        case View.NO_ID:
            return createNodeForHost();
        default:
            return createNodeForChild(virtualViewId);
    }
}
 
/**
 * Constructs and returns an {@link AccessibilityEvent} for the specified
 * virtual view id, which includes the host view ({@link View#NO_ID}).
 *
 * @param virtualViewId The virtual view id for the item for which to
 *            construct an event.
 * @param eventType The type of event to construct.
 * @return An {@link AccessibilityEvent} populated with information about
 *         the specified item.
 */
private AccessibilityEvent createEvent(int virtualViewId, int eventType) {
    switch (virtualViewId) {
        case View.NO_ID:
            return createEventForHost(eventType);
        default:
            return createEventForChild(virtualViewId, eventType);
    }
}
 
 方法所在类
 同类方法