android.view.View#isShown ( )源码实例Demo

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

源代码1 项目: KlyphMessenger   文件: PullToRefreshAttacher.java
final boolean isViewBeingDragged(View view, MotionEvent event) {
    if (view.isShown() && mRefreshableViews.containsKey(view)) {
        // First we need to set the rect to the view's screen co-ordinates
        view.getLocationOnScreen(mViewLocationResult);
        final int viewLeft = mViewLocationResult[0], viewTop = mViewLocationResult[1];
        mRect.set(viewLeft, viewTop, viewLeft + view.getWidth(), viewTop + view.getHeight());

        if (DEBUG) Log.d(LOG_TAG, "isViewBeingDragged. View Rect: " + mRect.toString());

        final int rawX = (int) event.getRawX(), rawY = (int) event.getRawY();
        if (mRect.contains(rawX, rawY)) {
            // The Touch Event is within the View's display Rect
            ViewDelegate delegate = mRefreshableViews.get(view);
            if (delegate != null) {
                // Now call the delegate, converting the X/Y into the View's co-ordinate system
                return delegate.isReadyForPull(view, rawX - mRect.left, rawY - mRect.top);
            }
        }
    }
    return false;
}
 
public int getVisiblePercent(View v) {

        Rect scrollBounds = new Rect();
        scrollView.getHitRect(scrollBounds);
        if (v.getLocalVisibleRect(scrollBounds)) {
            // Any portion of the imageView, even a single pixel, is within the visible window
        } else {
            // NONE of the imageView is within the visible window
            return -1;
        }

        if (v.isShown()) {
            Rect r = new Rect();
            v.getGlobalVisibleRect(r);
            double sVisible = r.width() * r.height();
            double sTotal = v.getWidth() * v.getHeight();

            MyLg.e(TAG, "sVisible " + sVisible + " sTotal" + sTotal);

            return (int) (100 * sVisible / sTotal) - 20;
        } else {
            return -1;
        }
    }
 
public int getVisiblePercent(View v) {

        Rect scrollBounds = new Rect();
        scrollView.getHitRect(scrollBounds);
        if (v.getLocalVisibleRect(scrollBounds)) {
            // Any portion of the imageView, even a single pixel, is within the visible window
        } else {
            // NONE of the imageView is within the visible window
            return -1;
        }

        if (v.isShown()) {
            Rect r = new Rect();
            v.getGlobalVisibleRect(r);
            double sVisible = r.width() * r.height();
            double sTotal = v.getWidth() * v.getHeight();

            MyLg.e(TAG, "sVisible " + sVisible + " sTotal" + sTotal);

            return (int) (100 * sVisible / sTotal) - 20;
        } else {
            return -1;
        }
    }
 
源代码4 项目: demo4Fish   文件: SimpleClickListener.java
public boolean inRangeOfView(View view, MotionEvent ev) {
    int[] location = new int[2];
    if (view==null||!view.isShown()){
        return false;
    }
    view.getLocationOnScreen(location);
    int x = location[0];
    int y = location[1];
    if (ev.getRawX() < x
            || ev.getRawX() > (x + view.getWidth())
            || ev.getRawY() < y
            || ev.getRawY() > (y + view.getHeight())) {
        return false;
    }
    return true;
}
 
源代码5 项目: TableView   文件: TableViewLayoutChangeListener.java
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int
        oldTop, int oldRight, int oldBottom) {

    if (v.isShown() && (right - left) != (oldRight - oldLeft)) {

        // Control who need the remeasure
        if (mColumnHeaderRecyclerView.getWidth() > mCellRecyclerView.getWidth()) {
            // Remeasure all nested CellRow recyclerViews
            mCellLayoutManager.remeasureAllChild();

        } else if (mCellRecyclerView.getWidth() > mColumnHeaderRecyclerView.getWidth()) {

            // It seems Column Header is needed.
            mColumnHeaderRecyclerView.getLayoutParams().width = WRAP_CONTENT;
            mColumnHeaderRecyclerView.requestLayout();
        }
    }
}
 
