diff --git a/README.md b/README.md index d76d93b..ffe622a 100644 --- a/README.md +++ b/README.md @@ -73,18 +73,22 @@ Firstly, you should declare your view in xml file app:layout_constraintStart_toStartOf="parent" /> ``` -Then you should add menu items to your navigation component +Then you should add menu items to your navigation menu +To access menu call `bottomBar.menu` on your navigation view ```kotlin val bottomBar: ExpandableBottomBar = findViewById(R.id.expandable_bottom_bar) - - bottomBar.addItems( - MenuItemDescriptor.Builder(context = this) - .addItem(R.id.icon_home, R.drawable.ic_bug, R.string.text, Color.GRAY) - .addItem(R.id.icon_go, R.drawable.ic_gift, R.string.text2, 0xFFFF77A9) - .addItem(R.id.icon_left, R.drawable.ic_one, R.string.text3, 0xFF58A5F0) - .addItem(R.id.icon_right, R.drawable.ic_two, R.string.text4, 0xFFBE9C91) - .build() + val menu = bottomBar.menu + + menu.add( + MenuItemDescriptor.Builder( + this, + R.id.icon_home, + R.drawable.ic_home, + R.string.text, + Color.GRAY + ) + .build() ) bottomBar.onItemSelectedListener = { view, menuItem -> @@ -185,7 +189,8 @@ Then you should reference this xml file at the view attributes /** * Returns notification object */ - val notification = bottomBar.getMenuItemFor(i.itemId).notification() // itemId is R.id.action_id + val menu = bottomBar.menu + val notification = menu.findItemById(i.itemId).notification() // itemId is R.id.action_id notification.show() // shows simple dot-notification notification.show("string literal") // shows notification with counter. Counter could not exceed the 4 symbols length diff --git a/app/src/main/java/github/com/st235/expandablebottombar/screens/NotificationBadgeActivity.kt b/app/src/main/java/github/com/st235/expandablebottombar/screens/NotificationBadgeActivity.kt index 97ad996..0a38f80 100644 --- a/app/src/main/java/github/com/st235/expandablebottombar/screens/NotificationBadgeActivity.kt +++ b/app/src/main/java/github/com/st235/expandablebottombar/screens/NotificationBadgeActivity.kt @@ -10,7 +10,6 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.graphics.ColorUtils import github.com.st235.expandablebottombar.R import github.com.st235.lib_expandablebottombar.ExpandableBottomBar -import github.com.st235.lib_expandablebottombar.Notification import kotlinx.android.synthetic.main.activity_xml_declared.* class NotificationBadgeActivity : AppCompatActivity() { diff --git a/app/src/main/java/github/com/st235/expandablebottombar/screens/ProgrammaticallyCreatedDemoActivity.kt b/app/src/main/java/github/com/st235/expandablebottombar/screens/ProgrammaticallyCreatedDemoActivity.kt index fd34d0d..d496139 100644 --- a/app/src/main/java/github/com/st235/expandablebottombar/screens/ProgrammaticallyCreatedDemoActivity.kt +++ b/app/src/main/java/github/com/st235/expandablebottombar/screens/ProgrammaticallyCreatedDemoActivity.kt @@ -2,8 +2,6 @@ package github.com.st235.expandablebottombar.screens import android.graphics.Color import android.os.Bundle -import android.os.Handler -import android.os.Looper import android.util.Log import android.view.View import android.view.ViewAnimationUtils diff --git a/gradle.properties b/gradle.properties index 9966876..25ea180 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ android.useAndroidX=true GROUP=com.github.st235 -VERSION_CODE=42 -VERSION_NAME=1.3.2 +VERSION_CODE=45 +VERSION_NAME=1.4.0 POM_DESCRIPTION=A new way to improve navigation in your app. POM_URL=https://github.com/st235/ExpandableBottomBar diff --git a/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/Menu.kt b/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/Menu.kt index 6b29666..f390f56 100644 --- a/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/Menu.kt +++ b/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/Menu.kt @@ -33,23 +33,33 @@ interface Menu: Iterable { * Programmatically select item * * @param id - identifier of menu item, which should be selected + * @throws IllegalArgumentException when menu item cannot be found */ @Throws(IllegalArgumentException::class) fun select(@IdRes id: Int) fun deselect() + /** + * Removes the given menu item + * + * @param id - identifier of menu item, which should be selected + * @throws IllegalArgumentException when menu item cannot be found + */ @Throws(IllegalArgumentException::class) fun remove(@IdRes id: Int) + /** + * Removes all menu items + */ fun removeAll() /** * Returns menu item for the given id value * - * @throws NullPointerException when id doesn't exists + * @throws IllegalArgumentException when menu item cannot be found */ @Throws(IllegalArgumentException::class) fun findItemById(@IdRes id: Int): MenuItem -} \ No newline at end of file +} diff --git a/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/MenuImpl.kt b/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/MenuImpl.kt index 119ffe8..9a80dc5 100644 --- a/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/MenuImpl.kt +++ b/lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/MenuImpl.kt @@ -161,4 +161,4 @@ internal class MenuImpl( itemsLookup[item.id]?.setAccessibleWith(prev = prev, next = next) } } -} \ No newline at end of file +}