List of usage examples for android.view View clearAnimation
public void clearAnimation()
From source file:android.support.v7.app.MediaRouteControllerDialog.java
void clearGroupListAnimation(boolean exceptAddedRoutes) { int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); if (exceptAddedRoutes && mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) { continue; }//from w w w . j a va 2s .co m LinearLayout container = (LinearLayout) view.findViewById(R.id.volume_item_container); container.setVisibility(View.VISIBLE); AnimationSet animSet = new AnimationSet(true); Animation alphaAnim = new AlphaAnimation(1.0f, 1.0f); alphaAnim.setDuration(0); animSet.addAnimation(alphaAnim); Animation translationAnim = new TranslateAnimation(0, 0, 0, 0); translationAnim.setDuration(0); animSet.setFillAfter(true); animSet.setFillEnabled(true); view.clearAnimation(); view.startAnimation(animSet); } mVolumeGroupList.stopAnimationAll(); if (!exceptAddedRoutes) { finishAnimation(false); } }
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);//from w ww.j a v a2 s . c o m animSet.addAnimation(alpha); animSet.setFillEnabled(true); animSet.setFillAfter(true); v.clearAnimation(); v.startAnimation(animSet); } }
From source file:com.coco.draggablegridviewpager.DraggableGridViewPager.java
private void animateGap(int target) { for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i); if (i == mLastDragged) { continue; }/*w ww . j a v a2 s .c o m*/ int newPos = i; if (mLastDragged < target && i >= mLastDragged + 1 && i <= target) { newPos--; } else if (target < mLastDragged && i >= target && i < mLastDragged) { newPos++; } int oldPos = i; if (newPositions.get(i) != -1) { oldPos = newPositions.get(i); } if (oldPos == newPos) { continue; } // animate DEBUG_LOG("animateGap from=" + oldPos + ", to=" + newPos); final Rect oldRect = getRectByPosition(oldPos); final Rect newRect = getRectByPosition(newPos); oldRect.offset(-v.getLeft(), -v.getTop()); newRect.offset(-v.getLeft(), -v.getTop()); TranslateAnimation translate = new TranslateAnimation(oldRect.left, newRect.left, oldRect.top, newRect.top); translate.setDuration(ANIMATION_DURATION); translate.setFillEnabled(true); translate.setFillAfter(true); v.clearAnimation(); v.startAnimation(translate); newPositions.set(i, newPos); } }
From source file:com.tencent.tws.assistant.support.v4.app.FragmentManager.java
void moveToState(Fragment f, int newState, int transit, int transitionStyle, boolean keepActive) { // Fragments that are not currently added will sit in the onCreate() state. if ((!f.mAdded || f.mDetached) && newState > Fragment.CREATED) { newState = Fragment.CREATED;//from w ww .ja v a 2 s . com } if (f.mRemoving && newState > f.mState) { // While removing a fragment, we can't change it to a higher state. newState = f.mState; } // Defer start if requested; don't allow it to move to STARTED or higher // if it's not already started. if (f.mDeferStart && f.mState < Fragment.STARTED && newState > Fragment.STOPPED) { newState = Fragment.STOPPED; } if (f.mState < newState) { // For fragments that are created from a layout, when restoring from // state we don't want to allow them to be created until they are // being reloaded from the layout. if (f.mFromLayout && !f.mInLayout) { return; } if (f.mAnimatingAway != null) { // The fragment is currently being animated... but! Now we // want to move our state back up. Give up on waiting for the // animation, move to whatever the final state should be once // the animation is done, and then we can proceed from there. f.mAnimatingAway = null; moveToState(f, f.mStateAfterAnimating, 0, 0, true); } switch (f.mState) { case Fragment.INITIALIZING: if (DEBUG) Log.v(TAG, "moveto CREATED: " + f); if (f.mSavedFragmentState != null) { f.mSavedViewState = f.mSavedFragmentState .getSparseParcelableArray(FragmentManagerImpl.VIEW_STATE_TAG); f.mTarget = getFragment(f.mSavedFragmentState, FragmentManagerImpl.TARGET_STATE_TAG); if (f.mTarget != null) { f.mTargetRequestCode = f.mSavedFragmentState .getInt(FragmentManagerImpl.TARGET_REQUEST_CODE_STATE_TAG, 0); } f.mUserVisibleHint = f.mSavedFragmentState.getBoolean(FragmentManagerImpl.USER_VISIBLE_HINT_TAG, true); if (!f.mUserVisibleHint) { f.mDeferStart = true; if (newState > Fragment.STOPPED) { newState = Fragment.STOPPED; } } } f.mActivity = mActivity; f.mParentFragment = mParent; f.mFragmentManager = mParent != null ? mParent.mChildFragmentManager : mActivity.mFragments; f.mCalled = false; f.onAttach(mActivity); if (!f.mCalled) { throw new SuperNotCalledException( "Fragment " + f + " did not call through to super.onAttach()"); } if (f.mParentFragment == null) { mActivity.onAttachFragment(f); } if (!f.mRetaining) { f.performCreate(f.mSavedFragmentState); } f.mRetaining = false; if (f.mFromLayout) { // For fragments that are part of the content view // layout, we need to instantiate the view immediately // and the inflater will take care of adding it. f.mView = f.performCreateView(f.getLayoutInflater(f.mSavedFragmentState), null, f.mSavedFragmentState); if (f.mView != null) { f.mInnerView = f.mView; f.mView = NoSaveStateFrameLayout.wrap(f.mView); if (f.mHidden) f.mView.setVisibility(View.GONE); f.onViewCreated(f.mView, f.mSavedFragmentState); } else { f.mInnerView = null; } } case Fragment.CREATED: if (newState > Fragment.CREATED) { if (DEBUG) Log.v(TAG, "moveto ACTIVITY_CREATED: " + f); if (!f.mFromLayout) { ViewGroup container = null; if (f.mContainerId != 0) { container = (ViewGroup) mContainer.findViewById(f.mContainerId); if (container == null && !f.mRestored) { throwException(new IllegalArgumentException( "No view found for id 0x" + Integer.toHexString(f.mContainerId) + " (" + f.getResources().getResourceName(f.mContainerId) + ") for fragment " + f)); } } f.mContainer = container; f.mView = f.performCreateView(f.getLayoutInflater(f.mSavedFragmentState), container, f.mSavedFragmentState); if (f.mView != null) { f.mInnerView = f.mView; f.mView = NoSaveStateFrameLayout.wrap(f.mView); if (container != null) { Animation anim = loadAnimation(f, transit, true, transitionStyle); if (anim != null) { f.mView.startAnimation(anim); } container.addView(f.mView); } if (f.mHidden) f.mView.setVisibility(View.GONE); f.onViewCreated(f.mView, f.mSavedFragmentState); } else { f.mInnerView = null; } } f.performActivityCreated(f.mSavedFragmentState); if (f.mView != null) { f.restoreViewState(f.mSavedFragmentState); } f.mSavedFragmentState = null; } case Fragment.ACTIVITY_CREATED: case Fragment.STOPPED: if (newState > Fragment.STOPPED) { if (DEBUG) Log.v(TAG, "moveto STARTED: " + f); f.performStart(); } case Fragment.STARTED: if (newState > Fragment.STARTED) { if (DEBUG) Log.v(TAG, "moveto RESUMED: " + f); f.mResumed = true; f.performResume(); f.mSavedFragmentState = null; f.mSavedViewState = null; } } } else if (f.mState > newState) { switch (f.mState) { case Fragment.RESUMED: if (newState < Fragment.RESUMED) { if (DEBUG) Log.v(TAG, "movefrom RESUMED: " + f); f.performPause(); f.mResumed = false; } case Fragment.STARTED: if (newState < Fragment.STARTED) { if (DEBUG) Log.v(TAG, "movefrom STARTED: " + f); f.performStop(); } case Fragment.STOPPED: if (newState < Fragment.STOPPED) { if (DEBUG) Log.v(TAG, "movefrom STOPPED: " + f); f.performReallyStop(); } case Fragment.ACTIVITY_CREATED: if (newState < Fragment.ACTIVITY_CREATED) { if (DEBUG) Log.v(TAG, "movefrom ACTIVITY_CREATED: " + f); if (f.mView != null) { // Need to save the current view state if not // done already. if (!mActivity.isFinishing() && f.mSavedViewState == null) { saveFragmentViewState(f); } } f.performDestroyView(); if (f.mView != null && f.mContainer != null) { Animation anim = null; if (mCurState > Fragment.INITIALIZING && !mDestroyed) { anim = loadAnimation(f, transit, false, transitionStyle); } if (anim != null) { final Fragment fragment = f; f.mAnimatingAway = f.mView; f.mStateAfterAnimating = newState; anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (fragment.mAnimatingAway != null) { fragment.mAnimatingAway = null; moveToState(fragment, fragment.mStateAfterAnimating, 0, 0, false); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); f.mView.startAnimation(anim); } f.mContainer.removeView(f.mView); } f.mContainer = null; f.mView = null; f.mInnerView = null; } case Fragment.CREATED: if (newState < Fragment.CREATED) { if (mDestroyed) { if (f.mAnimatingAway != null) { // The fragment's containing activity is // being destroyed, but this fragment is // currently animating away. Stop the // animation right now -- it is not needed, // and we can't wait any more on destroying // the fragment. View v = f.mAnimatingAway; f.mAnimatingAway = null; v.clearAnimation(); } } if (f.mAnimatingAway != null) { // We are waiting for the fragment's view to finish // animating away. Just make a note of the state // the fragment now should move to once the animation // is done. f.mStateAfterAnimating = newState; newState = Fragment.CREATED; } else { if (DEBUG) Log.v(TAG, "movefrom CREATED: " + f); if (!f.mRetaining) { f.performDestroy(); } f.mCalled = false; f.onDetach(); if (!f.mCalled) { throw new SuperNotCalledException( "Fragment " + f + " did not call through to super.onDetach()"); } if (!keepActive) { if (!f.mRetaining) { makeInactive(f); } else { f.mActivity = null; f.mFragmentManager = null; } } } } } } f.mState = newState; }
From source file:com.chuhan.privatecalc.fragment.os.FragmentManager.java
void moveToState(Fragment f, int newState, int transit, int transitionStyle, boolean keepActive) { // Fragments that are not currently added will sit in the onCreate() state. if ((!f.mAdded || f.mDetached) && newState > Fragment.CREATED) { newState = Fragment.CREATED;/* ww w . j a v a 2s . c o m*/ } if (f.mRemoving && newState > f.mState) { // While removing a fragment, we can't change it to a higher state. newState = f.mState; } // Defer start if requested; don't allow it to move to STARTED or higher // if it's not already started. if (f.mDeferStart && f.mState < Fragment.STARTED && newState > Fragment.STOPPED) { newState = Fragment.STOPPED; } if (f.mState < newState) { // For fragments that are created from a layout, when restoring from // state we don't want to allow them to be created until they are // being reloaded from the layout. if (f.mFromLayout && !f.mInLayout) { return; } if (f.mAnimatingAway != null) { // The fragment is currently being animated... but! Now we // want to move our state back up. Give up on waiting for the // animation, move to whatever the final state should be once // the animation is done, and then we can proceed from there. f.mAnimatingAway = null; moveToState(f, f.mStateAfterAnimating, 0, 0, true); } switch (f.mState) { case Fragment.INITIALIZING: if (DEBUG) Log.v(TAG, "moveto CREATED: " + f); if (f.mSavedFragmentState != null) { f.mSavedViewState = f.mSavedFragmentState .getSparseParcelableArray(FragmentManagerImpl.VIEW_STATE_TAG); f.mTarget = getFragment(f.mSavedFragmentState, FragmentManagerImpl.TARGET_STATE_TAG); if (f.mTarget != null) { f.mTargetRequestCode = f.mSavedFragmentState .getInt(FragmentManagerImpl.TARGET_REQUEST_CODE_STATE_TAG, 0); } f.mUserVisibleHint = f.mSavedFragmentState.getBoolean(FragmentManagerImpl.USER_VISIBLE_HINT_TAG, true); if (!f.mUserVisibleHint) { f.mDeferStart = true; if (newState > Fragment.STOPPED) { newState = Fragment.STOPPED; } } } f.mActivity = mActivity; f.mParentFragment = mParent; f.mFragmentManager = mParent != null ? mParent.mChildFragmentManager : mActivity.mFragments; f.mCalled = false; f.onAttach(mActivity); if (!f.mCalled) { throw new SuperNotCalledException( "Fragment " + f + " did not call through to super.onAttach()"); } if (f.mParentFragment == null) { mActivity.onAttachFragment(f); } if (!f.mRetaining) { f.performCreate(f.mSavedFragmentState); } f.mRetaining = false; if (f.mFromLayout) { // For fragments that are part of the content view // layout, we need to instantiate the view immediately // and the inflater will take care of adding it. f.mView = f.performCreateView(f.getLayoutInflater(f.mSavedFragmentState), null, f.mSavedFragmentState); if (f.mView != null) { f.mInnerView = f.mView; f.mView = NoSaveStateFrameLayout.wrap(f.mView); if (f.mHidden) f.mView.setVisibility(View.GONE); f.onViewCreated(f.mView, f.mSavedFragmentState); } else { f.mInnerView = null; } } case Fragment.CREATED: if (newState > Fragment.CREATED) { if (DEBUG) Log.v(TAG, "moveto ACTIVITY_CREATED: " + f); if (!f.mFromLayout) { ViewGroup container = null; if (f.mContainerId != 0) { container = (ViewGroup) mContainer.findViewById(f.mContainerId); if (container == null && !f.mRestored) { throwException(new IllegalArgumentException( "No view found for id 0x" + Integer.toHexString(f.mContainerId) + " (" + f.getResources().getResourceName(f.mContainerId) + ") for fragment " + f)); } } f.mContainer = container; f.mView = f.performCreateView(f.getLayoutInflater(f.mSavedFragmentState), container, f.mSavedFragmentState); if (f.mView != null) { f.mInnerView = f.mView; f.mView = NoSaveStateFrameLayout.wrap(f.mView); if (container != null) { Animation anim = loadAnimation(f, transit, true, transitionStyle); if (anim != null) { f.mView.startAnimation(anim); } container.addView(f.mView); } if (f.mHidden) f.mView.setVisibility(View.GONE); f.onViewCreated(f.mView, f.mSavedFragmentState); } else { f.mInnerView = null; } } f.performActivityCreated(f.mSavedFragmentState); if (f.mView != null) { f.restoreViewState(f.mSavedFragmentState); } f.mSavedFragmentState = null; } case Fragment.ACTIVITY_CREATED: case Fragment.STOPPED: if (newState > Fragment.STOPPED) { if (DEBUG) Log.v(TAG, "moveto STARTED: " + f); f.performStart(); } case Fragment.STARTED: if (newState > Fragment.STARTED) { if (DEBUG) Log.v(TAG, "moveto RESUMED: " + f); f.mResumed = true; f.performResume(); f.mSavedFragmentState = null; f.mSavedViewState = null; } } } else if (f.mState > newState) { switch (f.mState) { case Fragment.RESUMED: if (newState < Fragment.RESUMED) { if (DEBUG) Log.v(TAG, "movefrom RESUMED: " + f); f.performPause(); f.mResumed = false; } case Fragment.STARTED: if (newState < Fragment.STARTED) { if (DEBUG) Log.v(TAG, "movefrom STARTED: " + f); f.performStop(); } case Fragment.STOPPED: if (newState < Fragment.STOPPED) { if (DEBUG) Log.v(TAG, "movefrom STOPPED: " + f); f.performReallyStop(); } case Fragment.ACTIVITY_CREATED: if (newState < Fragment.ACTIVITY_CREATED) { if (DEBUG) Log.v(TAG, "movefrom ACTIVITY_CREATED: " + f); if (f.mView != null) { // Need to save the current view state if not // done already. if (!mActivity.isFinishing() && f.mSavedViewState == null) { saveFragmentViewState(f); } } f.performDestroyView(); if (f.mView != null && f.mContainer != null) { Animation anim = null; if (mCurState > Fragment.INITIALIZING && !mDestroyed) { anim = loadAnimation(f, transit, false, transitionStyle); } // modify boolean bSlideStillAnimation = anim instanceof SlideStillAnimation; if (anim != null) { final Fragment fragment = f; f.mAnimatingAway = f.mView; f.mStateAfterAnimating = newState; final ViewGroup container = bSlideStillAnimation ? f.mContainer : null; final View view = bSlideStillAnimation ? f.mView : null; anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (fragment.mAnimatingAway != null) { fragment.mAnimatingAway = null; moveToState(fragment, fragment.mStateAfterAnimating, 0, 0, false); } if (view != null) { container.postDelayed(new Runnable() { @Override public void run() { container.removeViewInLayout(view); } }, 100); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { } }); f.mView.startAnimation(anim); } if (!bSlideStillAnimation) { f.mContainer.removeView(f.mView); } } f.mContainer = null; f.mView = null; f.mInnerView = null; } case Fragment.CREATED: if (newState < Fragment.CREATED) { if (mDestroyed) { if (f.mAnimatingAway != null) { // The fragment's containing activity is // being destroyed, but this fragment is // currently animating away. Stop the // animation right now -- it is not needed, // and we can't wait any more on destroying // the fragment. View v = f.mAnimatingAway; f.mAnimatingAway = null; v.clearAnimation(); } } if (f.mAnimatingAway != null) { // We are waiting for the fragment's view to finish // animating away. Just make a note of the state // the fragment now should move to once the animation // is done. f.mStateAfterAnimating = newState; newState = Fragment.CREATED; } else { if (DEBUG) Log.v(TAG, "movefrom CREATED: " + f); if (!f.mRetaining) { f.performDestroy(); } f.mCalled = false; f.onDetach(); if (!f.mCalled) { throw new SuperNotCalledException( "Fragment " + f + " did not call through to super.onDetach()"); } if (!keepActive) { if (!f.mRetaining) { makeInactive(f); } else { f.mActivity = null; f.mFragmentManager = null; } } } } } } f.mState = newState; }
From source file:com.icloud.listenbook.base.view.DraggableGridViewPager.java
/*** * ?//w w w. ja v a2 s. c om * **/ 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); animSet.addAnimation(alpha); animSet.setFillEnabled(true); animSet.setFillAfter(true); v.clearAnimation(); v.startAnimation(animSet); } }
From source file:com.android.hcframe.DraggableGridViewPager.java
private void animateGap(int target) { for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i); if (i == mLastDragged) { continue; }// ww w .j a v a 2 s .c om int newPos = i; if (mLastDragged < target && i >= mLastDragged + 1 && i <= target) { newPos--; } else if (target < mLastDragged && i >= target && i < mLastDragged) { newPos++; } int oldPos = i; if (newPositions.get(i) != -1) { oldPos = newPositions.get(i); } if (oldPos == newPos) { continue; } // animate HcLog.D("animateGap from=" + oldPos + ", to=" + newPos); final Rect oldRect = getRectByPosition(oldPos); final Rect newRect = getRectByPosition(newPos); oldRect.offset(-v.getLeft(), -v.getTop()); newRect.offset(-v.getLeft(), -v.getTop()); TranslateAnimation translate = new TranslateAnimation(oldRect.left, newRect.left, oldRect.top, newRect.top); translate.setDuration(ANIMATION_DURATION); translate.setFillEnabled(true); translate.setFillAfter(true); v.clearAnimation(); v.startAnimation(translate); newPositions.set(i, newPos); } }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
private void animateGroupListItemsInternal(Map<MediaRouter.RouteInfo, Rect> previousRouteBoundMap, Map<MediaRouter.RouteInfo, BitmapDrawable> previousRouteBitmapMap) { if (mGroupMemberRoutesAdded == null || mGroupMemberRoutesRemoved == null) { return;/*from www .j a v a 2 s . co m*/ } int groupSizeDelta = mGroupMemberRoutesAdded.size() - mGroupMemberRoutesRemoved.size(); boolean listenerRegistered = false; Animation.AnimationListener listener = new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mVolumeGroupList.startAnimationAll(); mVolumeGroupList.postDelayed(mGroupListFadeInAnimation, mGroupListAnimationDurationMs); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }; // Animate visible items from previous positions to current positions except routes added // just before. Added routes will remain hidden until translate animation finishes. int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); Rect previousBounds = previousRouteBoundMap.get(route); int currentTop = view.getTop(); int previousTop = previousBounds != null ? previousBounds.top : (currentTop + mVolumeGroupListItemHeight * groupSizeDelta); AnimationSet animSet = new AnimationSet(true); if (mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) { previousTop = currentTop; Animation alphaAnim = new AlphaAnimation(0.0f, 0.0f); alphaAnim.setDuration(mGroupListFadeInDurationMs); animSet.addAnimation(alphaAnim); } Animation translationAnim = new TranslateAnimation(0, 0, previousTop - currentTop, 0); translationAnim.setDuration(mGroupListAnimationDurationMs); animSet.addAnimation(translationAnim); animSet.setFillAfter(true); animSet.setFillEnabled(true); animSet.setInterpolator(mInterpolator); if (!listenerRegistered) { listenerRegistered = true; animSet.setAnimationListener(listener); } view.clearAnimation(); view.startAnimation(animSet); previousRouteBoundMap.remove(route); previousRouteBitmapMap.remove(route); } // If a member route doesn't exist any longer, it can be either removed or moved out of the // ListView layout boundary. In this case, use the previously captured bitmaps for // animation. for (Map.Entry<MediaRouter.RouteInfo, BitmapDrawable> item : previousRouteBitmapMap.entrySet()) { final MediaRouter.RouteInfo route = item.getKey(); final BitmapDrawable bitmap = item.getValue(); final Rect bounds = previousRouteBoundMap.get(route); OverlayObject object = null; if (mGroupMemberRoutesRemoved.contains(route)) { object = new OverlayObject(bitmap, bounds).setAlphaAnimation(1.0f, 0.0f) .setDuration(mGroupListFadeOutDurationMs).setInterpolator(mInterpolator); } else { int deltaY = groupSizeDelta * mVolumeGroupListItemHeight; object = new OverlayObject(bitmap, bounds).setTranslateYAnimation(deltaY) .setDuration(mGroupListAnimationDurationMs).setInterpolator(mInterpolator) .setAnimationEndListener(new OverlayObject.OnAnimationEndListener() { @Override public void onAnimationEnd() { mGroupMemberRoutesAnimatingWithBitmap.remove(route); mVolumeGroupAdapter.notifyDataSetChanged(); } }); mGroupMemberRoutesAnimatingWithBitmap.add(route); } mVolumeGroupList.addOverlayObject(object); } }
From source file:com.juick.android.MessagesFragment.java
public void scrollToX(int scrollX, long duration) { currentScrollX = scrollX;//from ww w . ja v a2s .c o m final View frag = getActivity().findViewById(R.id.messagesfragment); TranslateAnimation ta = new TranslateAnimation(lastToXDelta != null ? lastToXDelta : 0, -scrollX, 0, 0); lastToXDelta = -scrollX; ta.setFillEnabled(true); ta.setDuration(duration); ta.setFillAfter(true); ta.setFillBefore(true); if (parent instanceof MainActivity) { final View navPanel = parent.findViewById(R.id.navigation_panel); navPanel.setVisibility(View.VISIBLE); } if (duration > 2) { ta.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } @Override public void onAnimationEnd(Animation animation) { if (mScrollState == SCROLL_STATE_SETTLING) { setScrollState(SCROLL_STATE_IDLE); frag.clearAnimation(); } } @Override public void onAnimationRepeat(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } }); } frag.startAnimation(ta); }
From source file:com.juick.android.MainActivity.java
public void openNavigationMenu(boolean animate) { if (isNavigationMenuShown()) return;/* w ww.j a v a2 s . co m*/ navigationMenuShown = true; final ViewGroup navigationPanel = (ViewGroup) findViewById(R.id.navigation_panel); navigationPanel.setVisibility(View.VISIBLE); final View frag = (ViewGroup) findViewById(R.id.messagesfragment); if (animate) { AnimationSet set = new AnimationSet(true); TranslateAnimation translate = new TranslateAnimation(0, navigationPanel.getWidth(), 0, 0); translate.setFillAfter(false); translate.setFillEnabled(true); translate.setDuration(400); set.addAnimation(translate); set.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } @Override public void onAnimationEnd(Animation animation) { frag.clearAnimation(); layoutNavigationPane(); } @Override public void onAnimationRepeat(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } }); frag.startAnimation(set); } else { layoutNavigationPane(); } }