源代码6 项目: JD-Test   文件: SimpleClickListener.java
public boolean inRangeOfView(View view, MotionEvent ev) {
    int[] location = new int[2];
    if (view==null||!view.isShown()){
        return false;
    }
    view.getLocationOnScreen(location);
    int x = location[0];
    int y = location[1];
    if (ev.getRawX() < x
            || ev.getRawX() > (x + view.getWidth())
            || ev.getRawY() < y
            || ev.getRawY() > (y + view.getHeight())) {
        return false;
    }
    return true;
}
 
源代码7 项目: Indic-Keyboard   文件: LatinIME.java
@Override
public void onComputeInsets(final InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);
    // This method may be called before {@link #setInputView(View)}.
    if (mInputView == null) {
        return;
    }
    final SettingsValues settingsValues = mSettings.getCurrent();
    final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
    if (visibleKeyboardView == null || !hasSuggestionStripView()) {
        return;
    }
    final int inputHeight = mInputView.getHeight();
    if (isImeSuppressedByHardwareKeyboard() && !visibleKeyboardView.isShown()) {
        // If there is a hardware keyboard and a visible software keyboard view has been hidden,
        // no visual element will be shown on the screen.
        outInsets.contentTopInsets = inputHeight;
        outInsets.visibleTopInsets = inputHeight;
        mInsetsUpdater.setInsets(outInsets);
        return;
    }
    final int suggestionsHeight = (!mKeyboardSwitcher.isShowingEmojiPalettes()
            && mSuggestionStripView.getVisibility() == View.VISIBLE)
            ? mSuggestionStripView.getHeight() : 0;
    final int visibleTopY = inputHeight - visibleKeyboardView.getHeight() - suggestionsHeight;
    mSuggestionStripView.setMoreSuggestionsHeight(visibleTopY);
    // Need to set expanded touchable region only if a keyboard view is being shown.
    if (visibleKeyboardView.isShown()) {
        final int touchLeft = 0;
        final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
        final int touchRight = visibleKeyboardView.getWidth();
        final int touchBottom = inputHeight;
        outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
        outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
    }
    outInsets.contentTopInsets = visibleTopY;
    outInsets.visibleTopInsets = visibleTopY;
    mInsetsUpdater.setInsets(outInsets);
}
 
源代码8 项目: SlickForm   文件: SimpleTooltipUtils.java
public static boolean isShown(View mContentLayout) {
    if (!mContentLayout.isShown())
        return false;
    ViewParent parent = mContentLayout.getParent();
    do {
        if (parent instanceof View && !((View) parent).isShown())
            return false;
        else
            System.out.println(parent.getClass());

    } while ((parent = parent.getParent()) != null);
    return true;
}
 
源代码9 项目: zen4android   文件: MenuPopupHelper.java
@Override
public void onGlobalLayout() {
    if (isShowing()) {
        final View anchor = mAnchorView;
        if (anchor == null || !anchor.isShown()) {
            dismiss();
        } else if (isShowing()) {
            // Recompute window size and position
            mPopup.show();
        }
    }
}
 
源代码10 项目: LokiBoard-Android-Keylogger   文件: LatinIME.java
@Override
public void onComputeInsets(final InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);
    // This method may be called before {@link #setInputView(View)}.
    if (mInputView == null) {
        return;
    }
    final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
    if (visibleKeyboardView == null) {
        return;
    }
    final int inputHeight = mInputView.getHeight();
    if (isImeSuppressedByHardwareKeyboard() && !visibleKeyboardView.isShown()) {
        // If there is a hardware keyboard and a visible software keyboard view has been hidden,
        // no visual element will be shown on the screen.
        outInsets.contentTopInsets = inputHeight;
        outInsets.visibleTopInsets = inputHeight;
        mInsetsUpdater.setInsets(outInsets);
        return;
    }
    final int visibleTopY = inputHeight - visibleKeyboardView.getHeight();
    // Need to set expanded touchable region only if a keyboard view is being shown.
    if (visibleKeyboardView.isShown()) {
        final int touchLeft = 0;
        final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
        final int touchRight = visibleKeyboardView.getWidth();
        final int touchBottom = inputHeight
                // Extend touchable region below the keyboard.
                + EXTENDED_TOUCHABLE_REGION_HEIGHT;
        outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
        outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
    }
    outInsets.contentTopInsets = visibleTopY;
    outInsets.visibleTopInsets = visibleTopY;
    mInsetsUpdater.setInsets(outInsets);
}
 
