List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:com.ludoscity.findmybikes.activities.NearbyActivity.java
private void hideSetupShowTripDetailsWidget() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Animator hideAnimator = buildTripDetailsWidgetAnimators(false, getResources().getInteger(R.integer.camera_animation_duration) / 2, .23f); hideAnimator.addListener(new AnimatorListenerAdapter() { @Override/*from w w w .j ava 2 s . c om*/ public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); try { setupTripDetailsWidget(); buildTripDetailsWidgetAnimators(true, getResources().getInteger(R.integer.camera_animation_duration) / 2, .23f).start(); } catch (IllegalStateException e) { Log.i("NearbyActivity", "Trip widget hide animation end encountered some trouble, skipping", e); } } }); hideAnimator.start(); } else { setupTripDetailsWidget(); } }
From source file:com.ludoscity.findmybikes.activities.NearbyActivity.java
private void hideTripDetailsWidget() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Animator hideAnimator = buildTripDetailsWidgetAnimators(false, getResources().getInteger(R.integer.camera_animation_duration), 0); // make the view invisible when the animation is done hideAnimator.addListener(new AnimatorListenerAdapter() { @Override//from w w w .j a v a2 s .c om public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mTripDetailsWidget.setVisibility(View.INVISIBLE); } }); hideAnimator.start(); } else mTripDetailsWidget.setVisibility(View.INVISIBLE); }
From source file:com.android.soma.Launcher.java
/** * Zoom the camera back into the workspace, hiding 'fromView'. * This is the opposite of showAppsCustomizeHelper. * @param animated If true, the transition will be animated. *//*from w w w. j a v a 2 s . c om*/ private void hideAppsCustomizeHelper(Workspace.State toState, final boolean animated, final boolean springLoaded, final Runnable onCompleteRunnable) { if (mStateAnimation != null) { mStateAnimation.setDuration(0); mStateAnimation.cancel(); mStateAnimation = null; } Resources res = getResources(); final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime); final int fadeOutDuration = res.getInteger(R.integer.config_appsCustomizeFadeOutTime); final float scaleFactor = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mAppsCustomizeTabHost; final View toView = mWorkspace; Animator workspaceAnim = null; if (toState == Workspace.State.NORMAL) { int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger); workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, stagger, -1); } else if (toState == Workspace.State.SPRING_LOADED || toState == Workspace.State.OVERVIEW) { workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated); } setPivotsForZoom(fromView, scaleFactor); showHotseat(animated); if (animated) { final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(fromView); scaleAnim.scaleX(scaleFactor).scaleY(scaleFactor).setDuration(duration) .setInterpolator(new Workspace.ZoomInInterpolator()); final ObjectAnimator alphaAnim = LauncherAnimUtils.ofFloat(fromView, "alpha", 1f, 0f) .setDuration(fadeOutDuration); alphaAnim.setInterpolator(new AccelerateDecelerateInterpolator()); alphaAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float t = 1f - (Float) animation.getAnimatedValue(); dispatchOnLauncherTransitionStep(fromView, t); dispatchOnLauncherTransitionStep(toView, t); } }); mStateAnimation = LauncherAnimUtils.createAnimatorSet(); dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); mAppsCustomizeContent.pauseScrolling(); mStateAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); if (onCompleteRunnable != null) { onCompleteRunnable.run(); } mAppsCustomizeContent.updateCurrentPageScroll(); mAppsCustomizeContent.resumeScrolling(); } }); mStateAnimation.playTogether(scaleAnim, alphaAnim); if (workspaceAnim != null) { mStateAnimation.play(workspaceAnim); } dispatchOnLauncherTransitionStart(fromView, animated, true); dispatchOnLauncherTransitionStart(toView, animated, true); LauncherAnimUtils.startAnimationAfterNextDraw(mStateAnimation, toView); } else { fromView.setVisibility(View.GONE); dispatchOnLauncherTransitionPrepare(fromView, animated, true); dispatchOnLauncherTransitionStart(fromView, animated, true); dispatchOnLauncherTransitionEnd(fromView, animated, true); dispatchOnLauncherTransitionPrepare(toView, animated, true); dispatchOnLauncherTransitionStart(toView, animated, true); dispatchOnLauncherTransitionEnd(toView, animated, true); } }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
private void shrinkAndFadeInFolderIcon(final FolderIcon fi) { if (fi == null) return;/*from ww w. ja va 2 s .c o m*/ PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); final CellLayout cl = (CellLayout) fi.getParent().getParent(); // We remove and re-draw the FolderIcon in-case it has changed mDragLayer.removeView(mFolderIconImageView); copyFolderIconToImage(fi); ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(mFolderIconImageView, alpha, scaleX, scaleY); oa.setDuration(getResources().getInteger(R.integer.config_folderExpandDuration)); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (cl != null) { cl.clearFolderLeaveBehind(); // Remove the ImageView copy of the FolderIcon and make the original visible. mDragLayer.removeView(mFolderIconImageView); fi.setVisibility(View.VISIBLE); } } }); oa.start(); }
From source file:com.android.launcher3.Launcher.java
private void shrinkAndFadeInFolderIcon(final FolderIcon fi, boolean animate) { if (fi == null) return;//from w ww . j av a2 s .com final CellLayout cl = (CellLayout) fi.getParent().getParent(); // We remove and re-draw the FolderIcon in-case it has changed mDragLayer.removeView(mFolderIconImageView); copyFolderIconToImage(fi); if (cl != null) { cl.clearFolderLeaveBehind(); } ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(mFolderIconImageView, 1, 1, 1); oa.setDuration(getResources().getInteger(R.integer.config_folderExpandDuration)); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (cl != null) { // Remove the ImageView copy of the FolderIcon and make the original visible. mDragLayer.removeView(mFolderIconImageView); fi.setVisibility(View.VISIBLE); } } }); oa.start(); if (!animate) { oa.end(); } }
From source file:com.android.launcher2.Launcher.java
/** * Runs a new animation that scales up icons that were added while Launcher was in the * background./*from w w w. j ava2 s . com*/ * * @param immediate whether to run the animation or show the results immediately */ private void runNewAppsAnimation(boolean immediate) { AnimatorSet anim = LauncherAnimUtils.createAnimatorSet(); Collection<Animator> bounceAnims = new ArrayList<Animator>(); // Order these new views spatially so that they animate in order Collections.sort(mNewShortcutAnimateViews, new Comparator<View>() { @Override public int compare(View a, View b) { CellLayout.LayoutParams alp = (CellLayout.LayoutParams) a.getLayoutParams(); CellLayout.LayoutParams blp = (CellLayout.LayoutParams) b.getLayoutParams(); int cellCountX = LauncherModel.getCellCountX(); return (alp.cellY * cellCountX + alp.cellX) - (blp.cellY * cellCountX + blp.cellX); } }); // Animate each of the views in place (or show them immediately if requested) if (immediate) { for (View v : mNewShortcutAnimateViews) { v.setAlpha(1f); v.setScaleX(1f); v.setScaleY(1f); } } else { for (int i = 0; i < mNewShortcutAnimateViews.size(); ++i) { View v = mNewShortcutAnimateViews.get(i); ValueAnimator bounceAnim = LauncherAnimUtils.ofPropertyValuesHolder(v, PropertyValuesHolder.ofFloat("alpha", 1f), PropertyValuesHolder.ofFloat("scaleX", 1f), PropertyValuesHolder.ofFloat("scaleY", 1f)); bounceAnim.setDuration(InstallShortcutReceiver.NEW_SHORTCUT_BOUNCE_DURATION); bounceAnim.setStartDelay(i * InstallShortcutReceiver.NEW_SHORTCUT_STAGGER_DELAY); bounceAnim.setInterpolator(new SmoothPagedView.OvershootInterpolator()); bounceAnims.add(bounceAnim); } anim.playTogether(bounceAnims); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mWorkspace != null) { mWorkspace.postDelayed(mBuildLayersRunnable, 500); } } }); anim.start(); } // Clean up mNewShortcutAnimatePage = -1; mNewShortcutAnimateViews.clear(); new Thread("clearNewAppsThread") { public void run() { mSharedPrefs.edit().putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1) .putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY, null).commit(); } }.start(); }
From source file:com.android.launcher2.Launcher.java
private void dismissCling(final Cling cling, final String flag, int duration) { // To catch cases where siblings of top-level views are made invisible, just check whether // the cling is directly set to GONE before dismissing it. if (cling != null && cling.getVisibility() != View.GONE) { ObjectAnimator anim = LauncherAnimUtils.ofFloat(cling, "alpha", 0f); anim.setDuration(duration);//from w w w . j av a 2 s .com anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { cling.setVisibility(View.GONE); cling.cleanup(); // We should update the shared preferences on a background thread new Thread("dismissClingThread") { public void run() { SharedPreferences.Editor editor = mSharedPrefs.edit(); editor.putBoolean(flag, true); editor.commit(); } }.start(); }; }); anim.start(); mHideFromAccessibilityHelper.restoreImportantForAccessibility(mDragLayer); } }
From source file:com.gxapplications.android.gxsuite.launcher.Launcher.java
private void dismissCling(final Cling cling, final String flag, int duration) { if (cling != null && cling.getVisibility() == View.VISIBLE) { ObjectAnimator anim = LauncherAnimUtils.ofFloat(cling, "alpha", 0f); anim.setDuration(duration);//from ww w .j av a 2 s . com anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { cling.setVisibility(View.GONE); cling.cleanup(); // We should update the shared preferences on a background thread new Thread("dismissClingThread") { public void run() { SharedPreferences.Editor editor = mSharedPrefs.edit(); editor.putBoolean(flag, true); editor.commit(); } }.start(); }; }); anim.start(); mHideFromAccessibilityHelper.restoreImportantForAccessibility(mDragLayer); } }
From source file:com.android.soma.Launcher.java
private void setCustomContentHintVisibility(Cling cling, String ccHintStr, boolean visible, boolean animate) { final TextView ccHint = (TextView) cling.findViewById(R.id.custom_content_hint); if (ccHint != null) { if (visible && !ccHintStr.isEmpty()) { ccHint.setText(ccHintStr);// w w w . j a v a 2s . c om ccHint.setVisibility(View.VISIBLE); if (animate) { ccHint.setAlpha(0f); ccHint.animate().alpha(1f).setDuration(SHOW_CLING_DURATION).start(); } else { ccHint.setAlpha(1f); } } else { if (animate) { ccHint.animate().alpha(0f).setDuration(SHOW_CLING_DURATION) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ccHint.setVisibility(View.GONE); } }).start(); } else { ccHint.setAlpha(0f); ccHint.setVisibility(View.GONE); } } } }