本文整理汇总了Java中android.support.transition.Transition类的典型用法代码示例。如果您正苦于以下问题:Java Transition类的具体用法?Java Transition怎么用?Java Transition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transition类属于android.support.transition包,在下文中一共展示了Transition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transitionToSearch
import android.support.transition.Transition; //导入依赖的package包/类
public void transitionToSearch(){
if (transitioning) {
return;
}
if (supportsTransitions()) {
Transition transition = FadeOutTransition.withAction(navigateToSearchWhenDone());
TransitionManager.beginDelayedTransition(searchView, transition);
expandToolbar();
ViewFader.hideContentOf(searchView);
TransitionManager.beginDelayedTransition(activityContent, new Fade(Fade.OUT));
activityContent.setVisibility(View.GONE);
} else {
TRouter.go(Constants.SEARCH);
}
}
示例2: applyStaggeredTransitionParams_setsPassedViewId_asTarget
import android.support.transition.Transition; //导入依赖的package包/类
@Test
public void applyStaggeredTransitionParams_setsPassedViewId_asTarget() {
//given
StaggeredAnimationGroup spiedGroup = prepareSpiedGroup();
Transition testTransition = new Fade(); //exemplary value
int testIndexInStaggeredTransition = 0; //exemplary value
int viewId = 12345; //exemplary value
//when
Transition resultTransition = spiedGroup.applyStaggeredTransitionParams(testTransition, viewId, testIndexInStaggeredTransition);
//then
List<Integer> targetIds = resultTransition.getTargetIds();
assertThat(targetIds).hasSize(1);
assertThat(targetIds.get(0)).isEqualTo(viewId);
}
示例3: setPartialTransitionFactory_setsField_whenPassed_nonNull_listener
import android.support.transition.Transition; //导入依赖的package包/类
@Test
public void setPartialTransitionFactory_setsField_whenPassed_nonNull_listener() {
//given
StaggeredAnimationGroup spiedGroup = prepareSpiedGroup();
StaggeredAnimationGroup.PartialTransitionFactory testFactory =
new StaggeredAnimationGroup.PartialTransitionFactory() {
@Override
public Transition createPartialTransition(boolean show, int viewId, int indexInTransition) {
return new AutoTransition();
}
};
//when
spiedGroup.setPartialTransitionFactory(testFactory);
//then
assertThat(spiedGroup.partialTransitionFactory).isEqualTo(testFactory);
}
示例4: preparePartialTransition_usesFactory
import android.support.transition.Transition; //导入依赖的package包/类
@Test
public void preparePartialTransition_usesFactory() {
//given
StaggeredAnimationGroup spiedGroup = prepareSpiedGroup();
StaggeredAnimationGroup.PartialTransitionFactory spiedFactory =
spy(new StaggeredAnimationGroup.PartialTransitionFactory() {
@Override
public Transition createPartialTransition(boolean show, int viewId, int indexInTransition) {
return new AutoTransition();
}
});
spiedGroup.setPartialTransitionFactory(spiedFactory);
//when
spiedGroup.preparePartialTransition(true, 0, 0);
//then
verify(spiedFactory, times(1))
.createPartialTransition(anyBoolean(), anyInt(), anyInt());
verifyNoMoreInteractions(spiedFactory);
}
示例5: preparePartialTransition_setsPartialDuration
import android.support.transition.Transition; //导入依赖的package包/类
@Test
public void preparePartialTransition_setsPartialDuration() {
//given
final StaggeredAnimationGroup spiedGroup = prepareSpiedGroup();
final int testPartialDuration = 12345;
final Transition spiedTransition = spy(new AutoTransition());
final StaggeredAnimationGroup.PartialTransitionFactory factory =
new StaggeredAnimationGroup.PartialTransitionFactory() {
@Override
public Transition createPartialTransition(boolean show, int viewId, int indexInTransition) {
return spiedTransition;
}
};
spiedGroup.setPartialTransitionFactory(factory);
spiedGroup.setPartialDuration(testPartialDuration);
//when
spiedGroup.preparePartialTransition(true, 0, 0);
//then
verify(spiedTransition, times(1)).setDuration(testPartialDuration);
}
示例6: preparePartialTransition_setsPartialInterpolator
import android.support.transition.Transition; //导入依赖的package包/类
@Test
public void preparePartialTransition_setsPartialInterpolator() {
//given
final StaggeredAnimationGroup spiedGroup = prepareSpiedGroup();
final TimeInterpolator testInterpolator = new LinearOutSlowInInterpolator();
final Transition spiedTransition = spy(new AutoTransition());
final StaggeredAnimationGroup.PartialTransitionFactory factory =
new StaggeredAnimationGroup.PartialTransitionFactory() {
@Override
public Transition createPartialTransition(boolean show, int viewId, int indexInTransition) {
return spiedTransition;
}
};
spiedGroup.setPartialTransitionFactory(factory);
spiedGroup.setPartialInterpolator(testInterpolator);
//when
spiedGroup.preparePartialTransition(true, 0, 0);
//then
verify(spiedTransition, times(1)).setInterpolator(testInterpolator);
}
示例7: removeActivityFromTransitionManager
import android.support.transition.Transition; //导入依赖的package包/类
private void removeActivityFromTransitionManager() {
final Class transitionManagerClass = TransitionManager.class;
try {
final Field runningTransitionsField = transitionManagerClass
.getDeclaredField("sRunningTransitions");
runningTransitionsField.setAccessible(true);
//noinspection unchecked
final ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>> runningTransitions
= (ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>>)
runningTransitionsField.get(transitionManagerClass);
if(runningTransitions.get() == null || runningTransitions.get().get() == null) {
return;
}
ArrayMap map = runningTransitions.get().get();
View decorView = getWindow().getDecorView();
if(map.containsKey(decorView)) {
map.remove(decorView);
}
} catch(Exception ignored) {
}
}
示例8: withAction
import android.support.transition.Transition; //导入依赖的package包/类
/**
* Creates a AutoTransition that calls the {@linkplain TransitionListener#onTransitionEnd(Transition)}
* of the passing DonationCallbacks when complete
*/
public static Transition withAction(TransitionListener finishingAction) {
AutoTransition transition = new AutoTransition();
transition.setDuration(FADE_OUT_DURATION);
transition.addListener(finishingAction);
return transition;
}
示例9: createPartialTransition
import android.support.transition.Transition; //导入依赖的package包/类
@NonNull
@Override
public Transition createPartialTransition(boolean isShowing,
int viewId,
int indexInTransition) {
return new Fade();
}
示例10: addTransitionToStaggeredTransition
import android.support.transition.Transition; //导入依赖的package包/类
@VisibleForTesting
final void addTransitionToStaggeredTransition(Transition basePartialTransition,
TransitionSet staggeredTransition,
int viewId, int indexInTransition) {
Transition partialTransition =
applyStaggeredTransitionParams(basePartialTransition, viewId, indexInTransition);
staggeredTransition.addTransition(partialTransition);
}
示例11: applyStaggeredTransitionParams
import android.support.transition.Transition; //导入依赖的package包/类
@VisibleForTesting
final Transition applyStaggeredTransitionParams(Transition partialTransition,
int viewId, int indexInTransition) {
partialTransition.setStartDelay(indexInTransition * partialDelay);
partialTransition.addTarget(viewId);
return partialTransition;
}
示例12: show
import android.support.transition.Transition; //导入依赖的package包/类
public final void show(boolean inReversedOrder) {
ConstraintLayout parent = getConstraintLayoutParent(this);
if (notNull(parent)) {
Transition transition = prepareStaggeredTransition(true, inReversedOrder);
TransitionManager.beginDelayedTransition(parent, transition);
setVisibility(View.VISIBLE);
}
}
示例13: hide
import android.support.transition.Transition; //导入依赖的package包/类
public final void hide(boolean inReversedOrder) {
ConstraintLayout parent = getConstraintLayoutParent(this);
if (notNull(parent)) {
Transition transition = prepareStaggeredTransition(false, inReversedOrder);
TransitionManager.beginDelayedTransition(parent, transition);
setVisibility(View.GONE);
}
}
示例14: applyStaggeredTransitionParams_setsDelay
import android.support.transition.Transition; //导入依赖的package包/类
public void applyStaggeredTransitionParams_setsDelay(int indexInStaggeredTransition, int expectedDelay) {
//given
StaggeredAnimationGroup spiedGroup = prepareSpiedGroup();
Transition testTransition = new Fade(); //exemplary value
int testViewId = 0; //exemplary value
//when
Transition resultTransition = spiedGroup.applyStaggeredTransitionParams(testTransition, testViewId, indexInStaggeredTransition);
//then
assertThat(resultTransition.getStartDelay()).isEqualTo(expectedDelay);
}
示例15: onCreate
import android.support.transition.Transition; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mStaggerCB = (CheckBox) findViewById(R.id.staggerCB);
mFirstButton = (Button) findViewById(R.id.firstButton);
mSecondButton = (Button) findViewById(R.id.secondButton);
mThirdButton = (Button) findViewById(R.id.thirdButton);
mFourthButton = (Button) findViewById(R.id.fourthButton);
mSceneRoot = (ViewGroup) findViewById(R.id.activity_main);
// Create custom transition that 'staggers' the animations by offsetting
// the individual start times
mStaggeredTransition = new TransitionSet();
Transition first = new ChangeBounds();
Transition second = new ChangeBounds();
Transition third = new ChangeBounds();
Transition fourth = new ChangeBounds();
first.addTarget(mFirstButton);
second.setStartDelay(50).addTarget(mSecondButton);
third.setStartDelay(100).addTarget(mThirdButton);
fourth.setStartDelay(150).addTarget(mFourthButton);
mStaggeredTransition.addTransition(first).addTransition(second).addTransition(third).
addTransition(fourth);
}