源代码11 项目: mytracks   文件: EndToEndTestUtils.java
/**
 * Resume recoding track.
 */
public static void resumeRecording() {
  View startButton = SOLO.getCurrentActivity().findViewById(R.id.track_controller_record);
  if (startButton != null && startButton.isShown()) {
    SOLO.clickOnView(startButton);
  }
  instrumentation.waitForIdleSync();
}
 
源代码12 项目: Falcon   文件: Falcon.java
private static List<ViewRootData> viewRootData(Object[] roots, LayoutParams[] params) {
  List<ViewRootData> rootViews = new ArrayList<>();
  for (int i = 0; i < roots.length; i++) {
    Object root = roots[i];

    View rootView = (View) getFieldValue("mView", root);

    // fixes https://github.com/jraska/Falcon/issues/10
    if (rootView == null) {
      Log.e(TAG, "null View stored as root in Global window manager, skipping");
      continue;
    }

    if(!rootView.isShown()){
      continue;
    }

    int[] location = new int[2];
    rootView.getLocationOnScreen(location);

    int left = location[0];
    int top = location[1];
    Rect area = new Rect(left, top, left + rootView.getWidth(), top + rootView.getHeight());

    rootViews.add(new ViewRootData(rootView, area, params[i]));
  }

  return rootViews;
}
 
源代码13 项目: 365browser   文件: LocationBarTablet.java
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mTargets == null) return true;

    View selectedTarget = null;
    float selectedDistance = 0;
    // newX and newY are in the coordinates of the selectedTarget.
    float newX = 0;
    float newY = 0;
    for (View target : mTargets) {
        if (!target.isShown()) continue;

        mCachedTargetBounds.set(0, 0, target.getWidth(), target.getHeight());
        offsetDescendantRectToMyCoords(target, mCachedTargetBounds);
        float x = event.getX();
        float y = event.getY();
        float dx = distanceToRange(
                mCachedTargetBounds.left, mCachedTargetBounds.right, x);
        float dy = distanceToRange(
                mCachedTargetBounds.top, mCachedTargetBounds.bottom, y);
        float distance = Math.abs(dx) + Math.abs(dy);
        if (selectedTarget == null || distance < selectedDistance) {
            selectedTarget = target;
            selectedDistance = distance;
            newX = x + dx;
            newY = y + dy;
        }
    }

    if (selectedTarget == null) return false;

    event.setLocation(newX, newY);
    return selectedTarget.onTouchEvent(event);
}
 
源代码14 项目: ALLGO   文件: PullToRefreshLayout.java
private View getChildForTouchEvent(MotionEvent event) {
    final float x = event.getX(), y = event.getY();
    View child;
    for (int z = getChildCount() - 1;  z >= 0 ; z--) {
        child = getChildAt(z);
        if (child.isShown() && x >= child.getLeft() && x <= child.getRight()
                && y >= child.getTop() && y <= child.getBottom()) {
            if (DEBUG) Log.d(LOG_TAG, "Got Child for Touch Event: " + child);
            return child;
        }
    }
    return null;
}
 
源代码15 项目: android-apps   文件: MenuPopupHelper.java
@Override
public void onGlobalLayout() {
    if (isShowing()) {
        final View anchor = mAnchorView;
        if (anchor == null || !anchor.isShown()) {
            dismiss();
        } else if (isShowing()) {
            // Recompute window size and position
            mPopup.show();
        }
    }
}
 
