Example usage for android.graphics.drawable TransitionDrawable reverseTransition

List of usage examples for android.graphics.drawable TransitionDrawable reverseTransition

Introduction

In this page you can find the example usage for android.graphics.drawable TransitionDrawable reverseTransition.

Prototype

public void reverseTransition(int duration) 

Source Link

Document

Reverses the transition, picking up where the transition currently is.

Usage

From source file:Main.java

public static void setOnTouchBackgroundEffect(View view) {
    view.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if (!(v.getBackground() instanceof TransitionDrawable))
                return false;

            TransitionDrawable transition = (TransitionDrawable) v.getBackground();

            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                transition.startTransition(500);
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
                transition.reverseTransition(500);
                break;
            }// w ww  .  j a  va 2  s.c  om

            return false;
        }
    });
}

From source file:org.runbuddy.tomahawk.views.PlaybackPanel.java

public void hideButtons() {
    mArtistNameButton.setClickable(false);
    TransitionDrawable drawable = (TransitionDrawable) mArtistNameButton.getBackground();
    drawable.reverseTransition(AnimationUtils.DURATION_CONTEXTMENU);
}

From source file:com.medhdj.pagergallery.PagerGalleryContainer.java

@Override
public void onPageSelected(int position) {
    if (position == mPreviousSelectedPosition) {
        return;/*from ww w .  ja va 2s .  com*/
    }
    View v = mPager.getChildAt(position);
    if (v != null) {
        if (v.getBackground() instanceof TransitionDrawable) {
            TransitionDrawable transition = (TransitionDrawable) v.getBackground();
            if (transition != null) {
                transition.startTransition(700);
            }

        }
    }

    View mprev = mPager.getChildAt(mPreviousSelectedPosition);
    if (mprev != null) {
        if (mprev.getBackground() instanceof TransitionDrawable) {
            TransitionDrawable transition = (TransitionDrawable) mprev.getBackground();
            if (transition != null) {
                transition.reverseTransition(700);
                transition.resetTransition();
            }

        }
    }

    if (mOnItemChangedListener != null) {
        mOnItemChangedListener.onItemSelected(v, position);
        mOnItemChangedListener.onItemUnSelected(mprev, mPreviousSelectedPosition);
    }

    mPreviousSelectedPosition = position;
}

From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java

@Override
protected void handleFindToolbarStateChange(boolean showing) {
    setVisibility(showing ? View.GONE : View.VISIBLE);
    TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.getDrawable();
    if (showing) {
        shadowDrawable.startTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
    } else {//from  w  w  w.  j a v a  2  s. co m
        shadowDrawable.reverseTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
    }
}

From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java

