Example usage for android.view.animation AlphaAnimation setDuration

List of usage examples for android.view.animation AlphaAnimation setDuration

Introduction

In this page you can find the example usage for android.view.animation AlphaAnimation setDuration.

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:com.zhongsou.souyue.activity.SplashActivity.java

private void animationHide(ImageView iv) {
    try {//  w  ww.  j  a v  a  2  s.  c o  m
        AlphaAnimation ai = new AlphaAnimation(1.0f, 0.0f);
        ai.setDuration(500);
        ai.setFillAfter(true);
        iv.startAnimation(ai);
    } catch (Exception ex) {

    }
}

From source file:com.zhongsou.souyue.activity.SplashActivity.java

private void animationShow(ImageView iv) {
    try {//from  w  ww.j ava  2s  .  c o m
        AlphaAnimation ai = new AlphaAnimation(0.0f, 1.0f);
        ai.setDuration(500);
        ai.setFillAfter(true);
        iv.startAnimation(ai);
    } catch (Exception ex) {

    }
}

From source file:com.fastbootmobile.encore.app.fragments.PlaylistViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View root = inflater.inflate(R.layout.fragment_playlist_view, container, false);
    assert root != null;

    if (mPlaylist == null) {
        // If playlist couldn't load, abort early
        return root;
    }/*  w  w w  . j  av a  2  s. c o m*/

    mListViewContents = (PlaylistListView) root.findViewById(R.id.lvPlaylistContents);

    // Setup the parallaxed header
    View headerView = inflater.inflate(R.layout.header_listview_songs, mListViewContents, false);
    mListViewContents.addParallaxedHeaderView(headerView);

    mAdapter = new PlaylistAdapter();
    mListViewContents.setAdapter(mAdapter);
    mListViewContents.setOnScrollListener(new ScrollStatusBarColorListener() {
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (view.getChildCount() == 0 || getActivity() == null) {
                return;
            }

            final float heroHeight = mIvHero.getMeasuredHeight();
            final float scrollY = getScroll(view);
            final float toolbarBgAlpha = Math.min(1, scrollY / heroHeight);
            final int toolbarAlphaInteger = (((int) (toolbarBgAlpha * 255)) << 24) | 0xFFFFFF;
            mColorDrawable.setColor(toolbarAlphaInteger & getResources().getColor(R.color.primary));

            SpannableString spannableTitle = new SpannableString(
                    mPlaylist.getName() != null ? mPlaylist.getName() : "");
            mAlphaSpan.setAlpha(toolbarBgAlpha);

            ActionBar actionbar = ((AppActivity) getActivity()).getSupportActionBar();
            if (actionbar != null) {
                actionbar.setBackgroundDrawable(mColorDrawable);
                spannableTitle.setSpan(mAlphaSpan, 0, spannableTitle.length(),
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                actionbar.setTitle(spannableTitle);
                if (Utils.hasLollipop()) {
                    getActivity().getWindow().setStatusBarColor(
                            toolbarAlphaInteger & getResources().getColor(R.color.primary_dark));
                }
            }
        }
    });

    headerView.findViewById(R.id.pbAlbumLoading).setVisibility(View.GONE);

    mIvHero = (ImageView) headerView.findViewById(R.id.ivHero);

    mTvPlaylistName = (TextView) headerView.findViewById(R.id.tvAlbumName);

    // Download button
    mOfflineBtn = (CircularProgressButton) headerView.findViewById(R.id.cpbOffline);
    mOfflineBtn.setAlpha(0.0f);
    mOfflineBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ProviderIdentifier pi = mPlaylist.getProvider();
            IMusicProvider provider = PluginsLookup.getDefault().getProvider(pi).getBinder();
            try {
                if (mPlaylist.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_NO) {
                    provider.setPlaylistOfflineMode(mPlaylist.getRef(), true);
                    mOfflineBtn.setIndeterminateProgressMode(true);
                    mOfflineBtn.setProgress(1);

                    if (ProviderAggregator.getDefault().isOfflineMode()) {
                        Toast.makeText(getActivity(), R.string.toast_offline_playlist_sync, Toast.LENGTH_SHORT)
                                .show();
                    }
                } else {
                    provider.setPlaylistOfflineMode(mPlaylist.getRef(), false);
                    mOfflineBtn.setProgress(0);
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Cannot set this playlist to offline mode", e);
                mOfflineBtn.setProgress(-1);
            }
        }
    });

    mHandler.sendEmptyMessageDelayed(UPDATE_OFFLINE_STATUS, 300);
    mTvPlaylistName.setText(mPlaylist.getName());

    Bitmap hero = Utils.dequeueBitmap(PlaylistActivity.BITMAP_PLAYLIST_HERO);
    if (hero == null) {
        mIvHero.setImageResource(R.drawable.album_placeholder);
    } else {
        mIvHero.setImageBitmap(hero);

        // Request the higher resolution
        loadArt();
    }

    mPlayFab = (FloatingActionButton) headerView.findViewById(R.id.fabPlay);

    // Set source logo
    mIvSource = (ImageView) headerView.findViewById(R.id.ivSourceLogo);
    mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mPlaylist);
    mIvSource.setImageDrawable(mLogoBitmap);

    // Set the FAB animated drawable
    mFabDrawable = new PlayPauseDrawable(getResources(), 1);
    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY);
    mFabDrawable.setYOffset(6);

    mPlayFab.setImageDrawable(mFabDrawable);
    mPlayFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) {
                if (mFabShouldResume) {
                    PlaybackProxy.play();
                    mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                    mFabDrawable.setBuffering(true);
                } else {
                    playNow();
                }

                if (Utils.hasLollipop()) {
                    showMaterialReelBar(mPlayFab);
                }
            } else {
                mFabShouldResume = true;
                PlaybackProxy.pause();
                mFabDrawable.setBuffering(true);
            }
        }
    });

    // Fill the playlist
    mAdapter.setPlaylist(mPlaylist);

    // Set the list listener
    mListViewContents.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Song song = mAdapter.getItem(i - 1);
            if (Utils.canPlaySong(song)) {
                PlaybackProxy.clearQueue();
                PlaybackProxy.queuePlaylist(mPlaylist, false);
                PlaybackProxy.playAtIndex(i - 1);

                // Update FAB
                mFabShouldResume = true;
                mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE);
                mFabDrawable.setBuffering(true);

                if (Utils.hasLollipop()) {
                    showMaterialReelBar(mPlayFab);
                }
            }
        }
    });

    // Set the display animation
    AlphaAnimation anim = new AlphaAnimation(0.f, 1.f);
    anim.setDuration(200);
    mListViewContents.setLayoutAnimation(new LayoutAnimationController(anim));

    setupMaterialReelBar(root, mReelFabClickListener);

    // Setup the opening animations for non-Lollipop devices
    if (!Utils.hasLollipop()) {
        mTvPlaylistName.setVisibility(View.VISIBLE);
        mTvPlaylistName.setAlpha(0.0f);
        mTvPlaylistName.animate().alpha(1.0f).setDuration(AlbumActivity.BACK_DELAY).start();
    }

    mIvSource.setAlpha(0.0f);
    mIvSource.animate().alpha(1).setDuration(200).start();

    return root;
}

