Java Code Examples for android.view.animation.Animation#setStartTime()

The following examples show how to use android.view.animation.Animation#setStartTime() . 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: SimpleDisplayer.java    From volley with Apache License 2.0 6 votes vote down vote up
private void animationDisplay(View imageView,Drawable bitmapDrawable,Animation animation){
    if (bitmapDrawable == null) {
        return;
    }
    if (animation != null) {
        animation.setStartTime(AnimationUtils.currentAnimationTimeMillis());        
    }
    if(imageView instanceof ImageView){
        ((ImageView)imageView).setImageDrawable(bitmapDrawable);
    }else{
        imageView.setBackgroundDrawable(bitmapDrawable);
    }
    if (animation != null) {
        imageView.startAnimation(animation);
    }
}
 
Example 2
Source File: ViewUtil.java    From Tok-Android with GNU General Public License v3.0 5 votes vote down vote up
public static void animateIn(final @NonNull View view, final @NonNull Animation animation) {
    if (view.getVisibility() == View.VISIBLE) {
        return;
    }

    view.clearAnimation();
    animation.reset();
    animation.setStartTime(0);
    view.setVisibility(View.VISIBLE);
    view.startAnimation(animation);
}
 
Example 3
Source File: ViewUtil.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public static void animateIn(final @NonNull View view, final @NonNull Animation animation) {
  if (view.getVisibility() == View.VISIBLE) return;

  view.clearAnimation();
  animation.reset();
  animation.setStartTime(0);
  view.setVisibility(View.VISIBLE);
  view.startAnimation(animation);
}
 
Example 4
Source File: ViewUtil.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
public static void animateIn(final @NonNull View view, final @NonNull Animation animation) {
  if (view.getVisibility() == View.VISIBLE) return;

  view.clearAnimation();
  animation.reset();
  animation.setStartTime(0);
  view.setVisibility(View.VISIBLE);
  view.startAnimation(animation);
}
 
Example 5
Source File: ViewUtil.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
public static void animateIn(final @NonNull View view, final @NonNull Animation animation) {
  if (view.getVisibility() == View.VISIBLE) return;

  view.clearAnimation();
  animation.reset();
  animation.setStartTime(0);
  view.setVisibility(View.VISIBLE);
  view.startAnimation(animation);
}
 
Example 6
Source File: SimpleDisplayer.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
private void animationDisplay(View imageView,Bitmap bitmap,Animation animation){
	animation.setStartTime(AnimationUtils.currentAnimationTimeMillis());		
       if(imageView instanceof ImageView){
		((ImageView)imageView).setImageBitmap(bitmap);
	}else{
		imageView.setBackgroundDrawable(new BitmapDrawable(bitmap));
	}
       imageView.startAnimation(animation);
}
 
Example 7
Source File: BaseZoomableImageView.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
protected void center(boolean vertical, boolean horizontal, boolean animate) {
	if (mBitmap == null)
		return;

	Matrix m = getImageViewMatrix();

	float [] topLeft  = new float[] { 0, 0 };
	float [] botRight = new float[] { mBitmap.getWidth(), mBitmap.getHeight() };

	translatePoint(m, topLeft);
	translatePoint(m, botRight);

	float height = botRight[1] - topLeft[1];
	float width  = botRight[0] - topLeft[0];

	float deltaX = 0, deltaY = 0;

	if (vertical) {
		int viewHeight = getHeight();
		if (height < viewHeight) {
			deltaY = (viewHeight - height)/2 - topLeft[1];
		} else if (topLeft[1] > 0) {
			deltaY = -topLeft[1];
		} else if (botRight[1] < viewHeight) {
			deltaY = getHeight() - botRight[1];
		}
	}

	if (horizontal) {
		int viewWidth = getWidth();
		if (width < viewWidth) {
			deltaX = (viewWidth - width)/2 - topLeft[0];
		} else if (topLeft[0] > 0) {
			deltaX = -topLeft[0];
		} else if (botRight[0] < viewWidth) {
			deltaX = viewWidth - botRight[0];
		}
	}

	postTranslate(deltaX, deltaY);
	if (animate) {
		Animation a = new TranslateAnimation(-deltaX, 0, -deltaY, 0);
		a.setStartTime(SystemClock.elapsedRealtime());
		a.setDuration(250);
		setAnimation(a);
	}
	setImageMatrix(getImageViewMatrix());
}
 
Example 8
Source File: BaseZoomableImageView.java    From NIM_Android_UIKit with MIT License 4 votes vote down vote up
protected void center(boolean vertical, boolean horizontal, boolean animate) {
    if (mBitmap == null)
        return;

    Matrix m = getImageViewMatrix();

    float[] topLeft = new float[]{0, 0};
    float[] botRight = new float[]{mBitmap.getWidth(), mBitmap.getHeight()};

    translatePoint(m, topLeft);
    translatePoint(m, botRight);

    float height = botRight[1] - topLeft[1];
    float width = botRight[0] - topLeft[0];

    float deltaX = 0, deltaY = 0;

    if (vertical) {
        int viewHeight = getHeight();
        if (height < viewHeight) {
            deltaY = (viewHeight - height) / 2 - topLeft[1];
        } else if (topLeft[1] > 0) {
            deltaY = -topLeft[1];
        } else if (botRight[1] < viewHeight) {
            deltaY = getHeight() - botRight[1];
        }
    }

    if (horizontal) {
        int viewWidth = getWidth();
        if (width < viewWidth) {
            deltaX = (viewWidth - width) / 2 - topLeft[0];
        } else if (topLeft[0] > 0) {
            deltaX = -topLeft[0];
        } else if (botRight[0] < viewWidth) {
            deltaX = viewWidth - botRight[0];
        }
    }

    postTranslate(deltaX, deltaY);
    if (animate) {
        Animation a = new TranslateAnimation(-deltaX, 0, -deltaY, 0);
        a.setStartTime(SystemClock.elapsedRealtime());
        a.setDuration(250);
        setAnimation(a);
    }
    setImageMatrix(getImageViewMatrix());
}
 
Example 9
Source File: CropImageView.java    From NIM_Android_UIKit with MIT License 4 votes vote down vote up
@Override
protected void center(boolean vertical, boolean horizontal, boolean animate) {
    if (mBitmap == null)
        return;
    if (selection == null) {
        invalidate();
        return;
    }

    Matrix m = getImageViewMatrix();

    float[] topLeft = new float[]{0, 0};
    float[] botRight = new float[]{mBitmap.getWidth(), mBitmap.getHeight()};

    translatePoint(m, topLeft);
    translatePoint(m, botRight);

    float deltaX = 0, deltaY = 0;

    if (vertical) {
        if (topLeft[1] > selection.bottom) {
            deltaY = selection.bottom - topLeft[1];
        } else if (botRight[1] < selection.top) {
            deltaY = selection.top - botRight[1];
        }
    }

    if (horizontal) {
        if (topLeft[0] > selection.right) {
            deltaX = selection.right - topLeft[0];
        } else if (botRight[0] < selection.left) {
            deltaX = selection.left - botRight[0];
        }
    }

    postTranslate(deltaX, deltaY);
    if (animate) {
        Animation a = new TranslateAnimation(-deltaX, 0, -deltaY, 0);
        a.setStartTime(SystemClock.elapsedRealtime());
        a.setDuration(250);
        setAnimation(a);
    }
    setImageMatrix(getImageViewMatrix());
}