use of android.view.animation.AlphaAnimation in project glitch-hq-android by tinyspeck.
the class Util method startAlphaAnimation.
public static void startAlphaAnimation(View v, int duration, float from, float to, int repeatCount) {
AlphaAnimation animation = new AlphaAnimation(from, to);
animation.setDuration(duration);
animation.setRepeatMode(TranslateAnimation.REVERSE);
animation.setRepeatCount(repeatCount);
v.startAnimation(animation);
}
use of android.view.animation.AlphaAnimation in project platform_frameworks_base by android.
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);
}
use of android.view.animation.AlphaAnimation in project platform_frameworks_base by android.
the class WindowAnimator method updateWindowsLocked.
private void updateWindowsLocked(final int displayId) {
++mAnimTransactionSequence;
final WindowList windows = mService.getWindowListLocked(displayId);
final boolean keyguardGoingAwayToShade = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_TO_SHADE) != 0;
final boolean keyguardGoingAwayNoAnimation = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS) != 0;
final boolean keyguardGoingAwayWithWallpaper = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER) != 0;
if (mKeyguardGoingAway) {
for (int i = windows.size() - 1; i >= 0; i--) {
WindowState win = windows.get(i);
if (!mPolicy.isKeyguardHostWindow(win.mAttrs)) {
continue;
}
final WindowStateAnimator winAnimator = win.mWinAnimator;
if ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
if (!winAnimator.mAnimating) {
if (DEBUG_KEYGUARD)
Slog.d(TAG, "updateWindowsLocked: creating delay animation");
// Create a new animation to delay until keyguard is gone on its own.
winAnimator.mAnimation = new AlphaAnimation(1.0f, 1.0f);
winAnimator.mAnimation.setDuration(KEYGUARD_ANIM_TIMEOUT_MS);
winAnimator.mAnimationIsEntrance = false;
winAnimator.mAnimationStartTime = -1;
winAnimator.mKeyguardGoingAwayAnimation = true;
winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
}
} else {
if (DEBUG_KEYGUARD)
Slog.d(TAG, "updateWindowsLocked: StatusBar is no longer keyguard");
mKeyguardGoingAway = false;
winAnimator.clearAnimation();
}
break;
}
}
mForceHiding = KEYGUARD_NOT_SHOWN;
boolean wallpaperInUnForceHiding = false;
boolean startingInUnForceHiding = false;
ArrayList<WindowStateAnimator> unForceHiding = null;
WindowState wallpaper = null;
final WallpaperController wallpaperController = mService.mWallpaperControllerLocked;
for (int i = windows.size() - 1; i >= 0; i--) {
WindowState win = windows.get(i);
WindowStateAnimator winAnimator = win.mWinAnimator;
final int flags = win.mAttrs.flags;
boolean canBeForceHidden = mPolicy.canBeForceHidden(win, win.mAttrs);
boolean shouldBeForceHidden = shouldForceHide(win);
if (winAnimator.hasSurface()) {
final boolean wasAnimating = winAnimator.mWasAnimating;
final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
winAnimator.mWasAnimating = nowAnimating;
orAnimating(nowAnimating);
if (DEBUG_WALLPAPER) {
Slog.v(TAG, win + ": wasAnimating=" + wasAnimating + ", nowAnimating=" + nowAnimating);
}
if (wasAnimating && !winAnimator.mAnimating && wallpaperController.isWallpaperTarget(win)) {
mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
setPendingLayoutChanges(Display.DEFAULT_DISPLAY, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
if (DEBUG_LAYOUT_REPEATS) {
mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 2", getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
}
}
if (mPolicy.isForceHiding(win.mAttrs)) {
if (!wasAnimating && nowAnimating) {
if (DEBUG_KEYGUARD || DEBUG_ANIM || DEBUG_VISIBILITY)
Slog.v(TAG, "Animation started that could impact force hide: " + win);
mBulkUpdateParams |= SET_FORCE_HIDING_CHANGED;
setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
if (DEBUG_LAYOUT_REPEATS) {
mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 3", getPendingLayoutChanges(displayId));
}
mService.mFocusMayChange = true;
} else if (mKeyguardGoingAway && !nowAnimating) {
// Timeout!!
Slog.e(TAG, "Timeout waiting for animation to startup");
mPolicy.startKeyguardExitAnimation(0, 0);
mKeyguardGoingAway = false;
}
if (win.isReadyForDisplay()) {
if (nowAnimating && win.mWinAnimator.mKeyguardGoingAwayAnimation) {
mForceHiding = KEYGUARD_ANIMATING_OUT;
} else {
mForceHiding = win.isDrawnLw() ? KEYGUARD_SHOWN : KEYGUARD_NOT_SHOWN;
}
}
if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
Slog.v(TAG, "Force hide " + forceHidingToString() + " hasSurface=" + win.mHasSurface + " policyVis=" + win.mPolicyVisibility + " destroying=" + win.mDestroying + " attHidden=" + win.mAttachedHidden + " vis=" + win.mViewVisibility + " hidden=" + win.mRootToken.hidden + " anim=" + win.mWinAnimator.mAnimation);
} else if (canBeForceHidden) {
if (shouldBeForceHidden) {
if (!win.hideLw(false, false)) {
// Was already hidden
continue;
}
if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
Slog.v(TAG, "Now policy hidden: " + win);
} else {
boolean applyExistingExitAnimation = mPostKeyguardExitAnimation != null && !mPostKeyguardExitAnimation.hasEnded() && !winAnimator.mKeyguardGoingAwayAnimation && win.hasDrawnLw() && win.mAttachedWindow == null && !win.mIsImWindow && displayId == Display.DEFAULT_DISPLAY;
// Keyguard exit animation, skip.
if (!win.showLw(false, false) && !applyExistingExitAnimation) {
continue;
}
final boolean visibleNow = win.isVisibleNow();
if (!visibleNow) {
// Couldn't really show, must showLw() again when win becomes visible.
win.hideLw(false, false);
continue;
}
if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
Slog.v(TAG, "Now policy shown: " + win);
if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 && win.mAttachedWindow == null) {
if (unForceHiding == null) {
unForceHiding = new ArrayList<>();
}
unForceHiding.add(winAnimator);
if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
wallpaperInUnForceHiding = true;
}
if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
startingInUnForceHiding = true;
}
} else if (applyExistingExitAnimation) {
// animation to bring in this window.
if (DEBUG_KEYGUARD)
Slog.v(TAG, "Applying existing Keyguard exit animation to new window: win=" + win);
Animation a = mPolicy.createForceHideEnterAnimation(false, keyguardGoingAwayToShade);
winAnimator.setAnimation(a, mPostKeyguardExitAnimation.getStartTime(), STACK_CLIP_BEFORE_ANIM);
winAnimator.mKeyguardGoingAwayAnimation = true;
winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
}
final WindowState currentFocus = mService.mCurrentFocus;
if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
// sure it is correct.
if (DEBUG_FOCUS_LIGHT)
Slog.v(TAG, "updateWindowsLocked: setting mFocusMayChange true");
mService.mFocusMayChange = true;
}
}
if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
setPendingLayoutChanges(Display.DEFAULT_DISPLAY, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
if (DEBUG_LAYOUT_REPEATS) {
mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 4", getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
}
}
}
} else // policy visibility.
if (canBeForceHidden) {
if (shouldBeForceHidden) {
win.hideLw(false, false);
} else {
win.showLw(false, false);
}
}
final AppWindowToken atoken = win.mAppToken;
if (winAnimator.mDrawState == READY_TO_SHOW) {
if (atoken == null || atoken.allDrawn) {
if (winAnimator.performShowLocked()) {
setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
if (DEBUG_LAYOUT_REPEATS) {
mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 5", getPendingLayoutChanges(displayId));
}
}
}
}
final AppWindowAnimator appAnimator = winAnimator.mAppAnimator;
if (appAnimator != null && appAnimator.thumbnail != null) {
if (appAnimator.thumbnailTransactionSeq != mAnimTransactionSequence) {
appAnimator.thumbnailTransactionSeq = mAnimTransactionSequence;
appAnimator.thumbnailLayer = 0;
}
if (appAnimator.thumbnailLayer < winAnimator.mAnimLayer) {
appAnimator.thumbnailLayer = winAnimator.mAnimLayer;
}
}
if (win.mIsWallpaper) {
wallpaper = win;
}
}
// disabled.
if (unForceHiding != null) {
if (!keyguardGoingAwayNoAnimation) {
boolean first = true;
for (int i = unForceHiding.size() - 1; i >= 0; i--) {
final WindowStateAnimator winAnimator = unForceHiding.get(i);
Animation a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding && !startingInUnForceHiding, keyguardGoingAwayToShade);
if (a != null) {
if (DEBUG_KEYGUARD)
Slog.v(TAG, "Starting keyguard exit animation on window " + winAnimator.mWin);
winAnimator.setAnimation(a, STACK_CLIP_BEFORE_ANIM);
winAnimator.mKeyguardGoingAwayAnimation = true;
winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
if (first) {
mPostKeyguardExitAnimation = a;
mPostKeyguardExitAnimation.setStartTime(mCurrentTime);
first = false;
}
}
}
} else if (mKeyguardGoingAway) {
mPolicy.startKeyguardExitAnimation(mCurrentTime, 0);
mKeyguardGoingAway = false;
}
// Wallpaper is going away in un-force-hide motion, animate it as well.
if (!wallpaperInUnForceHiding && wallpaper != null && !keyguardGoingAwayNoAnimation) {
if (DEBUG_KEYGUARD)
Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
Animation a = mPolicy.createForceHideWallpaperExitAnimation(keyguardGoingAwayToShade);
if (a != null) {
wallpaper.mWinAnimator.setAnimation(a);
}
}
}
if (mPostKeyguardExitAnimation != null) {
// We're in the midst of a keyguard exit animation.
if (mKeyguardGoingAway) {
mPolicy.startKeyguardExitAnimation(mCurrentTime + mPostKeyguardExitAnimation.getStartOffset(), mPostKeyguardExitAnimation.getDuration());
mKeyguardGoingAway = false;
} else // ended normally and cancelled case, and check the time for the "orphaned" case.
if (mPostKeyguardExitAnimation.hasEnded() || mCurrentTime - mPostKeyguardExitAnimation.getStartTime() > mPostKeyguardExitAnimation.getDuration()) {
// Done with the animation, reset.
if (DEBUG_KEYGUARD)
Slog.v(TAG, "Done with Keyguard exit animations.");
mPostKeyguardExitAnimation = null;
}
}
final WindowState winShowWhenLocked = (WindowState) mPolicy.getWinShowWhenLockedLw();
if (winShowWhenLocked != null) {
mLastShowWinWhenLocked = winShowWhenLocked;
}
}
use of android.view.animation.AlphaAnimation in project androidquery by androidquery.
the class BitmapAjaxCallback method setBmAnimate.
private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation, float ratio, float anchor, int source) {
bm = filter(iv, bm, fallback);
if (bm == null) {
iv.setImageBitmap(null);
return;
}
Drawable d = makeDrawable(iv, bm, ratio, anchor);
Animation anim = null;
if (fadeIn(animation, source)) {
if (preset == null) {
anim = new AlphaAnimation(0, 1);
anim.setInterpolator(new DecelerateInterpolator());
anim.setDuration(FADE_DUR);
} else {
Drawable pd = makeDrawable(iv, preset, ratio, anchor);
Drawable[] ds = new Drawable[] { pd, d };
TransitionDrawable td = new TransitionDrawable(ds);
td.setCrossFadeEnabled(true);
td.startTransition(FADE_DUR);
d = td;
}
} else if (animation > 0) {
anim = AnimationUtils.loadAnimation(iv.getContext(), animation);
}
iv.setImageDrawable(d);
if (anim != null) {
anim.setStartTime(AnimationUtils.currentAnimationTimeMillis());
iv.startAnimation(anim);
} else {
iv.setAnimation(null);
}
}
use of android.view.animation.AlphaAnimation in project platform_frameworks_base by android.
the class AppTransition method createThumbnailEnterExitAnimationLocked.
/**
* This animation is created when we are doing a thumbnail transition, for the activity that is
* leaving, and the activity that is entering.
*/
Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, Rect containingFrame, int transit, int taskId) {
final int appWidth = containingFrame.width();
final int appHeight = containingFrame.height();
Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId);
Animation a;
getDefaultNextAppTransitionStartRect(mTmpRect);
final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth;
final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight;
final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
switch(thumbTransitState) {
case THUMBNAIL_TRANSITION_ENTER_SCALE_UP:
{
// Entering app scales up with the thumbnail
float scaleW = thumbWidth / appWidth;
float scaleH = thumbHeight / appHeight;
a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mTmpRect.left, scaleW), computePivot(mTmpRect.top, scaleH));
break;
}
case THUMBNAIL_TRANSITION_EXIT_SCALE_UP:
{
// Exiting app while the thumbnail is scaling up should fade or stay in place
if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
// Fade out while bringing up selected activity. This keeps the
// current activity from showing through a launching wallpaper
// activity.
a = new AlphaAnimation(1, 0);
} else {
// noop animation
a = new AlphaAnimation(1, 1);
}
break;
}
case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN:
{
// Entering the other app, it should just be visible while we scale the thumbnail
// down above it
a = new AlphaAnimation(1, 1);
break;
}
case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN:
{
// Exiting the current app, the app should scale down with the thumbnail
float scaleW = thumbWidth / appWidth;
float scaleH = thumbHeight / appHeight;
Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mTmpRect.left, scaleW), computePivot(mTmpRect.top, scaleH));
Animation alpha = new AlphaAnimation(1, 0);
AnimationSet set = new AnimationSet(true);
set.addAnimation(scale);
set.addAnimation(alpha);
set.setZAdjustment(Animation.ZORDER_TOP);
a = set;
break;
}
default:
throw new RuntimeException("Invalid thumbnail transition state");
}
return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
}
Aggregations