Example usage for android.view.animation AnimationSet setFillAfter

List of usage examples for android.view.animation AnimationSet setFillAfter

Introduction

In this page you can find the example usage for android.view.animation AnimationSet setFillAfter.

Prototype

@Override
    public void setFillAfter(boolean fillAfter) 

Source Link

Usage

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;
        }// ww w .  j a  v  a2  s. 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.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);/*from ww w  .  j a  va  2s .c om*/
        animSet.addAnimation(alpha);
        animSet.setFillEnabled(true);
        animSet.setFillAfter(true);

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

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  av a  2 s  .c  o  m*/
        animSet.addAnimation(alpha);
        animSet.setFillEnabled(true);
        animSet.setFillAfter(true);

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

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

public synchronized void endImgLoad(ImgFileIO status, String resMessage, final Bitmap bitmap, final int index,
        final int fresh) {
    showErrorLog("endImageLoad : index : " + index + " ---- //");
    boolean isContinue = true;
    switch (status) {
    case InterruptError:
        toastFormThread(Table.ERROR_INTERRUPTED + " while loading image.");
        isContinue = false;//from  ww w.j  av a  2s . co  m
        break;
    case HttpCodeError:
        toastFormThread(Table.ERROR_HTTP_CODE + " while loading image. Http Response: " + resMessage);
        isContinue = false;
        break;
    case FileMalformedError:
        toastFormThread(Table.ERROR_MALFORMED_URL + " while loading image.");
        isContinue = false;
        break;
    case ClientProtocolError:
        toastFormThread(Table.ERROR_CLIENT_PROTOCOL + " while loading image.");
        isContinue = false;
        break;
    case FileIOError:
        toastFormThread(Table.ERROR_IO + " while loading image.");
        isContinue = false;
        break;
    case FileCloserror:
        toastFormThread(Table.ERROR_FILE_CLOSE + " while loading image.");
        isContinue = false;
    }
    if (!isContinue)
        return;
    if (bitmap == null) {
        toastFormThread(Table.ERROR_IMAGE_NULL + " while loading image. Http Response: " + resMessage + " (No. "
                + index + ")");
        //return;
    }

    // CONTINUE
    this.handler.post(new Runnable() {
        public void run() {
            ImageButton image = (ImageButton) mRootView.findViewById(imageViews[index]);
            image.setImageBitmap(bitmap);

            if (bitmap != null) {
                AnimationSet set = new AnimationSet(true);

                AlphaAnimation alpha;
                switch (fresh) {
                case 1:
                case 2:
                    alpha = new AlphaAnimation(0.0f, 0.8f);
                    break;
                case 3:
                case 4:
                    alpha = new AlphaAnimation(0.0f, 0.6f);
                    break;
                case 5:
                case 6:
                    alpha = new AlphaAnimation(0.0f, 0.4f);
                    break;
                case 7:
                    alpha = new AlphaAnimation(0.0f, 0.2f);
                    break;
                default:
                    alpha = new AlphaAnimation(0.0f, 1.0f);
                }
                set.addAnimation(alpha);
                set.setDuration(500);
                set.setFillAfter(true);

                image.startAnimation(set);
            }
        }
    });
}

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/* www.  ja v a2 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: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;/* w ww.j  av  a2  s .c o 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.icloud.listenbook.base.view.DraggableGridViewPager.java

/***
 * ?/*from w  w  w . j  a v  a 2  s .com*/
 * **/
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:androidx.mediarouter.app.MediaRouteControllerDialog.java

void animateGroupListItemsInternal(Map<MediaRouter.RouteInfo, Rect> previousRouteBoundMap,
        Map<MediaRouter.RouteInfo, BitmapDrawable> previousRouteBitmapMap) {
    if (mGroupMemberRoutesAdded == null || mGroupMemberRoutesRemoved == null) {
        return;/*from   w w  w . java 2s.c  o 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);
        OverlayListView.OverlayObject object = null;
        if (mGroupMemberRoutesRemoved.contains(route)) {
            object = new OverlayListView.OverlayObject(bitmap, bounds).setAlphaAnimation(1.0f, 0.0f)
                    .setDuration(mGroupListFadeOutDurationMs).setInterpolator(mInterpolator);
        } else {
            int deltaY = groupSizeDelta * mVolumeGroupListItemHeight;
            object = new OverlayListView.OverlayObject(bitmap, bounds).setTranslateYAnimation(deltaY)
                    .setDuration(mGroupListAnimationDurationMs).setInterpolator(mInterpolator)
                    .setAnimationEndListener(new OverlayListView.OverlayObject.OnAnimationEndListener() {
                        @Override
                        public void onAnimationEnd() {
                            mGroupMemberRoutesAnimatingWithBitmap.remove(route);
                            mVolumeGroupAdapter.notifyDataSetChanged();
                        }
                    });
            mGroupMemberRoutesAnimatingWithBitmap.add(route);
        }
        mVolumeGroupList.addOverlayObject(object);
    }
}