源代码16 项目: delion   文件: LocationBarTablet.java
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mTargets == null) return true;

    View selectedTarget = null;
    float selectedDistance = 0;
    // newX and newY are in the coordinates of the selectedTarget.
    float newX = 0;
    float newY = 0;
    for (View target : mTargets) {
        if (!target.isShown()) continue;

        mCachedTargetBounds.set(0, 0, target.getWidth(), target.getHeight());
        offsetDescendantRectToMyCoords(target, mCachedTargetBounds);
        float x = event.getX();
        float y = event.getY();
        float dx = distanceToRange(
                mCachedTargetBounds.left, mCachedTargetBounds.right, x);
        float dy = distanceToRange(
                mCachedTargetBounds.top, mCachedTargetBounds.bottom, y);
        float distance = Math.abs(dx) + Math.abs(dy);
        if (selectedTarget == null || distance < selectedDistance) {
            selectedTarget = target;
            selectedDistance = distance;
            newX = x + dx;
            newY = y + dy;
        }
    }

    if (selectedTarget == null) return false;

    event.setLocation(newX, newY);
    return selectedTarget.onTouchEvent(event);
}
 
源代码17 项目: mytracks   文件: EndToEndTestUtils.java
/**
 * Starts recoding track.
 */
public static void startRecording() {
  View startButton = SOLO.getCurrentActivity().findViewById(R.id.track_controller_record);
  if (startButton != null && startButton.isShown()) {
    SOLO.clickOnView(startButton);
  }
  instrumentation.waitForIdleSync();
}
 
源代码18 项目: timecat   文件: XposedUniversalCopyHandler.java
private ArrayList<CopyNode> traverseNode(View nodeInfo, int screenWidth, int scerrnHeight) {
    ArrayList nodeList = new ArrayList();
    if(nodeInfo != null ) {
        if (!nodeInfo.isShown()){
            return nodeList;
        }
        if (nodeInfo instanceof ViewGroup){
            ViewGroup viewGroup = (ViewGroup) nodeInfo;
            for(int var4 = 0; var4 < viewGroup.getChildCount(); ++var4) {
                nodeList.addAll(this.traverseNode(viewGroup.getChildAt(var4), screenWidth, scerrnHeight));
            }
        }
        if(nodeInfo.getClass().getName() != null && nodeInfo.getClass().getName().equals("android.webkit.WebView")) {
            return nodeList;
        } else {
            String content = null;
            String description = content;
            if(nodeInfo.getContentDescription() != null) {
                description = content;
                if(!"".equals(nodeInfo.getContentDescription())) {
                    description = nodeInfo.getContentDescription().toString();
                }
            }

            content = description;
            String text=getTextInFilters(nodeInfo,mFilters);
            if(text != null) {
                content = description;
                if(!"".equals(text)) {
                    content = text.toString();
                }
            }

            if(content != null) {
                Rect var8 = new Rect();
                nodeInfo.getGlobalVisibleRect(var8);
                if(checkBound(var8, screenWidth, scerrnHeight)) {
                    nodeList.add(new CopyNode(var8, content));
                }
            }

            return nodeList;
        }
    } else {
        return nodeList;
    }
}
 
源代码19 项目: Tok-Android   文件: BoardManager.java
/**
 * hide file selector layout
 * No.2-->toggle button show keyboard
 * No.3-->EditText visible
 * No.4-->record button invisible
 * No.5-->send button visible
 * No.6-->file selector layout show
 * No.7-->keyboard is visible by parameter
 *
 * @param layout the view need invisible
 * @param showSoftInput is show keyboard
 */
private void hideExtendLayout(View layout, boolean showSoftInput) {
    if (layout != null && layout.isShown()) {
        layout.setVisibility(View.GONE);
        if (showSoftInput) {
            showSoftInput();
            mInputRecordBtSw.showRecord();
        } else {
            mInputRecordBtSw.showKeyboard();
        }
    }
}
 
@Override
public boolean isIdleNow() {

    View view = activity.findViewById(R.id.pb_loading);

    boolean loadingHide = !view.isShown();

    if (loadingHide)
        callback.onTransitionToIdle();

    return loadingHide;
}
 
 方法所在类
 同类方法