diff --git a/build.gradle b/build.gradle index f08173b..fce0442 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.50' + ext.kotlin_version = '1.3.60' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' + classpath 'com.android.tools.build:gradle:3.5.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/lib/src/main/java/me/ibrahimsn/lib/OnItemReselectedListener.kt b/lib/src/main/java/me/ibrahimsn/lib/OnItemReselectedListener.kt new file mode 100644 index 0000000..afb4ec0 --- /dev/null +++ b/lib/src/main/java/me/ibrahimsn/lib/OnItemReselectedListener.kt @@ -0,0 +1,5 @@ +package me.ibrahimsn.lib + +interface OnItemReselectedListener { + fun onItemReselect(pos: Int) +} \ No newline at end of file diff --git a/lib/src/main/java/me/ibrahimsn/lib/OnItemSelectedListener.kt b/lib/src/main/java/me/ibrahimsn/lib/OnItemSelectedListener.kt new file mode 100644 index 0000000..aac93a8 --- /dev/null +++ b/lib/src/main/java/me/ibrahimsn/lib/OnItemSelectedListener.kt @@ -0,0 +1,5 @@ +package me.ibrahimsn.lib + +interface OnItemSelectedListener { + fun onItemSelect(pos: Int) +} \ No newline at end of file diff --git a/lib/src/main/java/me/ibrahimsn/lib/SmoothBottomBar.kt b/lib/src/main/java/me/ibrahimsn/lib/SmoothBottomBar.kt index 1cf735d..a5ca5b1 100644 --- a/lib/src/main/java/me/ibrahimsn/lib/SmoothBottomBar.kt +++ b/lib/src/main/java/me/ibrahimsn/lib/SmoothBottomBar.kt @@ -62,6 +62,9 @@ class SmoothBottomBar : View { private var items = listOf() + private var onItemSelectedListener: OnItemSelectedListener? = null + private var onItemReselectedListener: OnItemReselectedListener? = null + var onItemSelected: (Int) -> Unit = {} var onItemReselected: (Int) -> Unit = {} @@ -188,8 +191,10 @@ class SmoothBottomBar : View { if (itemId != this.activeItemIndex) { setActiveItem(itemId) onItemSelected(itemId) + onItemSelectedListener?.onItemSelect(itemId) } else { onItemReselected(itemId) + onItemReselectedListener?.onItemReselect(itemId) } } } @@ -249,4 +254,12 @@ class SmoothBottomBar : View { private fun d2p(dp: Float): Float { return resources.displayMetrics.densityDpi.toFloat() / 160.toFloat() * dp } + + fun setOnItemSelectedListener(listener: OnItemSelectedListener) { + this.onItemSelectedListener = listener + } + + fun setOnItemReselectedListener(listener: OnItemReselectedListener) { + this.onItemReselectedListener = listener + } } \ No newline at end of file