Search in sources :

Example 46 with AnimationSet

use of android.view.animation.AnimationSet in project android_frameworks_base by crdroidandroid.

the class ListWithDisappearingItemBug method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Toast.makeText(this, "Make sure you rotate screen to see bug", Toast.LENGTH_LONG).show();
    // Get a cursor with all people
    Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
    startManagingCursor(c);
    ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view
    R.layout.list_with_disappearing_item_bug_item, // Give the cursor to the list adatper
    c, // Map the NAME column in the people database to...
    new String[] { People.NAME }, // The "text1" view defined in the XML template
    new int[] { R.id.text1 });
    setListAdapter(adapter);
    AnimationSet set = new AnimationSet(true);
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(50);
    set.addAnimation(animation);
    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(100);
    set.addAnimation(animation);
    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    ListView listView = getListView();
    listView.setLayoutAnimation(controller);
}
Also used : ListView(android.widget.ListView) SimpleCursorAdapter(android.widget.SimpleCursorAdapter) LayoutAnimationController(android.view.animation.LayoutAnimationController) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) Cursor(android.database.Cursor) AnimationSet(android.view.animation.AnimationSet) ListAdapter(android.widget.ListAdapter) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 47 with AnimationSet

use of android.view.animation.AnimationSet in project smartmodule by carozhu.

the class OptAnimationLoader method createAnimationFromXml.

private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException {
    Animation anim = null;
    // Make sure we are on a start tag.
    int type;
    int depth = parser.getDepth();
    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
        if (type != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("set")) {
            anim = new AnimationSet(c, attrs);
            createAnimationFromXml(c, parser, (AnimationSet) anim, attrs);
        } else if (name.equals("alpha")) {
            anim = new AlphaAnimation(c, attrs);
        } else if (name.equals("scale")) {
            anim = new ScaleAnimation(c, attrs);
        } else if (name.equals("rotate")) {
            anim = new RotateAnimation(c, attrs);
        } else if (name.equals("translate")) {
            anim = new TranslateAnimation(c, attrs);
        } else {
            try {
                anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs);
            } catch (Exception te) {
                throw new RuntimeException("Unknown animation name: " + parser.getName() + " error:" + te.getMessage());
            }
        }
        if (parent != null) {
            parent.addAnimation(anim);
        }
    }
    return anim;
}
Also used : Context(android.content.Context) RotateAnimation(android.view.animation.RotateAnimation) AttributeSet(android.util.AttributeSet) ScaleAnimation(android.view.animation.ScaleAnimation) RotateAnimation(android.view.animation.RotateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 48 with AnimationSet

use of android.view.animation.AnimationSet in project android_frameworks_base by crdroidandroid.

the class DragState method createCancelAnimationLocked.

private Animation createCancelAnimationLocked() {
    final AnimationSet set = new AnimationSet(false);
    set.addAnimation(new ScaleAnimation(1, 0, 1, 0, mThumbOffsetX, mThumbOffsetY));
    set.addAnimation(new AlphaAnimation(mOriginalAlpha, 0));
    set.setDuration(ANIMATION_DURATION_MS);
    set.setInterpolator(mCubicEaseOutInterpolator);
    set.initialize(0, 0, 0, 0);
    // Will start on the first call to getTransformation.
    set.start();
    return set;
}
Also used : AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 49 with AnimationSet

use of android.view.animation.AnimationSet in project android_frameworks_base by crdroidandroid.

the class AppTransition method createThumbnailScaleAnimationLocked.

/**
     * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
     * when a thumbnail is specified with the pending animation override.
     */
Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit, Bitmap thumbnailHeader) {
    Animation a;
    getDefaultNextAppTransitionStartRect(mTmpRect);
    final int thumbWidthI = thumbnailHeader.getWidth();
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = thumbnailHeader.getHeight();
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
    if (mNextAppTransitionScaleUp) {
        // Animation for the thumbnail zooming from its initial size to the full screen
        float scaleW = appWidth / thumbWidth;
        float scaleH = appHeight / thumbHeight;
        Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mTmpRect.left, 1 / scaleW), computePivot(mTmpRect.top, 1 / scaleH));
        scale.setInterpolator(mDecelerateInterpolator);
        Animation alpha = new AlphaAnimation(1, 0);
        alpha.setInterpolator(mThumbnailFadeOutInterpolator);
        // This AnimationSet uses the Interpolators assigned above.
        AnimationSet set = new AnimationSet(false);
        set.addAnimation(scale);
        set.addAnimation(alpha);
        a = set;
    } else {
        // Animation for the thumbnail zooming down from the full screen to its final size
        float scaleW = appWidth / thumbWidth;
        float scaleH = appHeight / thumbHeight;
        a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mTmpRect.left, 1 / scaleW), computePivot(mTmpRect.top, 1 / scaleH));
    }
    return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) WindowAnimation_wallpaperCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation) CurvedTranslateAnimation(com.android.server.wm.animation.CurvedTranslateAnimation) WindowAnimation_activityOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation) WindowAnimation_wallpaperOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation) WindowAnimation_taskToBackEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation) WindowAnimation_activityOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ClipRectAnimation(android.view.animation.ClipRectAnimation) WindowAnimation_wallpaperOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation) WindowAnimation_launchTaskBehindTargetAnimation(com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation) WindowAnimation_launchTaskBehindSourceAnimation(com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation) WindowAnimation_taskCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) WindowAnimation_wallpaperIntraCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation) WindowAnimation_taskToBackExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation) WindowAnimation_activityCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation) WindowAnimation_taskCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation) WindowAnimation_taskOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation) WindowAnimation_wallpaperIntraCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation) ClipRectTBAnimation(com.android.server.wm.animation.ClipRectTBAnimation) WindowAnimation_taskOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation) ClipRectLRAnimation(com.android.server.wm.animation.ClipRectLRAnimation) WindowAnimation_activityCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation) WindowAnimation_taskToFrontEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation) WindowAnimation_wallpaperIntraOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation) WindowAnimation_wallpaperIntraOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation) WindowAnimation_taskToFrontExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation) WindowAnimation_wallpaperCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 50 with AnimationSet

