Skip to content

Commit

Permalink
fix font type support
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimsn98 committed May 27, 2019
1 parent fc6c52a commit 95a0025
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/src/main/java/me/ibrahimsn/lib/NiceBottomBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import android.view.MotionEvent
import android.annotation.SuppressLint
import android.animation.ArgbEvaluator
import android.graphics.*
import android.os.Build

class NiceBottomBar : View {

Expand All @@ -30,7 +31,7 @@ class NiceBottomBar : View {
private var itemTextColorActive = Color.parseColor("#426dfe")
private var itemTextSize = d2p(11.0f)
private var itemBadgeColor = itemTextColorActive
private var itemFontFamilyStyle = 0
private var itemFontFamily = 0
private var activeItem = 0

private var items = listOf<BottomBarItem>()
Expand Down Expand Up @@ -78,7 +79,7 @@ class NiceBottomBar : View {
activeItem = typedArray.getInt(R.styleable.NiceBottomBar_activeItem, this.activeItem)
barIndicatorInterpolator = typedArray.getInt(R.styleable.NiceBottomBar_indicatorInterpolator, this.barIndicatorInterpolator)
itemBadgeColor = typedArray.getColor(R.styleable.NiceBottomBar_badgeColor, this.itemBadgeColor)
itemFontFamilyStyle = typedArray.getResourceId(R.styleable.NiceBottomBar_fontFamily, this.itemFontFamilyStyle)
itemFontFamily = typedArray.getResourceId(R.styleable.NiceBottomBar_itemFontFamily, this.itemFontFamily)
items = BottomBarParser(context, typedArray.getResourceId(R.styleable.NiceBottomBar_menu, 0)).parse()
typedArray.recycle()

Expand All @@ -90,8 +91,9 @@ class NiceBottomBar : View {
paintText.textSize = itemTextSize
paintBadge.color = itemBadgeColor

if (itemFontFamilyStyle != 0)
paintText.typeface = Typeface.defaultFromStyle(itemFontFamilyStyle)
if (itemFontFamily != 0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
paintText.typeface = resources.getFont(itemFontFamily)
}

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<attr name="indicatorWidth" format="dimension" />
<attr name="indicatorEnabled" format="boolean" />
<attr name="textColor" format="color" />
<attr name="fontFamily" format="reference" />
<attr name="itemFontFamily" format="reference" />
<attr name="textColorActive" format="color" />
<attr name="textSize" format="dimension" />
<attr name="iconSize" format="dimension" />
Expand Down

0 comments on commit 95a0025

Please sign in to comment.