Java Code Examples for android.view.View#NO_ID

The following examples show how to use android.view.View#NO_ID . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: DevUtils   File: BarUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 判断 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;
}
 
Example 2
Source Project: sealrtc-android   File: BeautyBoxGroup.java    License: MIT License 6 votes vote down vote up
/** {@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);
    }
}
 
Example 3
@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);
  }
}
 
Example 4
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);
    }
}
 
Example 5
Source Project: sealrtc-android   File: CheckGroup.java    License: MIT License 6 votes vote down vote up
/** {@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);
    }
}
 
Example 6
/**
 * 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();
}
 
Example 7
Source Project: Edit-Spinner   File: EditSpinner.java    License: Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example 8
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;
}
 
Example 9
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    int initialCheckedId = mInitialCheckedId != View.NO_ID ?
            mInitialCheckedId : mSilentInitialCheckedId;
    if (initialCheckedId != View.NO_ID) {
        setCheckedStateForView(initialCheckedId, true);
    }
}
 
Example 10
@Override
public void startUpdate(@NonNull ViewGroup container) {
    if (container.getId() == View.NO_ID) {
        throw new IllegalStateException("ViewPager with adapter " + this
                + " requires a view id");
    }
}
 
Example 11
/**
 * 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;
}
 
Example 12
@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();
}
 
Example 13
Source Project: ToggleButtons   File: ToggleGroup.java    License: MIT License 5 votes vote down vote up
/**
   * {@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);
      }
  }
 
Example 14
/**
 * 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);
    }
}
 
Example 15
@Nullable
public final <T extends View> T findViewById(@IdRes int id) {
    if (id == View.NO_ID) {
        return null;
    }
    return mRootView.findViewById(id);
}
 
Example 16
Source Project: kripton   File: RecyclerView.java    License: Apache License 2.0 4 votes vote down vote up
private void resetFocusInfo() {
    mState.mFocusedItemId = NO_ID;
    mState.mFocusedItemPosition = NO_POSITION;
    mState.mFocusedSubChildId = View.NO_ID;
}
 
Example 17
Source Project: scene   File: Utility.java    License: Apache License 2.0 4 votes vote down vote up
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();
}
 
Example 18
@CalledByNative
private void handleNavigate() {
    mAccessibilityFocusId = View.NO_ID;
    mUserHasTouchExplored = false;
    mFrameInfoInitialized = false;
}
 
Example 19
Source Project: guideshow   File: ExploreByTouchHelper.java    License: MIT License 3 votes vote down vote up
/**
 * 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);
    }
}
 
Example 20
/**
 * 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);
    }
}