Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
gurleensethi authored Aug 21, 2017
1 parent 11b1ff4 commit d74e9bc
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ recyclerAdapter.addOnDataBindListener { itemView, item, position ->
* `item` - Data item from the list.
* `position` - Position of the data item in the list.

#### Click Listeners
### Click Listeners
You can also add `OnClickListener` and `OnLongClickListener` simply by implementing two lambdas.

```kotlin
Expand All @@ -72,7 +72,7 @@ Both `addOnClickListener` and `addOnLongClickListener` provide lambda with two p
* `item` - Data item from the list.
* `position` - Position of the data item in the list.

#### Using Builder pattern for more consice code
### Using Builder pattern for more consice code

Use `RecyclerAdapterUtil.Builder` to chain functions as shown below.

Expand Down Expand Up @@ -105,7 +105,7 @@ val floatingActionButton = findViewById(R.id.floatingActionButton) as FloatingAc
nestedSrollView.hideFloatingActionButtonOnScroll(floatingActionButton)
```

#### Take custom action when scrolled up and down
### Take custom action when scrolled up and down
If you want to take custom action when scrolled up or down you can implement `ScrollListener` using the function `addScrollListener(ScrollListener)`. This works with both `NestedScrollView` and `RecyclerView`.

```kotlin
Expand All @@ -119,3 +119,26 @@ nestedScrollView.addScrollListener(object : ScrollListener {
}
})
```

ToastUtils
======

Making toast has never been easier. Just use `shortToast(String)` for making short toast and `longToast(String)` for making long ones. These functions are implemented as extension functions on `Context`, so wherever `Context` is available, these functions can be used.

```kotlin
shortToast("This is a short toast")
longToast("This is a long toast")
```

### Making colored Toasts
To make a toast with custom background and text color use `coloredShortToast(message, backgroundColor, textColor)` or `coloredLongToast(message, backgroundColor, textColor)`.

Both of these functions take three parameters:
* `message`: String displayed by the toast.
* `backgroundColor`: Background Color of the toast.
* `textColor`: Color of the text shown.

```kotlin
coloredShortToast("Colored short toast", R.color.darker_gray, R.color.black)
coloredLongToast("Colored long toast", R.color.darker_gray, R.color.black)
```

0 comments on commit d74e9bc

Please sign in to comment.