-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create DiffRVRendererAdapter to use RecyclerView's DiffUtil (#36)
* Update support library in order to add the DiffUtil, also update gradle version * Add DiffRVRendererAdapter class to take advantage of the DiffUtil in our RendererAdapters * Implement the Diff * Create a renderer with the hability of remove items from the list in order to show the Diff animation * Fix checkstyle and change android sdk version on travis * Fix lint * Remove DiffRVRendererAdapter and move update to RVRendererAdapter then fix the sample project * Rename the class RemoveItemCallback to RemovableVideoRenderer.Listener * Rename the method removeItem in RemoveItemCallback to onRemoveButtonTapped * Add a documentation comment for our new diffUpdate method * Override hashCode in order to fix the checkstyle
- Loading branch information
Showing
10 changed files
with
157 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sun Jan 03 17:21:12 CET 2016 | ||
#Fri Apr 07 09:29:52 CEST 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip |
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
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
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
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
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
38 changes: 38 additions & 0 deletions
38
...le/src/main/java/com/pedrogomez/renderers/sample/ui/renderers/RemovableVideoRenderer.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.pedrogomez.renderers.sample.ui.renderers; | ||
|
||
import com.pedrogomez.renderers.sample.R; | ||
import com.pedrogomez.renderers.sample.model.Video; | ||
|
||
import butterknife.OnClick; | ||
|
||
public class RemovableVideoRenderer extends VideoRenderer { | ||
|
||
private Listener removeItemListener; | ||
|
||
public interface Listener { | ||
|
||
void onRemoveButtonTapped(Video video); | ||
} | ||
|
||
public RemovableVideoRenderer(Listener removeItemListener) { | ||
this.removeItemListener = removeItemListener; | ||
} | ||
|
||
@Override protected void renderLabel() { | ||
String deleteLabel = getContext().getString(R.string.delete_label); | ||
getLabel().setText(deleteLabel); | ||
} | ||
|
||
@Override protected void renderMarker(Video video) { | ||
|
||
} | ||
|
||
@OnClick(R.id.tv_label) void clickOnDelete() { | ||
removeItemListener.onRemoveButtonTapped(getContent()); | ||
} | ||
|
||
@OnClick(R.id.iv_marker) void clickOnLike() { | ||
getContent().setLiked(!getContent().isLiked()); | ||
renderMarker(getContent()); | ||
} | ||
} |
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