Skip to content

Commit

Permalink
add setter method for animator and transformer to builder.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1noon committed Sep 19, 2015
1 parent 2117ffc commit 1ddb010
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import com.minoon.disco.Disco;
import com.minoon.disco.ViewParam;
import com.minoon.disco.choreography.ScrollChoreography;
import com.minoon.disco.choreography.Choreography;
import com.minoon.disco.choreography.builder.Position;
import com.minoon.disco.sample.adapter.SampleAdapter;

Expand Down Expand Up @@ -115,30 +115,28 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView parent, Recycle
);

// set up toolbar behavior
mDisco.addScrollObserver(mToolbar, new ScrollChoreography() {

@Override
public long playEvent(Enum e, View chaserView) {
int duration = 300;
if (e instanceof SampleEvent) {
TransitionDrawable drawable = (TransitionDrawable) chaserView.getBackground();
switch ((SampleEvent) e) {
case BACK:
drawable.startTransition(duration);
return duration;
case FORWARD:
drawable.reverseTransition(duration);
return duration;
mDisco.addScrollObserver(mToolbar, mDisco.getScrollChoreographyBuilder()
.at(SampleEvent.BACK)
.animator(new Choreography.Animator() {
@Override
public long animate(View view) {
TransitionDrawable drawable = (TransitionDrawable) view.getBackground();
drawable.startTransition(300);
return 300;
}
}
return 0;
}

@Override
public boolean playScroll(View chaserView, int dx, int dy, int x, int y) {
return false;
}
});
})
.end()
.at(SampleEvent.FORWARD)
.animator(new Choreography.Animator() {
@Override
public long animate(View view) {
TransitionDrawable drawable = (TransitionDrawable) view.getBackground();
drawable.reverseTransition(300);
return 300;
}
})
.build()
);

if (savedInstanceState != null) {
mDisco.restoreInstanceState(savedInstanceState.getParcelable(ARG_DISCO_STATE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,20 @@
public interface Choreography {

long playEvent(Enum e, View chaserView);


interface Transformer {
void transform(View view, float progress);
}


interface Animator {
/**
* animate the specified view.
*
* @param view view to be animated.
* @return animate duration
*/
long animate(View view);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
public interface ViewChaseChoreography extends Choreography {

boolean playChase(View anchorView, View chaserView);

interface ViewChaseTransformer {
void transform(View chaseView, float progress);
}
}

This file was deleted.

Loading

0 comments on commit 1ddb010

Please sign in to comment.