Bug 1317446 - 2. Add TabStripItemAnimator for TabStripView item animations. r=sebastian

MozReview-Commit-ID: AF2pwFMvWDe

--HG--
extra : rebase_source : c47ed9eae20dfa5ba5b6ce5a3e64250ef47073e1
This commit is contained in:
Tom Klein 2016-10-17 20:45:13 -05:00
Родитель 2a0c005f63
Коммит 87f9e0dca6
3 изменённых файлов: 49 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,47 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.tabs;
import org.mozilla.gecko.widget.DefaultItemAnimatorBase;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
class TabStripItemAnimator extends DefaultItemAnimatorBase {
public TabStripItemAnimator(int animationDuration) {
setAddDuration(animationDuration);
setSupportsChangeAnimations(false);
}
@Override
protected boolean preAnimateRemoveImpl(final RecyclerView.ViewHolder holder) {
return false;
}
@Override
protected boolean preAnimateAddImpl(final RecyclerView.ViewHolder holder) {
resetAnimation(holder);
final View view = holder.itemView;
view.setTranslationY(view.getHeight());
return true;
}
@Override
protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
ViewCompat.animate(holder.itemView)
.setDuration(getAddDuration())
.setListener(new DefaultAddVpaListener(holder))
.translationY(0)
.start();
}
@Override
protected void resetViewProperties(View view) {
view.setTranslationX(0);
view.setTranslationY(0);
}
}

Просмотреть файл

@ -58,7 +58,7 @@ public class TabStripView extends RecyclerView {
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
setLayoutManager(layoutManager);
// TODO add item animator.
setItemAnimator(new TabStripItemAnimator(ANIM_TIME_MS));
// TODO add item decoration.
}
@ -148,7 +148,6 @@ public class TabStripView extends RecyclerView {
// Make sure we didn't miss any resets after animations etc.
child.setTranslationX(0);
child.setTranslationY(0);
child.setAlpha(1);
}
@Override

Просмотреть файл

@ -855,6 +855,7 @@ if max_sdk_version >= 11:
gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
'tabs/TabStrip.java',
'tabs/TabStripAdapter.java',
'tabs/TabStripItemAnimator.java',
'tabs/TabStripItemView.java',
'tabs/TabStripView.java'
]]