From source file:com.xander.panel.PanelController.java

private Animation createBgAnimation(int animType) {
    AlphaAnimation an = null;
    if (ANIM_TYPE_SHOW == animType) {
        an = new AlphaAnimation(0, 1);
    } else {//from www. jav a  2 s  .c  o  m
        an = new AlphaAnimation(1, 0);
    }
    an.setDuration(DURATION_ALPHA);
    an.setFillAfter(true);
    return an;
}

From source file:org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity.java

/**
 * Load QR Code asynchronously and with a fade in animation
 *//*from   w  w w . j av  a 2 s  .com*/
private void loadQrCode(final byte[] fingerprint) {
    AsyncTask<Void, Void, Bitmap> loadTask = new AsyncTask<Void, Void, Bitmap>() {
        protected Bitmap doInBackground(Void... unused) {
            String fingerprintStr = KeyFormattingUtils.convertFingerprintToHex(fingerprint);
            Uri uri = new Uri.Builder().scheme(Constants.FINGERPRINT_SCHEME).opaquePart(fingerprintStr).build();
            // render with minimal size
            return QrCodeUtils.getQRCodeBitmap(uri, 0);
        }

        protected void onPostExecute(Bitmap qrCode) {
            mQrCodeLoaded = fingerprint;
            // scale the image up to our actual size. we do this in code rather
            // than let the ImageView do this because we don't require filtering.
            Bitmap scaled = Bitmap.createScaledBitmap(qrCode, mQrCode.getHeight(), mQrCode.getHeight(), false);
            mQrCode.setImageBitmap(scaled);

            // simple fade-in animation
            AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
            anim.setDuration(200);
            mQrCode.startAnimation(anim);
        }
    };

    loadTask.execute();
}

