List of usage examples for android.view View getTop
@ViewDebug.CapturedViewProperty public final int getTop()
From source file:app.hanks.com.testadvancerecyclerview.MyDraggableSwipeableItemAdapter.java
public static boolean hitTest(View v, int x, int y) { final int tx = (int) (ViewCompat.getTranslationX(v) + 0.5f); final int ty = (int) (ViewCompat.getTranslationY(v) + 0.5f); final int left = v.getLeft() + tx; final int right = v.getRight() + tx; final int top = v.getTop() + ty; final int bottom = v.getBottom() + ty; return (x >= left) && (x <= right) && (y >= top) && (y <= bottom); }
From source file:cn.bingoogolapple.refreshlayout.util.BGARefreshScrollingUtil.java
public static boolean isRecyclerViewToTop(RecyclerView recyclerView) { if (recyclerView != null) { RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager == null) { return true; }/*from w ww . ja v a2 s. co m*/ if (manager.getItemCount() == 0) { return true; } if (manager instanceof LinearLayoutManager) { LinearLayoutManager layoutManager = (LinearLayoutManager) manager; int firstChildTop = 0; if (recyclerView.getChildCount() > 0) { // ?item? View firstVisibleChild = recyclerView.getChildAt(0); if (firstVisibleChild != null && firstVisibleChild.getMeasuredHeight() >= recyclerView.getMeasuredHeight()) { if (android.os.Build.VERSION.SDK_INT < 14) { return !(ViewCompat.canScrollVertically(recyclerView, -1) || recyclerView.getScrollY() > 0); } else { return !ViewCompat.canScrollVertically(recyclerView, -1); } } // RecyclerView???0??top // itemtopMargin?0?? View firstChild = recyclerView.getChildAt(0); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) firstChild .getLayoutParams(); firstChildTop = firstChild.getTop() - layoutParams.topMargin - getRecyclerViewItemTopInset(layoutParams) - recyclerView.getPaddingTop(); } if (layoutManager.findFirstCompletelyVisibleItemPosition() < 1 && firstChildTop == 0) { return true; } } else if (manager instanceof StaggeredGridLayoutManager) { StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager; int[] out = layoutManager.findFirstCompletelyVisibleItemPositions(null); if (out[0] < 1) { return true; } } } return false; }
From source file:cn.zy.ef.refresh.utils.ScrollingUtil.java
public static boolean isRecyclerViewToTop(RecyclerView recyclerView) { if (recyclerView != null) { RecyclerView.LayoutManager manager = recyclerView.getLayoutManager(); if (manager == null) { return true; }//from ww w . j ava2 s.c o m if (manager.getItemCount() == 0) { return true; } if (manager instanceof LinearLayoutManager) { LinearLayoutManager layoutManager = (LinearLayoutManager) manager; int firstChildTop = 0; if (recyclerView.getChildCount() > 0) { // ?item? View firstVisibleChild = recyclerView.getChildAt(0); if (firstVisibleChild != null && firstVisibleChild.getMeasuredHeight() >= recyclerView.getMeasuredHeight()) { if (Build.VERSION.SDK_INT < 14) { return !(ViewCompat.canScrollVertically(recyclerView, -1) || recyclerView.getScrollY() > 0); } else { return !ViewCompat.canScrollVertically(recyclerView, -1); } } // RecyclerView???0??top // itemtopMargin?0?? View firstChild = recyclerView.getChildAt(0); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) firstChild .getLayoutParams(); firstChildTop = firstChild.getTop() - layoutParams.topMargin - getRecyclerViewItemTopInset(layoutParams) - recyclerView.getPaddingTop(); } if (layoutManager.findFirstCompletelyVisibleItemPosition() < 1 && firstChildTop == 0) { return true; } } else if (manager instanceof StaggeredGridLayoutManager) { StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager; int[] out = layoutManager.findFirstCompletelyVisibleItemPositions(null); if (out[0] < 1) { return true; } } } return false; }
From source file:com.breadwallet.tools.animation.BRAnimator.java
public static int getRelativeTop(View myView) { if (myView == null) return 0; if (myView.getParent() == myView.getRootView()) return myView.getTop(); else//from w w w .ja va2 s . com return myView.getTop() + getRelativeTop((View) myView.getParent()); }
From source file:com.cw.litenote.tabs.TabsHost.java
public static void store_listView_vScroll(RecyclerView recyclerView) { int firstVisibleIndex = ((LinearLayoutManager) recyclerView.getLayoutManager()) .findFirstVisibleItemPosition(); View v = recyclerView.getChildAt(0); int firstVisibleIndexTop = (v == null) ? 0 : v.getTop(); System.out.println("TabsHost / _store_listView_vScroll / firstVisibleIndex = " + firstVisibleIndex + " , firstVisibleIndexTop = " + firstVisibleIndexTop); // keep index and top position Pref.setPref_focusView_list_view_first_visible_index(MainAct.mAct, firstVisibleIndex); Pref.setPref_focusView_list_view_first_visible_index_top(MainAct.mAct, firstVisibleIndexTop); }
From source file:com.appassit.common.Utils.java
public static int getScrollY(AbsListView lv) { View c = lv.getChildAt(0); if (c == null) { return 0; }/*ww w .ja va 2s . co m*/ int firstVisiblePosition = lv.getFirstVisiblePosition(); int scrollY = -(c.getTop()); // int scrollY = 0; sListViewItemHeights.put(lv.getFirstVisiblePosition(), c.getHeight()); // if(scrollY>0) // Log.d("QuickReturnUtils", "getScrollY() : -(c.getTop()) - "+ -(c.getTop())); // else // Log.i("QuickReturnUtils", "getScrollY() : -(c.getTop()) - "+ -(c.getTop())); if (scrollY < 0) scrollY = 0; for (int i = 0; i < firstVisiblePosition; ++i) { // Log.d("QuickReturnUtils", "getScrollY() : i - "+i); // Log.d("QuickReturnUtils", "getScrollY() : sListViewItemHeights.get(i) - "+sListViewItemHeights.get(i)); if (sListViewItemHeights.get(i) != null) // (this is a sanity check) scrollY += sListViewItemHeights.get(i); // add all heights of the views that are gone } // Log.d("QuickReturnUtils", "getScrollY() : scrollY - "+scrollY); return scrollY; }
From source file:fiskinfoo.no.sintef.fiskinfoo.Implementation.FiskInfoUtility.java
public static int getRelativeTop(View myView) { if (myView.getId() == android.R.id.content) return myView.getTop(); else/*from w w w. j a v a 2s .c o m*/ return myView.getTop() + getRelativeTop((View) myView.getParent()); }
From source file:com.android.clear.reminder.AnimatorUtils.java
/** * @param target the view to be morphed// w w w . j a v a2s .c o m * @param from the bounds of the {@code target} before animating * @param to the bounds of the {@code target} after animating * @return an animator that morphs the {@code target} between the {@code from} bounds and the * {@code to} bounds. Note that it is the *content* bounds that matter here, so padding * insets contributed by the background are subtracted from the views when computing the * {@code target} bounds. */ public static Animator getBoundsAnimator(View target, View from, View to) { // Fetch the content insets for the views. Content bounds are what matter, not total bounds. final Rect targetInsets = new Rect(); target.getBackground().getPadding(targetInsets); final Rect fromInsets = new Rect(); from.getBackground().getPadding(fromInsets); final Rect toInsets = new Rect(); to.getBackground().getPadding(toInsets); // Before animating, the content bounds of target must match the content bounds of from. final int startLeft = from.getLeft() - fromInsets.left + targetInsets.left; final int startTop = from.getTop() - fromInsets.top + targetInsets.top; final int startRight = from.getRight() - fromInsets.right + targetInsets.right; final int startBottom = from.getBottom() - fromInsets.bottom + targetInsets.bottom; // After animating, the content bounds of target must match the content bounds of to. final int endLeft = to.getLeft() - toInsets.left + targetInsets.left; final int endTop = to.getTop() - toInsets.top + targetInsets.top; final int endRight = to.getRight() - toInsets.right + targetInsets.right; final int endBottom = to.getBottom() - toInsets.bottom + targetInsets.bottom; return getBoundsAnimator(target, startLeft, startTop, startRight, startBottom, endLeft, endTop, endRight, endBottom); }
From source file:com.daycle.daycleapp.custom.swipelistview.itemmanipulation.swipedismiss.SwipeTouchListener.java
private static Rect getChildViewRect(final View parentView, final View childView) { Rect childRect = new Rect(childView.getLeft(), childView.getTop(), childView.getRight(), childView.getBottom());/* w ww . ja v a2 s . c o m*/ if (!parentView.equals(childView)) { View workingChildView = childView; ViewGroup parent; while (!(parent = (ViewGroup) workingChildView.getParent()).equals(parentView)) { childRect.offset(parent.getLeft(), parent.getTop()); workingChildView = parent; } } return childRect; }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;/* www . java 2s . c o m*/ if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }