Skip to content

Commit

Permalink
Add interface to set badge drawable
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshixin committed Sep 20, 2016
1 parent 95eb1d3 commit 9aa70c2
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.chenshixin.bottomnavigation

import android.content.Context
import android.graphics.drawable.Drawable
import android.support.design.widget.CoordinatorLayout
import android.support.v4.app.FragmentStatePagerAdapter
import android.support.v4.app.FragmentPagerAdapter
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.ViewGroup
Expand Down Expand Up @@ -46,8 +47,10 @@ class BottomNavigation(context: Context?, attrs: AttributeSet?) : CoordinatorLay
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}

fun setFragmentPagerAdapter(fragmentPagerAdapter: FragmentStatePagerAdapter) {
fun setFragmentPagerAdapter(fragmentPagerAdapter: FragmentPagerAdapter) {
bottom_navigation_view_pager.adapter = fragmentPagerAdapter
//Cache all pages
bottom_navigation_view_pager.offscreenPageLimit = fragmentPagerAdapter.count - 1
}

fun setTabItems(tabs: List<BottomNavigationItem>) {
Expand Down Expand Up @@ -86,6 +89,10 @@ class BottomNavigation(context: Context?, attrs: AttributeSet?) : CoordinatorLay
bottom_navigation_bar.tabs[index].setBadgeNumber(number)
}

fun setBadgeDrawable(drawable: Drawable) {
bottom_navigation_bar.setBadgeBackground(drawable)
}

fun setItemTitle(index: Int, title: String) {
bottom_navigation_bar.tabs[index].setTitle(title)
}
Expand Down

0 comments on commit 9aa70c2

Please sign in to comment.