List of usage examples for android.view View getHeight
@ViewDebug.ExportedProperty(category = "layout") public final int getHeight()
From source file:co.com.parsoniisolutions.custombottomsheetbehavior.lib.ScrollAwareFABBehavior.java
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) { /**//from w w w.j a v a2s . c o m * Because we are not moving it, we always return false in this method. */ if (offset == 0) setOffsetValue(parent); if (mBottomSheetBehaviorRef == null) getBottomSheetBehavior(parent); int DyFix = getDyBetweenChildAndDependency(child, dependency); if ((child.getY() + DyFix) < offset) child.hide(); else if ((child.getY() + DyFix) >= offset) { /** * We are calculating every time point in Y where BottomSheet get {@link BottomSheetBehaviorGoogleMapsLike#STATE_COLLAPSED}. * If PeekHeight change dynamically we can reflect the behavior asap. */ if (mBottomSheetBehaviorRef == null || mBottomSheetBehaviorRef.get() == null) getBottomSheetBehavior(parent); int collapsedY = dependency.getHeight() - mBottomSheetBehaviorRef.get().getPeekHeight(); if ((child.getY() + DyFix) > collapsedY) child.hide(); else child.show(); } return false; }
From source file:com.example.carlitos.swipeitemrecycler.view.animation.swipe_item.swipeable.RecyclerViewSwipeManager.java
private void handleActionUpOrCancelWhileSwiping(int action) { int result = RESULT_CANCELED; if (action == MotionEvent.ACTION_UP) { final boolean horizontal = mSwipeHorizontal; final View itemView = mSwipingItem.itemView; final int viewSize = (horizontal) ? itemView.getWidth() : itemView.getHeight(); final float distance = (horizontal) ? (mLastTouchX - mInitialTouchX) : (mLastTouchY - mInitialTouchY); final float absDistance = Math.abs(distance); mVelocityTracker.computeCurrentVelocity(1000, mMaxFlingVelocity); // 1000: pixels per second final float velocity = (horizontal) ? mVelocityTracker.getXVelocity() : mVelocityTracker.getYVelocity(); final float absVelocity = Math.abs(velocity); if ((absDistance > (mTouchSlop * MIN_DISTANCE_TOUCH_SLOP_MUL)) && ((distance * velocity) > 0.0f) && (absVelocity <= mMaxFlingVelocity) && ((absDistance > (viewSize / 2)) || (absVelocity >= mMinFlingVelocity))) { if (horizontal && (distance < 0) && SwipeReactionUtils.canSwipeLeft(mSwipingItemReactionType)) { result = RESULT_SWIPED_LEFT; } else if ((!horizontal) && (distance < 0) && SwipeReactionUtils.canSwipeUp(mSwipingItemReactionType)) { result = RESULT_SWIPED_UP; } else if (horizontal && (distance > 0) && SwipeReactionUtils.canSwipeRight(mSwipingItemReactionType)) { result = RESULT_SWIPED_RIGHT; } else if ((!horizontal) && (distance > 0) && SwipeReactionUtils.canSwipeDown(mSwipingItemReactionType)) { result = RESULT_SWIPED_DOWN; }/* w w w . j a v a2 s . co m*/ } } if (LOCAL_LOGD) { Log.d(TAG, "swping finished --- result = " + result); } finishSwiping(result); }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
/** * Called when intro animation is finished. * <p>//from w w w .j a va2 s .c o m * If a subclass is going to alter the view, should wait until this is * called. */ public void onIntroAnimationFinished() { mIntroAnimationInProgress = false; // Display the selector view. View focusedChild = mListView.getFocusedChild(); if (focusedChild != null) { View actionView = (View) getView().getTag(R.id.action_fragment); int height = focusedChild.getHeight(); View selectorView = actionView.findViewById(R.id.selector); LayoutParams lp = selectorView.getLayoutParams(); lp.height = height; selectorView.setLayoutParams(lp); selectorView.setAlpha(1f); } }
From source file:com.mobile.godot.activity.LauncherActivity.java
private void initializeFullScreenMode() { final View contentView = findViewById(R.id.fullscreen_content_logo); final View loginView = findViewById(R.id.fullscreen_content_login); mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS); mSystemUiHider.setup();//from ww w. jav a2s .c o m mSystemUiHider.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() { int mControlsHeight; int mShortAnimTime; @Override @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public void onVisibilityChange(boolean visible) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { if (mControlsHeight == 0) { mControlsHeight = loginView.getHeight(); } if (mShortAnimTime == 0) { mShortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); } loginView.animate().translationY(visible ? 0 : mControlsHeight).setDuration(mShortAnimTime); } else { loginView.setVisibility(visible ? View.VISIBLE : View.GONE); } if (visible && AUTO_HIDE) { delayedHide(AUTO_HIDE_DELAY_MILLIS); } } }); contentView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (TOGGLE_ON_CLICK) { mSystemUiHider.toggle(); } else { mSystemUiHider.show(); } } }); }
From source file:com.android.deskclock.timer.TimerFullScreenFragment.java
private Animator getRevealAnimator(View source, int revealColor) { final ViewGroup containerView = (ViewGroup) source.getRootView().findViewById(android.R.id.content); final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth()); containerView.offsetDescendantRectToMyCoords(source, sourceBounds); final int centerX = sourceBounds.centerX(); final int centerY = sourceBounds.centerY(); final int xMax = Math.max(centerX, containerView.getWidth() - centerX); final int yMax = Math.max(centerY, containerView.getHeight() - centerY); final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f; final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax); final CircleView revealView = new CircleView(source.getContext()).setCenterX(centerX).setCenterY(centerY) .setFillColor(revealColor);/*from w w w .ja v a2s . co m*/ containerView.addView(revealView); final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius, endRadius); revealAnimator.setInterpolator(PathInterpolatorCompat.create(0.0f, 0.0f, 0.2f, 1.0f)); final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); fadeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { containerView.removeView(revealView); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(TimerFragment.ANIMATION_TIME_MILLIS); animatorSet.playSequentially(revealAnimator, fadeAnimator); return revealAnimator; }
From source file:io.indy.seni.ui.EvolveGridFragment.java
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Genotype genotype = mEvolveContainer.getGenotype((int) id); AstHolder astHolder = genotype.getAstHolder(); try {//from w w w . j a v a2 s . c o m String script = astHolder.scribe(genotype); Intent intent = new Intent(getActivity(), RenderActivity.class); intent.putExtra(GENESIS_SCRIPT, script); // startActivity(intent); if (AppConfig.hasJellyBean()) { // makeThumbnailScaleUpAnimation() looks kind of ugly here as the loading spinner may // show plus the thumbnail image in GridView is cropped. so using // makeScaleUpAnimation() instead. ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()); getActivity().startActivity(intent, options.toBundle()); } else { startActivity(intent); } } catch (Node.ScribeException e) { e.printStackTrace(); } }
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
private void removeOutOfBoundsAnnotations() { RelativeLayout relativeLayout = (RelativeLayout) findViewById( R.id.supersede_feedbacklibrary_annotate_image_layout); if (relativeLayout != null) { List<View> toRemove = new ArrayList<>(); int newBitmapWidth = annotateImageView.getBitmapWidth(); int newBitmapHeight = annotateImageView.getBitmapHeight(); float fraction = 0.5f; for (int i = 0; i < relativeLayout.getChildCount(); ++i) { View child = relativeLayout.getChildAt(i); if (child instanceof StickerAnnotationView || child instanceof TextAnnotationView) { // A fraction the sticker should be visible, if not the sticker will be removed float deleteThresholdX = child.getWidth() * fraction; float deleteThresholdY = child.getHeight() * fraction; float x = child.getX(); float y = child.getY(); boolean xOk = true; boolean yOk = true; if (x < 0) { xOk = Math.abs(x) < deleteThresholdX; } else if (x > 0 && !(x < 0)) { xOk = x + deleteThresholdX < newBitmapWidth; }//w ww. j a v a2 s .c o m if (y < 0) { yOk = Math.abs(y) < deleteThresholdY; } else if (y > 0 && !(y < 0)) { yOk = y + deleteThresholdY < newBitmapHeight; } if (!(xOk && yOk)) { toRemove.add(child); } } } for (int i = 0; i < toRemove.size(); ++i) { relativeLayout.removeView(toRemove.get(i)); } toRemove.clear(); textAnnotationCounter = 1; for (int i = 0; i < relativeLayout.getChildCount(); ++i) { View child = relativeLayout.getChildAt(i); if (child instanceof TextAnnotationView) { String newAnnotationNumber = Integer.toString(textAnnotationCounter); ((TextAnnotationImageView) child).getAnnotationNumberView().setText(newAnnotationNumber); textAnnotationCounter++; } if (textAnnotationCounter > textAnnotationCounterMaximum) { break; } } } }
From source file:com.appolica.interactiveinfowindow.InfoWindowManager.java
private void internalHide(@NonNull final View container, @NonNull final InfoWindow toHideWindow, final boolean animated) { if (animated) { final Animation animation; if (hideAnimation == null) { final int containerWidth = container.getWidth(); final int containerHeight = container.getHeight(); final float pivotX = container.getX() + containerWidth / 2; final float pivotY = container.getY() + containerHeight; animation = new ScaleAnimation(1f, 0f, 1f, 0f, pivotX, pivotY); animation.setDuration(DURATION_WINDOW_ANIMATION); animation.setInterpolator(new DecelerateInterpolator()); } else {/*from w ww. j ava 2 s. co m*/ animation = hideAnimation; } animation.setAnimationListener(new SimpleAnimationListener() { @Override public void onAnimationStart(Animation animation) { toHideWindow.setWindowState(InfoWindow.State.HIDING); propagateShowEvent(toHideWindow, InfoWindow.State.HIDING); } @Override public void onAnimationEnd(Animation animation) { removeWindow(toHideWindow, container); if (container.getId() != InfoWindowManager.this.currentContainer.getId()) { parent.removeView(container); } toHideWindow.setWindowState(InfoWindow.State.HIDDEN); propagateShowEvent(toHideWindow, InfoWindow.State.HIDDEN); } }); this.currentContainer.startAnimation(animation); } else { removeWindow(toHideWindow, container); propagateShowEvent(toHideWindow, InfoWindow.State.HIDDEN); } }
From source file:com.actionbarsherlock.internal.widget.IcsListPopupWindow.java
private int getMaxAvailableHeight(View anchor, int yOffset, boolean ignoreBottomDecorations) { final Rect displayFrame = new Rect(); anchor.getWindowVisibleDisplayFrame(displayFrame); final int[] anchorPos = new int[2]; anchor.getLocationOnScreen(anchorPos); int bottomEdge = displayFrame.bottom; if (ignoreBottomDecorations) { Resources res = anchor.getContext().getResources(); bottomEdge = res.getDisplayMetrics().heightPixels; }//from w w w.j a v a 2 s . c om final int distanceToBottom = bottomEdge - (anchorPos[1] + anchor.getHeight()) - yOffset; final int distanceToTop = anchorPos[1] - displayFrame.top + yOffset; // anchorPos[1] is distance from anchor to top of screen int returnedHeight = Math.max(distanceToBottom, distanceToTop); if (mPopup.getBackground() != null) { mPopup.getBackground().getPadding(mTempRect); returnedHeight -= mTempRect.top + mTempRect.bottom; } return returnedHeight; }
From source file:SwipeListViewTouchListener.java
/** * Perform dismiss action//from ww w . j a v a2 s .c o m * * @param dismissView View * @param dismissPosition Position of list */ protected void performDismiss(final View dismissView, final int dismissPosition, boolean doPendingDismiss) { final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime); if (doPendingDismiss) { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { --dismissAnimationRefCount; if (dismissAnimationRefCount == 0) { removePendingDismisses(originalHeight); } } }); } animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }