Example usage for android.widget ImageView getAlpha

List of usage examples for android.widget ImageView getAlpha

Introduction

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

Prototype

@ViewDebug.ExportedProperty(category = "drawing")
public float getAlpha() 

Source Link

Document

The opacity of the view.

Usage

From source file:org.runbuddy.tomahawk.ui.fragments.PlaybackFragment.java

/**
 * Refresh the information in this fragment to reflect that of the given Track.
 *///  ww w.j ava2s  . com
protected void refreshTrackInfo(MediaMetadataCompat metadata) {
    if (getView() != null && metadata != null && getPlaybackManager().getCurrentQuery() != null) {
        if (getPlaybackManager().getPreviousEntry() != null) {
            resolveImages(getPlaybackManager().getPreviousEntry().getQuery());
        }
        if (getPlaybackManager().getNextEntry() != null) {
            resolveImages(getPlaybackManager().getNextEntry().getQuery());
        }
        if (mCurrentBlurredImage != getPlaybackManager().getCurrentQuery().getImage()) {
            mCurrentBlurredImage = getPlaybackManager().getCurrentQuery().getImage();
            ImageView bgImageView = (ImageView) getView().findViewById(R.id.background);
            ImageView bgAltImageView = (ImageView) getView().findViewById(R.id.background_alt);
            final ImageView imageViewToFadeIn;
            final ImageView imageViewToFadeOut;
            if (bgAltImageView.getAlpha() < bgImageView.getAlpha()) {
                imageViewToFadeIn = bgAltImageView;
                imageViewToFadeOut = bgImageView;
            } else {
                imageViewToFadeIn = bgImageView;
                imageViewToFadeOut = bgAltImageView;
            }
            Callback fadeCallback = new Callback() {
                @Override
                public void onSuccess() {
                    AnimationUtils.fade(imageViewToFadeIn, imageViewToFadeIn.getAlpha(), 1f,
                            AnimationUtils.DURATION_PLAYBACKFRAGMENT_BG, true, null);
                    AnimationUtils.fade(imageViewToFadeOut, imageViewToFadeOut.getAlpha(), 0f,
                            AnimationUtils.DURATION_PLAYBACKFRAGMENT_BG, false,
                            new Animator.AnimatorListener() {
                                @Override
                                public void onAnimationStart(Animator animation) {
                                }

                                @Override
                                public void onAnimationEnd(Animator animation) {
                                    imageViewToFadeOut.setImageDrawable(null);
                                }

                                @Override
                                public void onAnimationCancel(Animator animation) {
                                }

                                @Override
                                public void onAnimationRepeat(Animator animation) {
                                }
                            });
                }

                @Override
                public void onError() {
                }
            };
            if (mCurrentBlurredImage != null) {
                ImageUtils.loadBlurredImageIntoImageView(TomahawkApp.getContext(), imageViewToFadeIn,
                        mCurrentBlurredImage, Image.getSmallImageSize(), 0, fadeCallback);
            } else {
                imageViewToFadeIn.setImageDrawable(
                        new ColorDrawable(getResources().getColor(R.color.playerview_default_bg)));
                fadeCallback.onSuccess();
            }
        }
    }
}