Skip to content

Instantly share code, notes, and snippets.

View chetdeva's full-sized avatar

Chetan Sachdeva chetdeva

View GitHub Profile
/**
* Bind ItemTouchHelper.SimpleCallback with RecyclerView
*
* @param recyclerView RecyclerView to bind to SwipeItemTouchHelperCallback
* @param swipeEnabled enable/disable swipe
* @param drawableSwipeLeft drawable shown when swiped left
* @param drawableSwipeRight drawable shown when swiped right
* @param bgColorSwipeLeft background color when swiped left
* @param bgColorSwipeRight background color when swiped right
* @param onItemSwipeLeft OnItemSwipeListener for swiped left
/**
* Bind ItemTouchHelper.SimpleCallback with RecyclerView
*
* @param recyclerView RecyclerView to bind to DragItemTouchHelperCallback
* @param dragEnabled enable/disable drag
* @param onItemDrag OnItemDragListener for dragged
*/
@android.databinding.BindingAdapter(value = {"dragEnabled", "onItemDrag"}, requireAll = false)
public static void setItemDragToRecyclerView(RecyclerView recyclerView, boolean dragEnabled,
DragItemTouchHelperCallback.OnItemDragListener onItemDrag) {
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
bind:dragEnabled="@{true}"
bind:onItemDrag="@{(indexFrom, indexTo) -> handler.onItemDragged(indexFrom, indexTo)}"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
bind:bgColorSwipeLeft="@{@color/app_green}"
bind:bgColorSwipeRight="@{@color/app_red}"
bind:drawableSwipeLeft="@{@drawable/ic_check_white_24dp}"
bind:drawableSwipeRight="@{@drawable/ic_close_white_24dp}"
bind:onItemSwipeLeft="@{(position) -> handler.onItemSwipedLeft(position)}"
textView.setText(new Truss()
.appendSelectiveln("With Snippety, you can use:", "Snippety",
new Snippety().textColor(Color.RED))
.appendln()
.pushSpan(new Snippety().typeface(typeface)) // TextTypefaceSpan
.appendln("typeface for TypefaceSpan")
.popSpan()
CharSequence text = new Truss()
.pushSpan(new BackgroundColorSpan(Color.RED))
.append("Hello Snippety")
.popSpan()
.build();
CharSequence text = new Truss()
.append("Hello Snippety", new BackgroundColorSpan(Color.RED))
.build();
CharSequence text = new Truss()
.append("Hello Snippety", new Snippety().backgroundColor(Color.RED))
.build();
CharSequence text = new Truss()
.append("Hello Snippety", new Snippety().backgroundColor(Color.RED).textColor(Color.WHITE))
.build();
textView.setText(new Truss()
.append(new Snippety().backgroundColor(Color.RED).textColor(Color.WHITE))
.build());