use of android.animation.LayoutTransition in project android_frameworks_base by ParanoidAndroid.
the class RecentsVerticalScrollView method onSizeChanged.
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
// Skip this work if a transition is running; it sets the scroll values independently
// and should not have those animated values clobbered by this logic
LayoutTransition transition = mLinearLayout.getLayoutTransition();
if (transition != null && transition.isRunning()) {
return;
}
// Keep track of the last visible item in the list so we can restore it
// to the bottom when the orientation changes.
mLastScrollPosition = scrollPositionOfMostRecent();
// This has to happen post-layout, so run it "in the future"
post(new Runnable() {
public void run() {
// Make sure we're still not clobbering the transition-set values, since this
// runnable launches asynchronously
LayoutTransition transition = mLinearLayout.getLayoutTransition();
if (transition == null || !transition.isRunning()) {
scrollTo(0, mLastScrollPosition);
}
}
});
}
use of android.animation.LayoutTransition in project android_frameworks_base by ParanoidAndroid.
the class TabletStatusBar method makeStatusBarView.
protected View makeStatusBarView() {
final Context context = mContext;
CustomTheme currentTheme = mContext.getResources().getConfiguration().customTheme;
if (currentTheme != null) {
mCurrentTheme = (CustomTheme) currentTheme.clone();
}
loadDimens();
final TabletStatusBarView sb = (TabletStatusBarView) View.inflate(context, R.layout.system_bar, null);
mStatusBarView = sb;
sb.setHandler(mHandler);
try {
// bar on a tablet that has only the system bar
if (mWindowManagerService.hasNavigationBar()) {
Slog.e(TAG, "Tablet device cannot show navigation bar and system bar");
}
} catch (RemoteException ex) {
}
// Overload screen with views that literally do nothing, thank you Google
int[] dummyGravity = { Gravity.LEFT, Gravity.TOP, Gravity.RIGHT, Gravity.BOTTOM };
for (int i = 0; i < 4; i++) {
mPieDummyTrigger[i] = new View(mContext);
mWindowManager.addView(mPieDummyTrigger[i], getDummyTriggerLayoutParams(mContext, dummyGravity[i]));
}
// set recents activity navigation bar view
RecentsActivity.addNavigationCallback(this);
mBarContents = (ViewGroup) sb.findViewById(R.id.bar_contents);
// system bar clock
mClock = (Clock) mBarContents.findViewById(R.id.clock);
// the whole right-hand side of the bar
mNotificationArea = sb.findViewById(R.id.notificationArea);
mNotificationArea.setOnTouchListener(new NotificationTriggerTouchListener());
// the button to open the notification area
mNotificationTrigger = sb.findViewById(R.id.notificationTrigger);
// the more notifications icon
mNotificationIconArea = (NotificationIconArea) sb.findViewById(R.id.notificationIcons);
// where the icons go
mIconLayout = (NotificationIconArea.IconLayout) sb.findViewById(R.id.icons);
mNotificationPeekTapDuration = ViewConfiguration.getTapTimeout();
// px/s
mNotificationFlingVelocity = 300;
mTabletTicker = new TabletTicker(this);
// The icons
// will post a notification
mLocationController = new LocationController(mContext);
// watch the PREF_DO_NOT_DISTURB and convert to appropriate disable() calls
mDoNotDisturb = new DoNotDisturb(mContext);
mBatteryController = new BatteryController(mContext);
mBatteryController.addIconView((ImageView) sb.findViewById(R.id.battery));
mBluetoothController = new BluetoothController(mContext);
mBluetoothController.addIconView((ImageView) sb.findViewById(R.id.bluetooth));
mNetworkController = new NetworkController(mContext);
mSignalCluster = (SignalClusterView) sb.findViewById(R.id.signal_cluster);
mNetworkController.addSignalCluster(mSignalCluster);
mSignalCluster.setNetworkController(mNetworkController);
mBarView = (ViewGroup) mStatusBarView;
mHasDockBattery = mContext.getResources().getBoolean(com.android.internal.R.bool.config_hasDockBattery);
if (mHasDockBattery) {
mDockBatteryController = new DockBatteryController(mContext);
mDockBatteryController.addIconView((ImageView) sb.findViewById(R.id.dock_battery));
}
// The navigation buttons
mBackButton = (ImageView) sb.findViewById(R.id.back);
mNavigationArea = (ViewGroup) sb.findViewById(R.id.navigationArea);
mHomeButton = mNavigationArea.findViewById(R.id.home);
mMenuButton = mNavigationArea.findViewById(R.id.menu);
mRecentButton = mNavigationArea.findViewById(R.id.recent_apps);
if (Settings.System.getInt(context.getContentResolver(), Settings.System.NAV_BAR_TABUI_MENU, 0) == 1) {
MarginLayoutParams marginParams = new MarginLayoutParams(mMenuButton.getLayoutParams());
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams);
layoutParams.addRule(RelativeLayout.RIGHT_OF, R.id.recent_apps);
layoutParams.setMargins(-(context.getResources().getDimensionPixelSize(R.dimen.navigation_menu_key_width) / 3), 0, 0, 0);
mMenuButton.setLayoutParams(layoutParams);
((ImageView) mMenuButton).setImageDrawable(context.getResources().getDrawable(R.drawable.ic_sysbar_menu));
} else {
mRecentButton.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
((KeyButtonView) mMenuButton).sendEventSequence(new int[][] { new int[] { KeyEvent.ACTION_DOWN, KeyEvent.FLAG_CANCELED }, new int[] { KeyEvent.ACTION_UP, 0 } });
mButtonBusy = false;
return true;
}
});
}
mRecentButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (mButtonBusy) {
onClickRecentButton();
} else {
mButtonBusy = true;
}
}
});
LayoutTransition lt = new LayoutTransition();
lt.setDuration(250);
// don't wait for these transitions; we just want icons to fade in/out, not move around
lt.setDuration(LayoutTransition.CHANGE_APPEARING, 0);
lt.setDuration(LayoutTransition.CHANGE_DISAPPEARING, 0);
lt.addTransitionListener(new LayoutTransition.TransitionListener() {
public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
// ensure the menu button doesn't stick around on the status bar after it's been
// removed
mBarContents.invalidate();
}
public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
}
});
mNavigationArea.setLayoutTransition(lt);
// no multi-touch on the nav buttons
mNavigationArea.setMotionEventSplittingEnabled(false);
// The bar contents buttons
mFeedbackIconArea = (ViewGroup) sb.findViewById(R.id.feedbackIconArea);
mInputMethodSwitchButton = (InputMethodButton) sb.findViewById(R.id.imeSwitchButton);
// Overwrite the lister
mInputMethodSwitchButton.setOnClickListener(mOnClickListener);
mCompatModeButton = (CompatModeButton) sb.findViewById(R.id.compatModeButton);
mCompatModeButton.setOnClickListener(mOnClickListener);
mCompatModeButton.setVisibility(View.GONE);
// for redirecting errant bar taps to the IME
mFakeSpaceBar = sb.findViewById(R.id.fake_space_bar);
// "shadows" of the status bar features, for lights-out mode
mShadow = sb.findViewById(R.id.bar_shadow);
mShadow.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
// even though setting the systemUI visibility below will turn these views
// on, we need them to come up faster so that they can catch this motion
// event
mShadow.setVisibility(View.GONE);
mBarContents.setVisibility(View.VISIBLE);
try {
mBarService.setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE);
} catch (RemoteException ex) {
// system process dead
}
}
return false;
}
});
// tuning parameters
final int LIGHTS_GOING_OUT_SYSBAR_DURATION = 750;
final int LIGHTS_GOING_OUT_SHADOW_DURATION = 750;
final int LIGHTS_GOING_OUT_SHADOW_DELAY = 0;
final int LIGHTS_COMING_UP_SYSBAR_DURATION = 200;
// final int LIGHTS_COMING_UP_SYSBAR_DELAY = 50;
final int LIGHTS_COMING_UP_SHADOW_DURATION = 0;
LayoutTransition xition = new LayoutTransition();
xition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(null, "alpha", 0.5f, 1f));
xition.setDuration(LayoutTransition.APPEARING, LIGHTS_COMING_UP_SYSBAR_DURATION);
xition.setStartDelay(LayoutTransition.APPEARING, 0);
xition.setAnimator(LayoutTransition.DISAPPEARING, ObjectAnimator.ofFloat(null, "alpha", 1f, 0f));
xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_GOING_OUT_SYSBAR_DURATION);
xition.setStartDelay(LayoutTransition.DISAPPEARING, 0);
((ViewGroup) sb.findViewById(R.id.bar_contents_holder)).setLayoutTransition(xition);
xition = new LayoutTransition();
xition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(null, "alpha", 0f, 1f));
xition.setDuration(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DURATION);
xition.setStartDelay(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DELAY);
xition.setAnimator(LayoutTransition.DISAPPEARING, ObjectAnimator.ofFloat(null, "alpha", 1f, 0f));
xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_COMING_UP_SHADOW_DURATION);
xition.setStartDelay(LayoutTransition.DISAPPEARING, 0);
((ViewGroup) sb.findViewById(R.id.bar_shadow_holder)).setLayoutTransition(xition);
// set the initial view visibility
setAreThereNotifications();
// receive broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
filter.addAction(Intent.ACTION_SCREEN_OFF);
context.registerReceiver(mBroadcastReceiver, filter);
return sb;
}
use of android.animation.LayoutTransition in project android_frameworks_base by ParanoidAndroid.
the class RenderSessionImpl method moveChild.
/**
* Moves a view to a new parent at a given location
* <p>
* {@link #acquire(long)} must have been called before this.
*
* @throws IllegalStateException if the current context is different than the one owned by
* the scene, or if {@link #acquire(long)} was not called.
*
* @see RenderSession#moveChild(Object, Object, int, Map, IAnimationListener)
*/
public Result moveChild(final ViewGroup newParentView, final View childView, final int index, Map<String, String> layoutParamsMap, final IAnimationListener listener) {
checkLock();
invalidateRenderingSize();
LayoutParams layoutParams = null;
if (layoutParamsMap != null) {
// need to create a new LayoutParams object for the new parent.
layoutParams = newParentView.generateLayoutParams(new BridgeLayoutParamsMapAttributes(layoutParamsMap));
}
// get the current parent of the view that needs to be moved.
final ViewGroup previousParent = (ViewGroup) childView.getParent();
if (listener != null) {
final LayoutParams params = layoutParams;
// parent views are different we fake the animation through a no animation thread.
if (previousParent != newParentView) {
new Thread("not animated moveChild") {
@Override
public void run() {
Result result = moveView(previousParent, newParentView, childView, index, params);
if (result.isSuccess() == false) {
listener.done(result);
}
// ready to do the work, acquire the scene.
result = acquire(250);
if (result.isSuccess() == false) {
listener.done(result);
return;
}
try {
result = render(false);
if (result.isSuccess()) {
listener.onNewFrame(RenderSessionImpl.this.getSession());
}
} finally {
release();
}
listener.done(result);
}
}.start();
} else {
new AnimationThread(this, "moveChild", listener) {
@Override
public Result preAnimation() {
// set up the transition for the parent.
LayoutTransition transition = new LayoutTransition();
previousParent.setLayoutTransition(transition);
// tweak the animation durations and start delays (to match the duration of
// animation playing just before).
// Note: Cannot user Animation.setDuration() directly. Have to set it
// on the LayoutTransition.
transition.setDuration(LayoutTransition.DISAPPEARING, 100);
// CHANGE_DISAPPEARING plays after DISAPPEARING
transition.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 100);
transition.setDuration(LayoutTransition.CHANGE_DISAPPEARING, 100);
transition.setDuration(LayoutTransition.CHANGE_APPEARING, 100);
// CHANGE_APPEARING plays after CHANGE_APPEARING
transition.setStartDelay(LayoutTransition.APPEARING, 100);
transition.setDuration(LayoutTransition.APPEARING, 100);
return moveView(previousParent, newParentView, childView, index, params);
}
@Override
public void postAnimation() {
previousParent.setLayoutTransition(null);
newParentView.setLayoutTransition(null);
}
}.start();
}
// always return success since the real status will come through the listener.
return SUCCESS.createResult(layoutParams);
}
Result result = moveView(previousParent, newParentView, childView, index, layoutParams);
if (result.isSuccess() == false) {
return result;
}
result = render(false);
if (layoutParams != null && result.isSuccess()) {
result = result.getCopyWithData(layoutParams);
}
return result;
}
use of android.animation.LayoutTransition in project android_frameworks_base by ParanoidAndroid.
the class RenderSessionImpl method removeChild.
/**
* Removes a child from its current parent.
* <p>
* {@link #acquire(long)} must have been called before this.
*
* @throws IllegalStateException if the current context is different than the one owned by
* the scene, or if {@link #acquire(long)} was not called.
*
* @see RenderSession#removeChild(Object, IAnimationListener)
*/
public Result removeChild(final View childView, IAnimationListener listener) {
checkLock();
invalidateRenderingSize();
final ViewGroup parent = (ViewGroup) childView.getParent();
if (listener != null) {
new AnimationThread(this, "moveChild", listener) {
@Override
public Result preAnimation() {
parent.setLayoutTransition(new LayoutTransition());
return removeView(parent, childView);
}
@Override
public void postAnimation() {
parent.setLayoutTransition(null);
}
}.start();
// always return success since the real status will come through the listener.
return SUCCESS.createResult();
}
Result result = removeView(parent, childView);
if (result.isSuccess() == false) {
return result;
}
return render(false);
}
use of android.animation.LayoutTransition in project platform_frameworks_base by android.
the class MLand method setScoreFieldHolder.
public void setScoreFieldHolder(ViewGroup vg) {
mScoreFields = vg;
if (vg != null) {
final LayoutTransition lt = new LayoutTransition();
lt.setDuration(250);
mScoreFields.setLayoutTransition(lt);
}
for (Player p : mPlayers) {
mScoreFields.addView(p.mScoreField, new MarginLayoutParams(MarginLayoutParams.WRAP_CONTENT, MarginLayoutParams.MATCH_PARENT));
}
}
Aggregations