-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added example of how to implement leave behind pattern, using daimaji…
…a’s swipelayout
- Loading branch information
Showing
8 changed files
with
168 additions
and
0 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
20 changes: 20 additions & 0 deletions
20
app/demo/src/main/java/net/gotev/recycleradapterdemo/leavebehind/LeaveBehindAdapterItem.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,20 @@ | ||
package net.gotev.recycleradapterdemo.leavebehind; | ||
|
||
|
||
import net.gotev.recycleradapter.AdapterItem; | ||
import net.gotev.recycleradapterdemo.R; | ||
|
||
|
||
/** | ||
* Base adapter item to extend when implementing leave-behind material pattern. | ||
* @author Aleksandar Gotev | ||
*/ | ||
|
||
public abstract class LeaveBehindAdapterItem<T extends LeaveBehindViewHolder> extends AdapterItem<T> { | ||
|
||
@Override | ||
public final int getLayoutId() { | ||
return R.layout.item_leave_behind; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
app/demo/src/main/java/net/gotev/recycleradapterdemo/leavebehind/LeaveBehindViewHolder.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 net.gotev.recycleradapterdemo.leavebehind; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.FrameLayout; | ||
|
||
import net.gotev.recycleradapter.RecyclerAdapterNotifier; | ||
import net.gotev.recycleradapter.RecyclerAdapterViewHolder; | ||
import net.gotev.recycleradapterdemo.R; | ||
|
||
/** | ||
* Base RecyclerAdapterViewHolder to extend when implementing leave-behind material pattern. | ||
* @author Aleksandar Gotev | ||
*/ | ||
|
||
public abstract class LeaveBehindViewHolder extends RecyclerAdapterViewHolder { | ||
|
||
FrameLayout contentView; | ||
FrameLayout leaveBehindView; | ||
|
||
public LeaveBehindViewHolder(final View itemView, final RecyclerAdapterNotifier adapter) { | ||
super(itemView, adapter); | ||
|
||
Context context = itemView.getContext(); | ||
|
||
contentView = (FrameLayout) findViewById(R.id.swipe_content_view); | ||
leaveBehindView = (FrameLayout) findViewById(R.id.swipe_background_layout); | ||
|
||
LayoutInflater.from(context).inflate(getContentViewId(), contentView); | ||
LayoutInflater.from(context).inflate(getLeaveBehindId(), leaveBehindView); | ||
} | ||
|
||
public abstract int getContentViewId(); | ||
|
||
public abstract int getLeaveBehindId(); | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
app/demo/src/main/java/net/gotev/recycleradapterdemo/leavebehind/MyLeaveBehindItem.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,55 @@ | ||
package net.gotev.recycleradapterdemo.leavebehind; | ||
|
||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import net.gotev.recycleradapter.RecyclerAdapterNotifier; | ||
import net.gotev.recycleradapterdemo.R; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
|
||
/** | ||
* @author Aleksandar Gotev | ||
*/ | ||
|
||
public class MyLeaveBehindItem extends LeaveBehindAdapterItem<MyLeaveBehindItem.Holder> { | ||
|
||
private String value; | ||
private String background; | ||
|
||
public MyLeaveBehindItem(String value, String background) { | ||
this.value = value; | ||
this.background = background; | ||
} | ||
|
||
@Override | ||
protected void bind(Holder holder) { | ||
holder.name.setText(value); | ||
holder.delete.setText(background); | ||
} | ||
|
||
public static class Holder extends LeaveBehindViewHolder { | ||
|
||
@BindView(R.id.name) | ||
TextView name; | ||
|
||
@BindView(R.id.delete) | ||
TextView delete; | ||
|
||
public Holder(final View itemView, final RecyclerAdapterNotifier adapter) { | ||
super(itemView, adapter); | ||
ButterKnife.bind(this, itemView); | ||
} | ||
|
||
@Override | ||
public int getContentViewId() { | ||
return R.layout.swipe_foregound_layout; | ||
} | ||
|
||
@Override | ||
public int getLeaveBehindId() { | ||
return R.layout.swipe_background_layout; | ||
} | ||
} | ||
} |
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,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<com.daimajia.swipe.SwipeLayout | ||
xmlns:android="http:https://schemas.android.com/apk/res/android" | ||
xmlns:swipe="http:https://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
swipe:leftEdgeSwipeOffset="0dp" | ||
swipe:rightEdgeSwipeOffset="0dp"> | ||
|
||
<FrameLayout | ||
android:id="@+id/swipe_background_layout" | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" /> | ||
|
||
<FrameLayout | ||
android:id="@+id/swipe_content_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
</com.daimajia.swipe.SwipeLayout> |
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
xmlns:android="http:https://schemas.android.com/apk/res/android"> | ||
|
||
<TextView | ||
android:id="@+id/delete" | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:text="delete" | ||
android:gravity="center" | ||
android:background="@android:color/holo_blue_bright"/> | ||
|
||
</LinearLayout> |
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,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:background="@android:color/white" | ||
android:padding="10dp" | ||
xmlns:android="http:https://schemas.android.com/apk/res/android"> | ||
|
||
<TextView | ||
android:id="@+id/name" | ||
android:layout_width="match_parent" | ||
android:layout_height="40dp" | ||
android:textSize="16sp" | ||
android:gravity="center_vertical" | ||
android:textColor="@android:color/black"/> | ||
|
||
</LinearLayout> |