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:pw.dedominic.airc.fragment.ConnectingFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_connecting, container, false);
    ImageView imageView = (ImageView) v.findViewById(R.id.spinning_cog);
    imageView.setAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.rotate_continuous));
    return v;/*from  w  w w.java 2  s .  c om*/
}

From source file:org.immopoly.android.adapter.FlatsPagerAdapter.java

private View getFlatView(final Flat flat, final int idx) {
    LayoutInflater inflater = LayoutInflater.from(mContext.getActivity());

    int layout = inPortfolio ? R.layout.teaser_content_portfolio : R.layout.teaser_content;
    View teaserView = inflater.inflate(layout, null, false);

    ImageView stateSymbol = (ImageView) teaserView.findViewById(R.id.stateSymbol);
    if (!flat.owned) {
        if (flat.age == Flat.AGE_OLD)
            stateSymbol.setImageResource(R.drawable.house_old);
        else if (flat.age == Flat.AGE_NEW)
            stateSymbol.setImageResource(R.drawable.house_new);
        else/*from w w w.jav  a2 s .co m*/
            stateSymbol.setImageResource(R.drawable.house);
    }

    ((EllipsizingTextView) teaserView.findViewById(R.id.flat_desc_text)).setText(flat.name);
    ((TextView) teaserView.findViewById(R.id.rooms_text))
            .setText(flat.numRooms > 0 ? Integer.toString(flat.numRooms) : "?");
    ((TextView) teaserView.findViewById(R.id.qm_text))
            .setText(flat.livingSpace > 0 ? numFmt.format(flat.livingSpace) : "?");
    ((TextView) teaserView.findViewById(R.id.price_text)).setText(flat.priceValue + " "); // TODO kommt im IS24 JSON immer EUR/MONTH ? 

    if (inPortfolio) {
        ((LinearLayout) teaserView.findViewById(R.id.takeover_daterow)).setVisibility(View.VISIBLE);
        String takeoverDate = flat.takeoverDate > 0 ? dateSDF.format(new Date(flat.takeoverDate)) : "?";
        ((EllipsizingTextView) teaserView.findViewById(R.id.flat_desc_text)).setMaxLines(3);
        ((TextView) teaserView.findViewById(R.id.takeover_date)).setText(takeoverDate);
        if (flat.owned && flat.takeoverTries > 0) {
            ((LinearLayout) teaserView.findViewById(R.id.takeover_numrow)).setVisibility(View.VISIBLE);
            ((EllipsizingTextView) teaserView.findViewById(R.id.flat_desc_text)).setMaxLines(2);
            ((TextView) teaserView.findViewById(R.id.takeovers_text)).setText("" + flat.takeoverTries);
        } else {
            ((LinearLayout) teaserView.findViewById(R.id.takeover_numrow)).setVisibility(View.GONE);
        }
    }
    ((EllipsizingTextView) teaserView.findViewById(R.id.flat_desc_text)).setMaxLines(2);

    teaserView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((OnMapItemClickedListener) mContext.getActivity()).onFlatClicked(flat);
        }
    });

    ImageView iconView = (ImageView) teaserView.findViewById(R.id.teaser_icon);
    if (flat.titlePictureSmall.trim().length() > 0) {
        imageDownloader.download(flat.titlePictureSmall, iconView);
    } else {
        iconView.clearAnimation();
        iconView.setAnimation(null);
        iconView.setImageDrawable(
                inflater.getContext().getResources().getDrawable(R.drawable.portfolio_fallback));
    }

    teaserView.setLayoutParams(new LayoutParams(270, 120));
    return teaserView;
}

From source file:free.yhc.netmbuddy.YTSearchFragment.java

protected void stopLoadingLookAndFeel() {
    View loadingv = mRootv.findViewById(R.id.loading);
    if (View.VISIBLE != loadingv.getVisibility())
        return;//from   w w  w .ja  va2  s .  c o  m

    ImageView iv = (ImageView) loadingv.findViewById(R.id.loading_img);
    if (null != iv.getAnimation()) {
        iv.getAnimation().cancel();
        iv.setAnimation(null);
    }
    mRootv.findViewById(R.id.error_text).setVisibility(View.GONE);
    loadingv.setVisibility(View.GONE);
    mListv.setVisibility(View.VISIBLE);
}

From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java

private ImageView getRotationImage() {
    RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(1000L);// w ww. j  a  va 2 s  . c  om
    rotateAnimation.setRepeatMode(Animation.INFINITE);
    rotateAnimation.setRepeatCount(Animation.INFINITE);
    rotateAnimation.setFillEnabled(false);
    rotateAnimation.setInterpolator(new LinearInterpolator());

    Drawable drawable = MBResourceService.getInstance().getImageByID(_refreshToolDef.getIcon());
    ImageView rotationImage = new ImageView(_context);
    rotationImage.setImageDrawable(drawable);
    rotationImage.setAnimation(rotateAnimation);

    return rotationImage;
}

From source file:org.immopoly.android.helper.ImageListDownloader.java

