зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1055604 - Add animation to reveal tabs on startup (r=mcomella)
This commit is contained in:
Родитель
459f23d9b3
Коммит
8df1511466
|
@ -103,6 +103,9 @@ public class TabStrip extends ThemedLinearLayout {
|
|||
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
|
||||
switch (msg) {
|
||||
case RESTORED:
|
||||
tabStripView.restoreTabs();
|
||||
break;
|
||||
|
||||
case ADDED:
|
||||
tabStripView.addTab(tab);
|
||||
break;
|
||||
|
|
|
@ -205,6 +205,38 @@ public class TabStripView extends TwoWayView {
|
|||
});
|
||||
}
|
||||
|
||||
private void animateRestoredTabs() {
|
||||
getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
|
||||
final List<Animator> childAnimators = new ArrayList<Animator>();
|
||||
|
||||
final int tabHeight = getHeight() - getPaddingTop() - getPaddingBottom();
|
||||
final int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
childAnimators.add(
|
||||
ObjectAnimator.ofFloat(child, "translationY", tabHeight, 0));
|
||||
}
|
||||
|
||||
final AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(childAnimators);
|
||||
animatorSet.setDuration(ANIM_TIME_MS);
|
||||
animatorSet.setInterpolator(ANIM_INTERPOLATOR);
|
||||
animatorSet.addListener(animatorListener);
|
||||
|
||||
TransitionsTracker.track(animatorSet);
|
||||
|
||||
animatorSet.start();
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ensurePositionIsVisible(final int position) {
|
||||
getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
|
||||
@Override
|
||||
|
@ -244,6 +276,11 @@ public class TabStripView extends TwoWayView {
|
|||
adapter.clear();
|
||||
}
|
||||
|
||||
void restoreTabs() {
|
||||
refreshTabs();
|
||||
animateRestoredTabs();
|
||||
}
|
||||
|
||||
void addTab(Tab tab) {
|
||||
// Refresh the list to make sure the new tab is
|
||||
// added in the right position.
|
||||
|
|
Загрузка…
Ссылка в новой задаче