This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AnimationUtils { | |
public static void registerCircularRevealAnimation(final Context context, final View view, final RevealAnimationSetting revealSettings, final int startColor, final int endColor) { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { | |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
@Override | |
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { | |
v.removeOnLayoutChangeListener(this); | |
int cx = revealSettings.getCenterX(); | |
int cy = revealSettings.getCenterY(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DetailFragment extends Fragment { | |
//... | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
//.. | |
AnimationUtils.registerCircularRevealAnimation(getContext(), view, (RevealAnimationSetting) getArguments().getParcelable(ARG_REVEAL_SETTINGS), getColor(R.color.prezi_blue), getColor(R.color.white)); | |
//... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SwipeableRecycleView extends RecyclerView { | |
interface OnSwipeActionListener { | |
@Retention(RetentionPolicy.SOURCE) | |
@IntDef({LEFT, RIGHT}) | |
@interface SwipeDirection {} | |
int LEFT = 0; | |
int RIGHT = 1; | |
void onSwipe(int position, @SwipeDirection int direction); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class ViewHolder extends RecyclerView.ViewHolder { | |
private Interpolator interpolator = new DecelerateInterpolator(2f); | |
private TextView nameTextView; | |
private View leftImage; | |
private View rightImage; | |
private View view; | |
public ViewHolder(View view) { | |
super(view); | |
this.view = view; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
//Won't show the events fully, only "peek" into it | |
final float maxX = getResources().getDimensionPixelSize(R.dimen.share_link_swipe_action_size) * 0.75f; | |
final ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); | |
animator.setInterpolator(new CycleInterpolator(1)); | |
animator.setDuration(1000); | |
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
@Override | |
public void onAnimationUpdate(ValueAnimator animation) { | |
float value = animation.getAnimatedFraction() * maxX; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AnimationUtils { | |
//... | |
public static void startCircularExitAnimation(final Context context, final View view, final RevealAnimationSetting revealSettings, final int startColor, final int endColor, final Dismissible.OnDismissedListener listener) { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
int cx = revealSettings.getCenterX(); | |
int cy = revealSettings.getCenterY(); | |
int width = revealSettings.getWidth(); | |
int height = revealSettings.getHeight(); | |
int duration = context.getResources().getInteger(android.R.integer.config_mediumAnimTime); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DetailFragment extends Fragment implements Dismissible, ... { | |
public static final String ARG_REVEAL_SETTINGS = "ARG_REVEAL_SETTINGS"; | |
//... | |
@Override | |
public void dismiss(OnDismissedListener listener) { | |
AnimationUtils.startCircularRevealExitAnimation(getContext(), getView(), (RevealAnimationSetting) getArguments().getParcelable(ARG_REVEAL_SETTINGS), getColor(R.color.white), getColor(R.color.prezi_blue), new AnimationFinishedListener() { | |
@Override | |
public void onAnimationFinished() { | |
listener.onDismissed(); | |
} |
OlderNewer