/**
 * Same as {@link #download(String, ImageView)}, with the possibility to
 * provide an additional cookie that will be used when the image will be
 * retrieved.// ww  w .j a  v  a2  s.co  m
 * 
 * @param url
 *            The URL of the image to download.
 * @param imageView
 *            The ImageView to bind the downloaded image to.
 * @param cookie
 *            A cookie String that will be used by the http connection.
 */
public void download(String url, ImageView imageView, String cookie) {
    resetPurgeTimer();
    Bitmap bitmap = getBitmapFromCache(url);

    if (bitmap == null) {
        forceDownload(url, imageView, cookie);
    } else {
        // stop animation
        imageView.setAnimation(null);
        cancelPotentialDownload(url, imageView);
        imageView.setImageBitmap(bitmap);
    }
}

From source file:org.immopoly.android.helper.ImageListDownloader.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.
 *//*from  w  w w . j  a  v a  2  s. co  m*/
private void forceDownload(String url, ImageView imageView, String cookie) {
    // State sanity: url is guaranteed to never be null in
    // DownloadedDrawable and cache keys.
    if (url == null) {
        imageView.setImageDrawable(new BitmapDrawable(fallbackBitmap));
        // stop animation
        imageView.setAnimation(null);
        return;
    }

    if (cancelPotentialDownload(url, imageView)) {
        BitmapDownloaderTask task = new BitmapDownloaderTask(imageView);
        DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task);
        // stop animation
        imageView.setAnimation(loadingAnimation);
        imageView.setImageDrawable(downloadedDrawable);
        task.execute(url, cookie);
    }
}

From source file:com.letsdoitworld.wastemapper.utils.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  w  w  w.j a va2  s . c o  m*/
public void download(String url, ImageView imageView) {
    resetPurgeTimer();
    Bitmap bitmap = getBitmapFromCache(url);

    if (bitmap == null) {
        forceDownload(url, imageView);
    } else {
        cancelPotentialDownload(url, imageView);
        imageView.setImageBitmap(bitmap);
        if (mContext != null) {
            imageView.setAnimation(AnimationUtils.loadAnimation(mContext, R.anim.fadeout));
        }

    }
}

From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java

private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation,
        float ratio, float anchor, int source) {
    bm = filter(iv, bm, fallback);/* w  w  w  .j  a  v a2  s .co m*/
    if (bm == null) {
        iv.setImageBitmap(null);
        return;
    }
    Drawable d = makeDrawable(iv, bm, ratio, anchor);
    Animation anim = null;
    if (fadeIn(animation, source)) {
        if (preset == null) {
            anim = new AlphaAnimation(0, 1);
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(FADE_DUR);
        } else {
            Drawable pd = makeDrawable(iv, preset, ratio, anchor);
            Drawable[] ds = new Drawable[] { pd, d };
            TransitionDrawable td = new TransitionDrawable(ds);
            td.setCrossFadeEnabled(true);
            td.startTransition(FADE_DUR);
            d = td;
        }
    } else if (animation > 0) {
        anim = AnimationUtils.loadAnimation(iv.getContext(), animation);
    }
    iv.setImageDrawable(d);
    if (anim != null) {
        anim.setStartTime(AnimationUtils.currentAnimationTimeMillis());
        iv.startAnimation(anim);
    } else {
        iv.setAnimation(null);
    }
}

From source file:dev.vision.shopping.center.Splash.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ImageView iv = new ImageView(this);
    Animation mLoadAnimation = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
    mLoadAnimation.setDuration(2500);/*from   w ww  . ja v a 2  s  .  c  om*/
    iv.setImageResource(R.drawable.myapp_loading);

    mLoadAnimation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            new Handler().postDelayed(new Runnable() {

                @SuppressLint("NewApi")
                @Override
                public void run() {
                    Intent i = new Intent(Splash.this, CustomZoomAnimation.class);
                    if (LICENSE.isValid("10/07/2015", Splash.this)) {
                        startActivity(i);
                        finish();
                    }
                }
            }, 2000);
        }
    });

    iv.setAnimation(mLoadAnimation);

    setContentView(iv);

}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation,
        float ratio, float anchor, int source) {

    bm = filter(iv, bm, fallback);/*from ww  w  . j  av  a2  s. c  o  m*/
    if (bm == null) {
        iv.setImageBitmap(null);
        return;
    }

    Drawable d = makeDrawable(iv, bm, ratio, anchor);
    Animation anim = null;

    if (fadeIn(animation, source)) {
        if (preset == null) {
            anim = new AlphaAnimation(0, 1);
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(FADE_DUR);
        } else {

            Drawable pd = makeDrawable(iv, preset, ratio, anchor);
            Drawable[] ds = new Drawable[] { pd, d };
            TransitionDrawable td = new TransitionDrawable(ds);
            td.setCrossFadeEnabled(true);
            td.startTransition(FADE_DUR);
            d = td;
        }
    } else if (animation > 0) {
        anim = AnimationUtils.loadAnimation(iv.getContext(), animation);
    }

    iv.setImageDrawable(d);

    if (anim != null) {
        anim.setStartTime(AnimationUtils.currentAnimationTimeMillis());
        iv.startAnimation(anim);
    } else {
        iv.setAnimation(null);
    }
}