use of android.view.animation.AnimationSet in project android_frameworks_base by crdroidandroid.

the class AppTransition method createAspectScaledThumbnailFreeformAnimationLocked.

private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame, Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) {
    final float sourceWidth = sourceFrame.width();
    final float sourceHeight = sourceFrame.height();
    final float destWidth = destFrame.width();
    final float destHeight = destFrame.height();
    final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth;
    final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight;
    AnimationSet set = new AnimationSet(true);
    final int surfaceInsetsH = surfaceInsets == null ? 0 : surfaceInsets.left + surfaceInsets.right;
    final int surfaceInsetsV = surfaceInsets == null ? 0 : surfaceInsets.top + surfaceInsets.bottom;
    // We want the scaling to happen from the center of the surface. In order to achieve that,
    // we need to account for surface insets that will be used to enlarge the surface.
    final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2;
    final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2;
    final ScaleAnimation scale = enter ? new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter) : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter);
    final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2;
    final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2;
    final int destHCenter = destFrame.left + destFrame.width() / 2;
    final int destVCenter = destFrame.top + destFrame.height() / 2;
    final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter;
    final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter;
    final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0) : new TranslateAnimation(0, fromX, 0, fromY);
    set.addAnimation(scale);
    set.addAnimation(translation);
    final IRemoteCallback callback = mAnimationFinishedCallback;
    if (callback != null) {
        set.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, callback).sendToTarget();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
    }
    return set;
}
Also used : IRemoteCallback(android.os.IRemoteCallback) CurvedTranslateAnimation(com.android.server.wm.animation.CurvedTranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) WindowAnimation_wallpaperCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation) CurvedTranslateAnimation(com.android.server.wm.animation.CurvedTranslateAnimation) WindowAnimation_activityOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation) WindowAnimation_wallpaperOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation) WindowAnimation_taskToBackEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation) WindowAnimation_activityOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ClipRectAnimation(android.view.animation.ClipRectAnimation) WindowAnimation_wallpaperOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation) WindowAnimation_launchTaskBehindTargetAnimation(com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation) WindowAnimation_launchTaskBehindSourceAnimation(com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation) WindowAnimation_taskCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) WindowAnimation_wallpaperIntraCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation) WindowAnimation_taskToBackExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation) WindowAnimation_activityCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation) WindowAnimation_taskCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation) WindowAnimation_taskOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation) WindowAnimation_wallpaperIntraCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation) ClipRectTBAnimation(com.android.server.wm.animation.ClipRectTBAnimation) WindowAnimation_taskOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation) ClipRectLRAnimation(com.android.server.wm.animation.ClipRectLRAnimation) WindowAnimation_activityCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation) WindowAnimation_taskToFrontEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation) WindowAnimation_wallpaperIntraOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation) WindowAnimation_wallpaperIntraOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation) WindowAnimation_taskToFrontExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation) WindowAnimation_wallpaperCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation) AnimationSet(android.view.animation.AnimationSet) ScaleAnimation(android.view.animation.ScaleAnimation)

Aggregations

AnimationSet (android.view.animation.AnimationSet)118 AlphaAnimation (android.view.animation.AlphaAnimation)86 TranslateAnimation (android.view.animation.TranslateAnimation)75 Animation (android.view.animation.Animation)71 ScaleAnimation (android.view.animation.ScaleAnimation)69 ClipRectAnimation (android.view.animation.ClipRectAnimation)32 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)32 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)30 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)30 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)30 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)30 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)30 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)30 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)30 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)30 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)30 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)30 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)30 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)30 WindowAnimation_wallpaperCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation)30