Java Code Examples for android.view.View#NO_ID

The following examples show how to use android.view.View#NO_ID . 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 File: BarUtils.java    From DevUtils with 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 File: EditSpinner.java    From Edit-Spinner with 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 3
Source File: AccessibilityCheckResult.java    From Accessibility-Test-Framework-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * 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 4
Source File: CheckGroup.java    From sealrtc-android with 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 5
Source File: BeautyBoxGroup.java    From sealrtc-android with 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 6
Source File: ChipGroup.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@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 7
Source File: ToolButtonGroup.java    From kolabnotes-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 8
Source File: MenuItemImpl.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
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
Source File: EditMenuViewHolder.java    From text_converter with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
public final <T extends View> T findViewById(@IdRes int id) {
    if (id == View.NO_ID) {
        return null;
    }
    return mRootView.findViewById(id);
}
 
Example 10
Source File: BrowserAccessibilityManager.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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 11
Source File: ToggleGroup.java    From ToggleButtons with 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 12
Source File: BrowserAccessibilityManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@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 File: ReactAndroidHWInputDeviceHelper.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * 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 14
Source File: FragmentPagerAdapter.java    From SlidingTutorial-Android with MIT License 5 votes vote down vote up
@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 15
Source File: MultiSelectToggleGroup.java    From ToggleButtonGroup with Apache License 2.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    int initialCheckedId = mInitialCheckedId != View.NO_ID ?
            mInitialCheckedId : mSilentInitialCheckedId;
    if (initialCheckedId != View.NO_ID) {
        setCheckedStateForView(initialCheckedId, true);
    }
}
 
Example 16
Source File: BrowserAccessibilityManager.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@CalledByNative
private void handleNavigate() {
    mAccessibilityFocusId = View.NO_ID;
    mUserHasTouchExplored = false;
    mFrameInfoInitialized = false;
}
 
Example 17
Source File: Utility.java    From scene with 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
Source File: RecyclerView.java    From kripton with 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 19
Source File: ExploreByTouchHelper.java    From guideshow with 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
Source File: ExploreByTouchHelper.java    From adt-leanback-support with Apache License 2.0 3 votes vote down vote up
/**
 * 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);
    }
}