diff --git a/README.md b/README.md
index 73f8692..ac983b9 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
# Sheet Selection
-[](https://jitpack.io/#minibugdev/SheetSelection)
+[](https://jitpack.io/#minibugdev/SheetSelection)
+[](https://android-arsenal.com/details/1/8051)
[](https://raw.githubusercontent.com/minibugdev/DrawableBadge/master/LICENSE)
`SheetSelection` is an Android library for display list and be able to select the item as a [BottomSheet](https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialogFragment).
@@ -17,7 +18,7 @@ repositories {
Add the dependency
``` groovy
dependencies {
- implementation 'com.github.minibugdev:sheetselection:0.0.2'
+ implementation 'com.github.minibugdev:sheetselection:0.0.3'
}
```
@@ -38,6 +39,7 @@ SheetSelection.Builder(context)
.selectedPosition(2)
.showDraggedIndicator(true)
.searchEnabled(true)
+ .searchNotFoundText("Nothing!!")
.onItemClickListener { item, position ->
// DO SOMETHING
}
@@ -49,6 +51,7 @@ SheetSelection.Builder(context)
- Set selected item by `Builder.selectedPosition(Int)`. default is `SheetSelection.NO_SELECT`
- Show dragged indicator by `Builder.showDraggedIndicator(Boolean)`. default is `false`
- Set search enabled by `Builder.searchEnabled(Boolean)`. default is `false`
+- Set search not found text by `Builder.searchNotFoundText(String)`. default is `Search not found.`
- Set custom theme by `Builder.theme(@StyleRes)`.
- To handle the item click listener by `Builder.onItemClickListener()`.
diff --git a/app/src/main/java/com/minibugdev/sheetselection/demo/MainActivity.kt b/app/src/main/java/com/minibugdev/sheetselection/demo/MainActivity.kt
index 5dee714..e0ac98a 100644
--- a/app/src/main/java/com/minibugdev/sheetselection/demo/MainActivity.kt
+++ b/app/src/main/java/com/minibugdev/sheetselection/demo/MainActivity.kt
@@ -50,6 +50,7 @@ class MainActivity : AppCompatActivity() {
.selectedPosition(2)
.showDraggedIndicator(true)
.searchEnabled(true)
+ .searchNotFoundText("Nothing!!")
.theme(R.style.Theme_Custom_SheetSelection)
.onItemClickListener { item, position ->
textview.text = "You selected `${item.value}`, At position [$position]."
diff --git a/build.gradle b/build.gradle
index fa30fa6..d583f8a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.3.61'
+ ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.6.1'
+ classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 7118542..d2c37e6 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Feb 28 14:19:21 ICT 2020
+#Tue Jul 07 10:49:00 ICT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
diff --git a/screenshot/ss_1.png b/screenshot/ss_1.png
new file mode 100644
index 0000000..9a91057
Binary files /dev/null and b/screenshot/ss_1.png differ
diff --git a/sheetselection/build.gradle b/sheetselection/build.gradle
index 86eb736..5a389b8 100644
--- a/sheetselection/build.gradle
+++ b/sheetselection/build.gradle
@@ -7,13 +7,13 @@ group='com.minibugdev.sheetselection'
android {
compileSdkVersion 29
- buildToolsVersion "29.0.3"
+ buildToolsVersion "30.0.0"
defaultConfig {
minSdkVersion 17
targetSdkVersion 29
- versionCode 1
- versionName "0.0.2"
+ versionCode 2
+ versionName "0.0.3"
}
buildTypes {
diff --git a/sheetselection/src/main/java/com/minibugdev/sheetselection/SheetSelection.kt b/sheetselection/src/main/java/com/minibugdev/sheetselection/SheetSelection.kt
index 9a0c638..3a87f83 100644
--- a/sheetselection/src/main/java/com/minibugdev/sheetselection/SheetSelection.kt
+++ b/sheetselection/src/main/java/com/minibugdev/sheetselection/SheetSelection.kt
@@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.annotation.StringRes
import androidx.annotation.StyleRes
import androidx.appcompat.widget.SearchView
import androidx.fragment.app.Fragment
@@ -23,6 +24,7 @@ class SheetSelection private constructor() : BottomSheetDialogFragment() {
SheetSelectionAdapter(
source = arguments?.getParcelableArrayList(ARGS_ITEMS) ?: emptyList(),
selectedPosition = arguments?.getInt(ARGS_SELECTED_POSITION, NO_SELECT) ?: NO_SELECT,
+ searchNotFoundText = arguments?.getString(ARGS_SEARCH_NOT_FOUND_TEXT) ?: "Search not found.",
onItemSelectedListener = onItemSelectedListener
)
}
@@ -112,7 +114,7 @@ class SheetSelection private constructor() : BottomSheetDialogFragment() {
}
}
- class Builder(context: Context) {
+ class Builder(private val context: Context) {
private val manager: FragmentManager? = when (context) {
is FragmentActivity -> context.supportFragmentManager
is Fragment -> context.requireFragmentManager()
@@ -126,6 +128,7 @@ class SheetSelection private constructor() : BottomSheetDialogFragment() {
private var selectedPosition: Int = NO_SELECT
private var showDraggedIndicator: Boolean = false
private var searchEnabled: Boolean = false
+ private var searchNotFoundText: String? = null
private var listener: OnItemSelectedListener? = null
fun theme(@StyleRes themeId: Int) = apply {
@@ -157,6 +160,14 @@ class SheetSelection private constructor() : BottomSheetDialogFragment() {
this.searchEnabled = enabled
}
+ fun searchNotFoundText(text: String) = apply {
+ this.searchNotFoundText = text
+ }
+
+ fun searchNotFoundText(@StringRes textResId: Int) = apply {
+ this.searchNotFoundText = context.getString(textResId)
+ }
+
fun onItemClickListener(listener: OnItemSelectedListener) = apply {
this.listener = listener
}
@@ -170,6 +181,7 @@ class SheetSelection private constructor() : BottomSheetDialogFragment() {
putInt(ARGS_SELECTED_POSITION, selectedPosition)
putBoolean(ARGS_SHOW_DRAGGED_INDICATOR, showDraggedIndicator)
putBoolean(ARGS_SEARCH_ENABLED, searchEnabled)
+ putString(ARGS_SEARCH_NOT_FOUND_TEXT, searchNotFoundText)
}
onItemClickListener = listener
}
@@ -187,6 +199,7 @@ class SheetSelection private constructor() : BottomSheetDialogFragment() {
private const val ARGS_THEME = "SheetSelection:ARGS_THEME"
private const val ARGS_TITLE = "SheetSelection:ARGS_TITLE"
private const val ARGS_ITEMS = "SheetSelection:ARGS_ITEMS"
+ private const val ARGS_SEARCH_NOT_FOUND_TEXT = "SheetSelection:ARGS_SEARCH_NOT_FOUND_TEXT"
private const val ARGS_SELECTED_POSITION = "SheetSelection:ARGS_SELECTED_POSITION"
private const val ARGS_SHOW_DRAGGED_INDICATOR = "SheetSelection:ARGS_SHOW_DRAGGED_INDICATOR"
private const val ARGS_SEARCH_ENABLED = "SheetSelection:ARGS_SEARCH_ENABLED"
diff --git a/sheetselection/src/main/java/com/minibugdev/sheetselection/SheetSelectionAdapter.kt b/sheetselection/src/main/java/com/minibugdev/sheetselection/SheetSelectionAdapter.kt
index f654519..a9d2cd0 100644
--- a/sheetselection/src/main/java/com/minibugdev/sheetselection/SheetSelectionAdapter.kt
+++ b/sheetselection/src/main/java/com/minibugdev/sheetselection/SheetSelectionAdapter.kt
@@ -12,28 +12,38 @@ typealias OnItemSelectedListener = (item: SheetSelectionItem, position: Int) ->
class SheetSelectionAdapter(
private val source: List