Example usage for android.widget ImageView setAnimation

List of usage examples for android.widget ImageView setAnimation

Introduction

In this page you can find the example usage for android.widget ImageView setAnimation.

Prototype

public void setAnimation(Animation animation) 

Source Link

Document

Sets the next animation to play for this view.

Usage

From source file:com.android.aft.AFCoreTools.ImageDownloader.java

/**
 * Download the specified image from the Internet and binds it to the
 * provided ImageView. The binding is immediate if the image is found in the
 * cache and will be done asynchronously otherwise. A null bitmap will be
 * associated to the ImageView if an error occurs.
 *
 * @param url The URL of the image to download.
 * @param imageView The ImageView to bind the downloaded image to.
 *//*from   www  .ja  v  a 2  s.c  o  m*/
public void download(String url, ImageView imageView, ImageDownloaderListener listener, Animation animation,
        int reqWidth, int reqHeight) {
    if (url != null) {
        resetPurgeTimer();
        Bitmap bitmap = getBitmapFromCache(url, reqWidth, reqHeight);

        if (bitmap == null) {
            forceDownload(url, imageView, reqWidth, reqHeight, listener, animation);
        } else {
            cancelPotentialDownload(url, imageView);
            // imageView.setBackgroundDrawable(null);
            imageView.setImageDrawable(null);
            // imageView.setScaleType(ScaleType.FIT_XY);
            imageView.setImageBitmap(bitmap);
            if (animation != null) {
                imageView.setAnimation(animation);
            }
            if (listener != null) {
                listener.onImageDownloaded(url, bitmap, imageView);
            }
        }
    }
}

From source file:com.android.aft.AFCoreTools.ImageDownloader.java

/**
 * Same as download but the image is always downloaded and the cache is not
 * used. Kept private at the moment as its interest is not clear.
 *///  w ww .j  ava 2  s  . com
private void forceDownload(String url, ImageView imageView, int reqWidth, int reqHeight,
        ImageDownloaderListener listener, Animation animation) {
    // State sanity: url is guaranteed to never be null in
    // DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(null);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        BitmapDownloaderTask task = new BitmapDownloaderTask(imageView, listener, reqWidth, reqHeight);

        Bitmap bg = null;
        if (imageView.getDrawable() instanceof BitmapDrawable)
            bg = ((BitmapDrawable) imageView.getDrawable()).getBitmap();

        DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task, bg);

        imageView.setImageDrawable(downloadedDrawable);
        if (animation != null) {
            imageView.setAnimation(animation);
        }
        imageView.setMinimumHeight(156);

        task.execute(Mode.Parallel, url);
    }
}

From source file:de.dmxcontrol.activity.ControlActivity.java

private Dialog createSplashDialog() {
    Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
    dialog.setContentView(R.layout.dialog_splash);
    ImageView image = (ImageView) dialog.findViewById(R.id.image_splash);
    image.setImageResource(R.drawable.image_splash);

    AnimationSet set = new AnimationSet(true);
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(500);//from   w w w.ja  v a 2s  .c o  m
    animation.setInterpolator(
            AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator));
    set.addAnimation(animation);
    animation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(1000);
    animation.setInterpolator(
            AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator));
    set.addAnimation(animation);

    image.setAnimation(set);
    dismissSplashDelayed();
    return dialog;
}

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

public void restoreonehourglass(ImageView iv, int drawable) {
    iv.setImageResource(drawable);//from  ww w. j a  va2s. c  om
    iv.setClickable(true);
    iv.removeOnLayoutChangeListener(hourglasslistener);
    iv.setAnimation(null);
}