@Override
public void onUrlFocusChange(final boolean hasFocus) {
    super.onUrlFocusChange(hasFocus);

    triggerUrlFocusAnimation(hasFocus);//from w ww.j a  va2 s .c  o m

    TransitionDrawable shadowDrawable = (TransitionDrawable) mToolbarShadow.getDrawable();
    if (hasFocus) {
        dismissTabSwitcherCallout();
        shadowDrawable.startTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
    } else {
        shadowDrawable.reverseTransition(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
    }
}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/*************************************
 * /*  w w w  . ja  va2 s  .  co m*/
 * playPauseClickListenerHelper
 * 
 *************************************/
public void playPauseClickListenerHelper() {
    try {
        // TODO: UI related updates----
        //   these are just mockups
        if (playerServiceIface.isPlaying()) {
            playerServiceIface.pause();
            //            AlphaAnimation albumPlayingFadeOut = new AlphaAnimation((float)1.0, (float)0.66);
            //            albumPlayingFadeOut.setFillAfter(true);
            //            albumPlayingFadeOut.setDuration(200);
            //            currentAlbumPlayingLayout.startAnimation(albumPlayingFadeOut);
            //playPauseImage.setImageResource(android.R.drawable.ic_media_play);
            TransitionDrawable playPauseTDrawable = (TransitionDrawable) playPauseImage.getDrawable();
            playPauseTDrawable.setCrossFadeEnabled(true);
            playPauseTDrawable.reverseTransition(300);
            playPauseTDrawable.invalidateSelf();
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 50);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 100);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 150);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 200);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 250);
            //            TransitionDrawable playPauseBgTDrawable = (TransitionDrawable) playPauseImage.getBackground();
            //            playPauseBgTDrawable.startTransition(500);
            //            playPauseBgTDrawable.invalidateSelf();
            //            playPauseOverlayHandler.sendEmptyMessageDelayed(0, 500);
            //            currentAlbumPlayingLayout.invalidate();
            //TODO: reverse transition with an handler
            //            
            //            playPauseImageOverlay.setVisibility(View.VISIBLE);
            //            AlphaAnimation playPauseImageOverlayFadeIn = new AlphaAnimation(0.0f, 1.0f);
            //            playPauseImageOverlayFadeIn.setFillAfter(true);
            //            playPauseImageOverlayFadeIn.setDuration(200);
            //            playPauseImageOverlayFadeIn.setAnimationListener(playPauseOverlayFadeInAnimationListener);
            //            playPauseImageOverlay.startAnimation(playPauseImageOverlayFadeIn);
            //currentAlbumPlayingLayout.setBackgroundColor(Color.argb(128, 255, 255, 255));
            if (songProgressTimer != null)
                songProgressTimer.cancel();
        } else {
            //playerServiceIface.resume(); - use a delayed timer to not interfere with the button animations
            Message msg = new Message();
            msg.what = 0;
            playerServiceResumeHandler.sendMessageDelayed(new Message(), 900);
            //            AlphaAnimation albumPlayingFadeIn = new AlphaAnimation((float)0.66, (float)1.0);
            //            albumPlayingFadeIn.setFillAfter(true);
            //            albumPlayingFadeIn.setDuration(200);
            //            currentAlbumPlayingLayout.startAnimation(albumPlayingFadeIn);
            //playPauseImage.setImageResource(android.R.drawable.ic_media_pause);
            TransitionDrawable playPauseTDrawable = (TransitionDrawable) playPauseImage.getDrawable();
            playPauseTDrawable.setCrossFadeEnabled(true);
            playPauseTDrawable.startTransition(500);
            playPauseTDrawable.invalidateSelf();
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 150);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 300);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 450);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 600);
            invalidateCurrentSongLayout.sendEmptyMessageDelayed(0, 750);
            //            TransitionDrawable playPauseBgTDrawable = (TransitionDrawable) playPauseImage.getBackground();
            //            playPauseBgTDrawable.startTransition(500);
            //            playPauseBgTDrawable.invalidateSelf();
            //            playPauseOverlayHandler.sendEmptyMessageDelayed(0, 500);
            //            currentAlbumPlayingLayout.invalidate();
            //TODO: reverse transition with an handler
            //            
            //            playPauseImageOverlay.setVisibility(View.VISIBLE);
            //            AlphaAnimation playPauseImageOverlayFadeIn = new AlphaAnimation(0.0f, 1.0f);
            //            playPauseImageOverlayFadeIn.setFillAfter(true);
            //            playPauseImageOverlayFadeIn.setDuration(250);
            //            playPauseImageOverlayFadeIn.setAnimationListener(playPauseOverlayFadeInAnimationListener);
            //            playPauseImageOverlay.startAnimation(playPauseImageOverlayFadeIn);
            //currentAlbumPlayingLayout.setBackgroundColor(Color.argb(0, 255, 255, 255));
            //Log.i("RES", "1");
            //            songProgressTimer = new Timer();
            //            Log.i("RES", "7");
            //            songProgressTimer.scheduleAtFixedRate(new SongProgressTimerTask(), 100, 1000);
            //            Log.i("RES", "8");
            updateSongTextUI(); // starts the progress timer
            //triggerSongProgress();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}