From source file:com.chuhan.privatecalc.fragment.os.FragmentManager.java

static Animation makeFadeAnimation(Context context, float start, float end) {
    AlphaAnimation anim = new AlphaAnimation(start, end);
    anim.setInterpolator(DECELERATE_CUBIC);
    anim.setDuration(ANIM_DUR);
    return anim;/*from w  w  w . j  av  a  2 s.c om*/
}

From source file:com.chuhan.privatecalc.fragment.os.FragmentManager.java

static Animation makeOpenCloseAnimation(Context context, float startScale, float endScale, float startAlpha,
        float endAlpha) {
    AnimationSet set = new AnimationSet(false);
    ScaleAnimation scale = new ScaleAnimation(startScale, endScale, startScale, endScale,
            Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    scale.setInterpolator(DECELERATE_QUINT);
    scale.setDuration(ANIM_DUR);//from   ww w. j a  v  a2 s .c om
    set.addAnimation(scale);
    AlphaAnimation alpha = new AlphaAnimation(startAlpha, endAlpha);
    alpha.setInterpolator(DECELERATE_CUBIC);
    alpha.setDuration(ANIM_DUR);
    set.addAnimation(alpha);
    return set;
}

From source file:com.ebaonet.lawyer.ui.weight.DraggableGridViewPager.java

private void animateDragged() {
    if (mLastDragged >= 0) {
        final View v = getChildAt(mLastDragged);

        final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
        r.inset(-r.width() / 20, -r.height() / 20);
        v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
        v.layout(r.left, r.top, r.right, r.bottom);

        AnimationSet animSet = new AnimationSet(true);
        ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
        scale.setDuration(ANIMATION_DURATION);
        AlphaAnimation alpha = new AlphaAnimation(1, .8f);
        alpha.setDuration(ANIMATION_DURATION);

        animSet.addAnimation(scale);/*www  . j  a v a 2s .c om*/
        animSet.addAnimation(alpha);
        animSet.setFillEnabled(true);
        animSet.setFillAfter(true);

        v.clearAnimation();
        v.startAnimation(animSet);
    }
}

From source file:com.example.testtab.fragment.TwitEyesPageFragment.java

public void showProgressBar(int percent) {
    TextView textLayer = (TextView) this.mRootView.findViewById(R.id.progress_bar);
    AnimationSet set = new AnimationSet(true);

    // ALPHA//from ww w. jav  a 2  s .  c om
    AlphaAnimation alpha;
    switch (percent) {
    case 100:
        alpha = new AlphaAnimation(1.0f, 0.0f);
        break;
    case 0:
        alpha = new AlphaAnimation(0.0f, 1.0f);
        break;
    default:
        alpha = new AlphaAnimation(0.8f, 1.0f);
    }
    alpha.setDuration(500);

    TranslateAnimation translate;
    float toX = ((float) percent - 100.0f) / 100.0f;
    float fromX = toX - 0.1f;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
    translate.setDuration(500);
    translate.setInterpolator(new BounceInterpolator());

    set.addAnimation(alpha);
    set.addAnimation(translate);
    //         set.setDuration(500);
    set.setFillBefore(true);
    set.setFillAfter(true);

    textLayer.startAnimation(set);
}

From source file:com.android.hcframe.DraggableGridViewPager.java

private void animateDragged() {
    if (mLastDragged >= 0) {
        final View v = getChildAt(mLastDragged);

        final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
        r.inset(-r.width() / 20, -r.height() / 20);
        v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
        v.layout(r.left, r.top, r.right, r.bottom);

        AnimationSet animSet = new AnimationSet(true);
        ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
        scale.setDuration(ANIMATION_DURATION);
        AlphaAnimation alpha = new AlphaAnimation(1, .5f);
        alpha.setDuration(ANIMATION_DURATION);

        animSet.addAnimation(scale);//w  w  w  . j a va 2 s .c  o m
        animSet.addAnimation(alpha);
        animSet.setFillEnabled(true);
        animSet.setFillAfter(true);

        v.clearAnimation();
        v.startAnimation(animSet);
    }
}