Java Code Examples for android.widget.FrameLayout#getLeft()

The following examples show how to use android.widget.FrameLayout#getLeft() . 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: PileLayout.java    From timecat with Apache License 2.0 6 votes vote down vote up
private void onRelease(float eventX, float velocityX) {
    animatingView = (FrameLayout) getChildAt(3);
    animateValue = animatingView.getLeft();
    int tag = Integer.parseInt(animatingView.getTag().toString());

    // 计算目标位置
    int destX = originX.get(3);
    if (velocityX > VELOCITY_THRESHOLD || (animatingView.getLeft() > originX.get(3) + scrollDistanceMax / 2 && velocityX > -VELOCITY_THRESHOLD)) {
        destX = originX.get(4);
        tag--;
    }
    if (tag < 0 || tag >= adapter.getItemCount()) {
        return;
    }

    if (Math.abs(animatingView.getLeft() - destX) < mTouchSlop && Math.abs(eventX - downX) < mTouchSlop) {
        return;
    }

    adapter.displaying(tag);
    animator = ObjectAnimator.ofFloat(this, "animateValue", animatingView.getLeft(), destX);
    animator.setInterpolator(interpolator);
    animator.setDuration(360).start();
}
 
Example 2
Source File: CardViewLayout.java    From YCCardView with Apache License 2.0 6 votes vote down vote up
private void onRelease(float eventX, int velocityX) {
    animatingView = (FrameLayout) getChildAt(3);
    animateValue = animatingView.getLeft();
    int tag = Integer.parseInt(animatingView.getTag().toString());

    // 计算目标位置
    int destX = originX.get(3);
    boolean isOrigin = animatingView.getLeft() > originX.get(3) + scrollDistanceMax / 2;
    if (velocityX > VELOCITY_THRESHOLD || (isOrigin && velocityX > -VELOCITY_THRESHOLD)) {
        destX = originX.get(4);
        tag--;
    }
    if (tag < 0 || tag >= adapter.getItemCount()) {
        return;
    }

    if (Math.abs(animatingView.getLeft() - destX) < mTouchSlop && Math.abs(eventX - downX) < mTouchSlop) {
        return;
    }

    adapter.displaying(tag);
    animator = ObjectAnimator.ofFloat(this, "animateValue", animatingView.getLeft(), destX);
    animator.setInterpolator(interpolator);
    animator.setDuration(360).start();
}
 
Example 3
Source File: SearchBox.java    From NHentai-android with GNU General Public License v3.0 4 votes vote down vote up
/***
 * Hide the searchbox using the circle animation. Can be called regardless of result list length
 * @param activity Activity
 */
public void hideCircularly(Activity activity){
	Display display = activity.getWindowManager().getDefaultDisplay();
	Point size = new Point();
	final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView()
			.findViewById(android.R.id.content);
	RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root);
	display.getSize(size);
	Resources r = getResources();
	float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,
			r.getDisplayMetrics());
	int cx = layout.getLeft() + layout.getRight();
	int cy = layout.getTop();
	int finalRadius = (int) Math.max(layout.getWidth()*1.5, px);

	SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
			root, cx, cy, 0, finalRadius);
	animator.setInterpolator(new ReverseInterpolator());
	animator.setDuration(250);
	animator.start();
	animator.addListener(new SupportAnimator.AnimatorListener(){

		@Override
		public void onAnimationStart() {
			
		}

		@Override
		public void onAnimationEnd() {
			setVisibility(View.GONE);
		}

		@Override
		public void onAnimationCancel() {
			
		}

		@Override
		public void onAnimationRepeat() {
			
		}
		
	});
}
 
Example 4
Source File: SearchBox.java    From NHentai-android with GNU General Public License v3.0 4 votes vote down vote up
private void revealFrom(float x, float y, Activity a, SearchBox s) {
	FrameLayout layout = (FrameLayout) a.getWindow().getDecorView()
			.findViewById(android.R.id.content);
	RelativeLayout root = (RelativeLayout) s.findViewById(R.id.search_root);
	Resources r = getResources();
	float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,
			r.getDisplayMetrics());
	int cx = layout.getLeft() + layout.getRight();
	int cy = layout.getTop();

	int finalRadius = (int) Math.max(layout.getWidth(), px);

	SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
			root, cx, cy, 0, finalRadius);
	animator.setInterpolator(new AccelerateDecelerateInterpolator());
	animator.setDuration(500);
	animator.addListener(new SupportAnimator.AnimatorListener(){

		@Override
		public void onAnimationCancel() {
			
		}

		@Override
		public void onAnimationEnd() {
			toggleSearch();				
		}

		@Override
		public void onAnimationRepeat() {
			
		}

		@Override
		public void onAnimationStart() {
			
		}
		
	});
	animator.start();
}
 
Example 5
Source File: SearchBox.java    From ExpressHelper with GNU General Public License v3.0 4 votes vote down vote up
/***
 * Hide the searchbox using the circle animation. Can be called regardless of result list length
 * @param activity
 */
public void hideCircularly(Activity activity){
	Display display = activity.getWindowManager().getDefaultDisplay();
	Point size = new Point();
	final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView()
			.findViewById(android.R.id.content);
	RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root);
	display.getSize(size);
	Resources r = getResources();
	float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,
			r.getDisplayMetrics());
	int cx = layout.getLeft() + layout.getRight();
	int cy = layout.getTop();
	int finalRadius = (int) Math.max(layout.getWidth()*1.5, px);

	SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
			root, cx, cy, 0, finalRadius);
	animator.setInterpolator(new ReverseInterpolator());
	animator.setDuration(500);
	animator.start();
	animator.addListener(new SupportAnimator.AnimatorListener(){

		@Override
		public void onAnimationStart() {
			
		}

		@Override
		public void onAnimationEnd() {
			setVisibility(View.GONE);
		}

		@Override
		public void onAnimationCancel() {
			
		}

		@Override
		public void onAnimationRepeat() {
			
		}
		
	});
}
 
Example 6
Source File: SearchBox.java    From ExpressHelper with GNU General Public License v3.0 4 votes vote down vote up
private void revealFrom(float x, float y, Activity a, SearchBox s) {
	Display display = a.getWindowManager().getDefaultDisplay();
	Point size = new Point();
	FrameLayout layout = (FrameLayout) a.getWindow().getDecorView()
			.findViewById(android.R.id.content);
	RelativeLayout root = (RelativeLayout) s.findViewById(R.id.search_root);
	display.getSize(size);
	Resources r = getResources();
	float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,
			r.getDisplayMetrics());
	int cx = layout.getLeft() + layout.getRight();
	int cy = layout.getTop();

	int finalRadius = (int) Math.max(layout.getWidth(), px);

	SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
			root, cx, cy, 0, finalRadius);
	animator.setInterpolator(new AccelerateDecelerateInterpolator());
	animator.setDuration(500);
	animator.addListener(new SupportAnimator.AnimatorListener(){

		@Override
		public void onAnimationCancel() {
			
		}

		@Override
		public void onAnimationEnd() {
			toggleSearch();				
		}

		@Override
		public void onAnimationRepeat() {
			
		}

		@Override
		public void onAnimationStart() {
			
		}
		
	});
	animator.start();
}