Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include canvas in ItemTouchHelper swipe callback #280

Merged
merged 1 commit into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
buildscript {

ext.KOTLIN_VERSION = "1.1.4-3"
ext.ANDROID_PLUGIN_VERSION = "3.0.0-beta4"
ext.ANDROID_PLUGIN_VERSION = "3.0.0-beta5"

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,12 @@ protected void onChildDraw(Canvas c, RecyclerView recyclerView, EpoxyViewHolder
float clampedProgress = Math.max(-1f, Math.min(1f, swipeProgress));

//noinspection unchecked
onSwipeProgressChanged((T) model, itemView, clampedProgress);
onSwipeProgressChanged((T) model, itemView, clampedProgress, c);
}

@Override
public void onSwipeProgressChanged(T model, View itemView, float swipeProgress) {
public void onSwipeProgressChanged(T model, View itemView, float swipeProgress,
Canvas canvas) {

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.airbnb.epoxy;

import android.graphics.Canvas;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.View;

Expand Down Expand Up @@ -30,10 +31,13 @@ public interface EpoxySwipeCallback<T extends EpoxyModel> extends BaseEpoxyTouch
* @param itemView The view that is being swiped
* @param swipeProgress A float from -1 to 1 representing the percentage that the view has been
* swiped relative to its width. This will be positive if the view is being
* swiped to the right and negative if it is swiped to the left. For example,
* if the view has been swiped halfway to the right this will be 0.5
* swiped to the right and negative if it is swiped to the left. For
* example,
* @param canvas The canvas on which RecyclerView is drawing its children. You can draw to
* this to support custom swipe animations.
*/
void onSwipeProgressChanged(T model, View itemView, float swipeProgress);
void onSwipeProgressChanged(T model, View itemView, float swipeProgress,
Canvas canvas);

/**
* Called when the user has released their touch on the view. If the displacement passed the swipe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.airbnb.epoxy;

import android.graphics.Canvas;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.View;
Expand Down Expand Up @@ -413,8 +414,9 @@ public void onSwipeStarted(U model, View itemView, int adapterPosition) {
}

@Override
public void onSwipeProgressChanged(U model, View itemView, float swipeProgress) {
callbacks.onSwipeProgressChanged(model, itemView, swipeProgress);
public void onSwipeProgressChanged(U model, View itemView, float swipeProgress,
Canvas canvas) {
callbacks.onSwipeProgressChanged(model, itemView, swipeProgress, canvas);
}

@Override
Expand Down Expand Up @@ -448,7 +450,8 @@ public void onSwipeStarted(T model, View itemView, int adapterPosition) {
}

@Override
public void onSwipeProgressChanged(T model, View itemView, float swipeProgress) {
public void onSwipeProgressChanged(T model, View itemView, float swipeProgress,
Canvas canvas) {

}

Expand Down