Java Code Examples for android.widget.ImageView#postDelayed()

The following examples show how to use android.widget.ImageView#postDelayed() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
private void animateImage(final ImageView imageView) {
    imageView.postDelayed(new Runnable() {
        @Override
        public void run() {
            // Play a subtle animation
            final long duration = 300;

            final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(imageView, View.SCALE_X, 1f, 1.2f, 1f);
            scaleXAnimator.setDuration(duration);
            scaleXAnimator.setRepeatCount(1);

            final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 1f, 1.2f, 1f);
            scaleYAnimator.setDuration(duration);
            scaleYAnimator.setRepeatCount(1);

            scaleXAnimator.start();
            scaleYAnimator.start();

            final AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.play(scaleXAnimator).with(scaleYAnimator);
            animatorSet.start();
        }
    }, 400);
}
 
Example 2
private void animateImage(final ImageView imageView) {
    imageView.postDelayed(new Runnable() {
        @Override
        public void run() {
            // Play a subtle animation
            final long duration = 300;

            final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(imageView, View.SCALE_X, 1f, 1.2f, 1f);
            scaleXAnimator.setDuration(duration);
            scaleXAnimator.setRepeatCount(1);

            final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 1f, 1.2f, 1f);
            scaleYAnimator.setDuration(duration);
            scaleYAnimator.setRepeatCount(1);

            scaleXAnimator.start();
            scaleYAnimator.start();

            final AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.play(scaleXAnimator).with(scaleYAnimator);
            animatorSet.start();
        }
    }, 400);
}
 
Example 3
Source Project: bither-android   File: RawDataDiceView.java    License: Apache License 2.0 6 votes vote down vote up
public void removeAllData() {
    int size = data.size();
    data.clear();
    for (int i = 0;
         i < size;
         i++) {
        final ImageView iv = (ImageView) ((FrameLayout) getChildAt(i)).getChildAt(0);
        if (iv.getVisibility() == View.VISIBLE) {
            ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                    0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            anim.setDuration(300);
            anim.setFillAfter(true);
            iv.startAnimation(anim);
            if (iv.getTag() != null && iv.getTag() instanceof HideIvRunnable) {
                iv.removeCallbacks((Runnable) iv.getTag());
            }
            HideIvRunnable r = new HideIvRunnable(iv);
            iv.setTag(r);
            iv.postDelayed(r, 300);
        }
    }
}
 
Example 4
Source Project: bither-android   File: RawDataDiceView.java    License: Apache License 2.0 6 votes vote down vote up
public void deleteLast() {
    int size = data.size();
    if (size <= 0) {
        return;
    }
    data.remove(size - 1);
    final ImageView iv = (ImageView) ((FrameLayout) getChildAt(size - 1)).getChildAt(0);
    if (iv.getVisibility() == View.VISIBLE) {
        ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        anim.setDuration(300);
        anim.setFillAfter(true);
        iv.startAnimation(anim);
        if (iv.getTag() != null && iv.getTag() instanceof HideIvRunnable) {
            iv.removeCallbacks((Runnable) iv.getTag());
        }
        HideIvRunnable r = new HideIvRunnable(iv);
        iv.setTag(r);
        iv.postDelayed(r, 300);
    }
}
 
Example 5
public void removeAllData(){
    int size = data.size();
    data.clear();
    for(int i = 0; i < size; i++){
        final ImageView iv = (ImageView) ((FrameLayout) getChildAt(i)).getChildAt(0);
        if(iv.getVisibility() == View.VISIBLE){
            ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                    0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            anim.setDuration(300);
            anim.setFillAfter(true);
            iv.startAnimation(anim);
            iv.postDelayed(new Runnable() {
                @Override
                public void run() {
                    iv.setVisibility(View.INVISIBLE);
                }
            }, 300);
        }
    }
}
 
Example 6
public void deleteLast(){
    int size = data.size();
    if(size <= 0){
        return;
    }
    data.remove(size - 1);
    final ImageView iv = (ImageView) ((FrameLayout) getChildAt(size - 1)).getChildAt(0);
    if(iv.getVisibility() == View.VISIBLE){
        ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        anim.setDuration(300);
        anim.setFillAfter(true);
        iv.startAnimation(anim);
        iv.postDelayed(new Runnable() {
            @Override
            public void run() {
                iv.setVisibility(View.INVISIBLE);
            }
        }, 300);
    }
}
 
Example 7
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(ResHelper.getLayoutRes(this, "activity_splash"));

	ivSplash = (ImageView) findViewById(ResHelper.getIdRes(this, "ivSplash"));

	ivSplash.postDelayed(new Runnable() {
		@Override
		public void run() {
			startActivity(new Intent(SplashActivity.this, InitActivity.class));
			finish();
		}
	}, 1500);
}
 
Example 8
Source Project: Carpaccio   File: ImageViewController.java    License: Apache License 2.0 5 votes vote down vote up
public void blur(final ImageView imageView, final int radiusString) {
    imageView.postDelayed(new Runnable() {
        @Override
        public void run() {
            try {
                Bitmap newBitmap = FastBlurHelper.getBitmapBlurFromView(imageView, radiusString);
                imageView.setImageBitmap(newBitmap);
            } catch (Exception e) {
                Log.e(TAG, e.getMessage(), e);
            }
        }
    }, 10);

}
 
Example 9
Source Project: Carpaccio   File: ImageViewController.java    License: Apache License 2.0 5 votes vote down vote up
public void greyScale(final ImageView imageView) {
    imageView.postDelayed(new Runnable() {
        @Override
        public void run() {
            try {
                Bitmap newBitmap = GrayScaleHelper.getBitmapGreyScaleFromView(imageView);
                imageView.setImageBitmap(newBitmap);
            } catch (Exception e) {
                Log.e(TAG, e.getMessage(), e);
            }
        }
    }, 10);

}
 
Example 10
Source Project: Magnet   File: MyService.java    License: MIT License 5 votes vote down vote up
@Override public void startMagnet() {
  final ImageView iconView = new ImageView(context);
  iconView.setImageResource(R.drawable.ic_launcher);
  if (magnet == null) {
    magnet = Magnet.newBuilder(context)
        .setIconView(iconView)
        .setIconCallback(this)
        .setHideFactor(0.2f)
        .setShouldShowRemoveView(true)
        .setRemoveIconResId(R.drawable.ic_close)
        .setRemoveIconShadow(R.drawable.bottom_shadow)
        .setShouldStickToWall(true)
        .setRemoveIconShouldBeResponsive(true)
        .setInitialPosition(100, 200)
        .build();
    magnet.show();
    iconView.postDelayed(new Runnable() {
      @Override public void run() {
        if (magnet != null) {
          magnet.setPosition(500, 800);
          iconView.postDelayed(new Runnable() {
            @Override public void run() {
              magnet.goToWall();
            }
          }, 500);
        }
      }
    }, 1000);
  }
}