use of android.animation.LayoutTransition in project platform_frameworks_base by android.
the class ViewGroup method setLayoutTransition.
/**
* Sets the LayoutTransition object for this ViewGroup. If the LayoutTransition object is
* not null, changes in layout which occur because of children being added to or removed from
* the ViewGroup will be animated according to the animations defined in that LayoutTransition
* object. By default, the transition object is null (so layout changes are not animated).
*
* <p>Replacing a non-null transition will cause that previous transition to be
* canceled, if it is currently running, to restore this container to
* its correct post-transition state.</p>
*
* @param transition The LayoutTransition object that will animated changes in layout. A value
* of <code>null</code> means no transition will run on layout changes.
* @attr ref android.R.styleable#ViewGroup_animateLayoutChanges
*/
public void setLayoutTransition(LayoutTransition transition) {
if (mTransition != null) {
LayoutTransition previousTransition = mTransition;
previousTransition.cancel();
previousTransition.removeTransitionListener(mLayoutTransitionListener);
}
mTransition = transition;
if (mTransition != null) {
mTransition.addTransitionListener(mLayoutTransitionListener);
}
}
use of android.animation.LayoutTransition in project SublimePicker by vikramkakkar.
the class SublimePicker method processOptions.
private void processOptions() {
if (mOptions.animateLayoutChanges()) {
// Basic Layout Change Animation(s)
LayoutTransition layoutTransition = new LayoutTransition();
if (SUtils.isApi_16_OrHigher()) {
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
}
setLayoutTransition(layoutTransition);
} else {
setLayoutTransition(null);
}
mDatePickerEnabled = mOptions.isDatePickerActive();
mTimePickerEnabled = mOptions.isTimePickerActive();
mRecurrencePickerEnabled = mOptions.isRecurrencePickerActive();
if (mDatePickerEnabled) {
//int[] dateParams = mOptions.getDateParams();
//mDatePicker.init(dateParams[0] /* year */,
// dateParams[1] /* month of year */,
// dateParams[2] /* day of month */,
// mOptions.canPickDateRange(),
// this);
mDatePicker.init(mOptions.getDateParams(), mOptions.canPickDateRange(), this);
long[] dateRange = mOptions.getDateRange();
if (dateRange[0] != /* min date */
Long.MIN_VALUE) {
mDatePicker.setMinDate(dateRange[0]);
}
if (dateRange[1] != /* max date */
Long.MIN_VALUE) {
mDatePicker.setMaxDate(dateRange[1]);
}
mDatePicker.setValidationCallback(this);
ivRecurrenceOptionsDP.setVisibility(mRecurrencePickerEnabled ? View.VISIBLE : View.GONE);
} else {
llMainContentHolder.removeView(mDatePicker);
mDatePicker = null;
}
if (mTimePickerEnabled) {
int[] timeParams = mOptions.getTimeParams();
mTimePicker.setCurrentHour(timeParams[0]);
mTimePicker.setCurrentMinute(timeParams[1]);
mTimePicker.setIs24HourView(mOptions.is24HourView());
mTimePicker.setValidationCallback(this);
ivRecurrenceOptionsTP.setVisibility(mRecurrencePickerEnabled ? View.VISIBLE : View.GONE);
} else {
llMainContentHolder.removeView(mTimePicker);
mTimePicker = null;
}
if (mDatePickerEnabled && mTimePickerEnabled) {
mButtonLayout.applyOptions(true, /* show switch button */
mButtonLayoutCallback);
} else {
mButtonLayout.applyOptions(false, /* hide switch button */
mButtonLayoutCallback);
}
if (!mDatePickerEnabled && !mTimePickerEnabled) {
removeView(llMainContentHolder);
llMainContentHolder = null;
mButtonLayout = null;
}
mCurrentRecurrenceOption = mOptions.getRecurrenceOption();
mRecurrenceRule = mOptions.getRecurrenceRule();
if (mRecurrencePickerEnabled) {
Calendar cal = mDatePickerEnabled ? mDatePicker.getSelectedDate().getStartDate() : SUtils.getCalendarForLocale(null, Locale.getDefault());
mSublimeRecurrencePicker.initializeData(mRepeatOptionSetListener, mCurrentRecurrenceOption, mRecurrenceRule, cal.getTimeInMillis());
} else {
removeView(mSublimeRecurrencePicker);
mSublimeRecurrencePicker = null;
}
mCurrentPicker = mOptions.getPickerToShow();
// Updated from 'updateDisplay()' when 'RecurrencePicker' is chosen
mHiddenPicker = SublimeOptions.Picker.INVALID;
}
use of android.animation.LayoutTransition in project android_frameworks_base by ParanoidAndroid.
the class SearchPanelView method show.
public void show(final boolean show, boolean animate) {
if (!show) {
final LayoutTransition transitioner = animate ? createLayoutTransitioner() : null;
((ViewGroup) mSearchTargetsContainer).setLayoutTransition(transitioner);
}
mShowing = show;
if (show) {
maybeSwapSearchIcon();
if (getVisibility() != View.VISIBLE) {
setVisibility(View.VISIBLE);
// Don't start the animation until we've created the layer, which is done
// right before we are drawn
mGlowPadView.suspendAnimations();
mGlowPadView.ping();
getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
vibrate();
}
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
} else {
setVisibility(View.INVISIBLE);
}
}
use of android.animation.LayoutTransition in project android_frameworks_base by ParanoidAndroid.
the class NavigationBarView method setDisabledFlags.
public void setDisabledFlags(int disabledFlags, boolean force) {
if (!force && mDisabledFlags == disabledFlags)
return;
mDisabledFlags = disabledFlags;
final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
final boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0) && ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);
final boolean disableSearch = ((disabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0);
if (SLIPPERY_WHEN_DISABLED) {
setSlippery(disableHome && disableRecent && disableBack && disableSearch);
}
if (!mScreenOn && mCurrentView != null) {
ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons);
LayoutTransition lt = navButtons == null ? null : navButtons.getLayoutTransition();
if (lt != null) {
lt.disableTransitionType(LayoutTransition.CHANGE_APPEARING | LayoutTransition.CHANGE_DISAPPEARING | LayoutTransition.APPEARING | LayoutTransition.DISAPPEARING);
}
}
setButtonWithTagVisibility(NavbarEditor.NAVBAR_BACK, disableBack ? View.INVISIBLE : View.VISIBLE);
setButtonWithTagVisibility(NavbarEditor.NAVBAR_HOME, disableHome ? View.INVISIBLE : View.VISIBLE);
setButtonWithTagVisibility(NavbarEditor.NAVBAR_RECENT, disableRecent ? View.INVISIBLE : View.VISIBLE);
setButtonWithTagVisibility(NavbarEditor.NAVBAR_RECENT, disableRecent ? View.INVISIBLE : View.VISIBLE);
setButtonWithTagVisibility(NavbarEditor.NAVBAR_ALWAYS_MENU, disableRecent ? View.INVISIBLE : View.VISIBLE);
setButtonWithTagVisibility(NavbarEditor.NAVBAR_MENU_BIG, disableRecent ? View.INVISIBLE : View.VISIBLE);
setButtonWithTagVisibility(NavbarEditor.NAVBAR_SEARCH, disableRecent ? View.INVISIBLE : View.VISIBLE);
getSearchLight().setVisibility((disableHome && !disableSearch) ? View.VISIBLE : View.GONE);
}
use of android.animation.LayoutTransition in project android_frameworks_base by ParanoidAndroid.
the class RecentsVerticalScrollView method update.
private void update() {
for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
View v = mLinearLayout.getChildAt(i);
addToRecycledViews(v);
mAdapter.recycleView(v);
}
LayoutTransition transitioner = getLayoutTransition();
setLayoutTransition(null);
mLinearLayout.removeAllViews();
// Once we can clear the data associated with individual item views,
// we can get rid of the removeAllViews() and the code below will
// recycle them.
Iterator<View> recycledViews = mRecycledViews.iterator();
for (int i = 0; i < mAdapter.getCount(); i++) {
View old = null;
if (recycledViews.hasNext()) {
old = recycledViews.next();
recycledViews.remove();
old.setVisibility(VISIBLE);
}
final View view = mAdapter.getView(i, old, mLinearLayout);
if (mPerformanceHelper != null) {
mPerformanceHelper.addViewCallback(view);
}
OnTouchListener noOpListener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
};
view.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mCallback.dismiss();
}
});
// We don't want a click sound when we dimiss recents
view.setSoundEffectsEnabled(false);
OnClickListener launchAppListener = new OnClickListener() {
public void onClick(View v) {
mCallback.handleOnClick(view);
}
};
RecentsPanelView.ViewHolder holder = (RecentsPanelView.ViewHolder) view.getTag();
final View thumbnailView = holder.thumbnailView;
OnLongClickListener longClickListener = new OnLongClickListener() {
public boolean onLongClick(View v) {
final View anchorView = view.findViewById(R.id.app_description);
mCallback.handleLongPress(view, anchorView, thumbnailView);
return true;
}
};
thumbnailView.setClickable(true);
thumbnailView.setOnClickListener(launchAppListener);
thumbnailView.setOnLongClickListener(longClickListener);
// We don't want to dismiss recents if a user clicks on the app title
// (we also don't want to launch the app either, though, because the
// app title is a small target and doesn't have great click feedback)
final View appTitle = view.findViewById(R.id.app_label);
appTitle.setContentDescription(" ");
appTitle.setOnTouchListener(noOpListener);
final View calloutLine = view.findViewById(R.id.recents_callout_line);
if (calloutLine != null) {
calloutLine.setOnTouchListener(noOpListener);
}
mLinearLayout.addView(view);
}
setLayoutTransition(transitioner);
// Scroll to end after initial layout.
final OnGlobalLayoutListener updateScroll = new OnGlobalLayoutListener() {
public void onGlobalLayout() {
mLastScrollPosition = scrollPositionOfMostRecent();
scrollTo(0, mLastScrollPosition);
final ViewTreeObserver observer = getViewTreeObserver();
if (observer.isAlive()) {
observer.removeOnGlobalLayoutListener(this);
}
}
};
getViewTreeObserver().addOnGlobalLayoutListener(updateScroll);
}
Aggregations