Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ android {
}

dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.iammert.readablebottombar

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.iammert.library.readablebottombar.ConfigurationXmlParser

class MainActivity : AppCompatActivity() {
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.iammert.library.readablebottombar

import android.graphics.drawable.Drawable
import android.support.annotation.ColorInt
import androidx.annotation.ColorInt
import com.iammert.library.readablebottombar.ReadableBottomBar.ItemType

data class BottomBarItem(
val index: Int,
val text: String,
val textSize: Float,
@ColorInt val textColor: Int,
val drawable: Drawable,
val type: ItemType
val index: Int,
val text: String,
val textSize: Float,
@ColorInt val textColor: Int,
val drawable: Drawable,
val type: ItemType
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package com.iammert.library.readablebottombar

import android.content.Context
import android.graphics.drawable.Drawable
import android.support.v7.widget.AppCompatImageView
import android.support.v7.widget.AppCompatTextView
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator
import android.view.animation.Animation
import android.view.animation.TranslateAnimation
import android.widget.FrameLayout
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import com.iammert.library.readablebottombar.ReadableBottomBar.Companion.ANIMATION_DURATION
import com.iammert.library.readablebottombar.ReadableBottomBar.ItemType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.iammert.library.readablebottombar
import android.content.Context
import android.content.res.XmlResourceParser
import android.graphics.drawable.Drawable
import android.support.v4.content.ContextCompat
import androidx.core.content.ContextCompat
import org.xmlpull.v1.XmlPullParserException

class ConfigurationXmlParser(private val context: Context, xmlRes: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.util.AttributeSet
import android.view.View
import android.view.ViewTreeObserver
import android.widget.LinearLayout
import java.util.ArrayList

class ReadableBottomBar @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)
: LinearLayout(context, attrs, defStyleAttr) {
Expand All @@ -27,6 +28,7 @@ class ReadableBottomBar @JvmOverloads constructor(context: Context, attrs: Attri
}

private val bottomBarItemList: List<BottomBarItem>
private val bottomBarViewItemList = ArrayList<BottomBarItemView>()

private var tabInitialSelectedIndex = 0
private var tabBackgroundColor: Int = Color.WHITE
Expand Down Expand Up @@ -75,12 +77,12 @@ class ReadableBottomBar @JvmOverloads constructor(context: Context, attrs: Attri

bottomBarItemList = bottomBarItemConfigList.map { config ->
BottomBarItem(
config.index,
config.text,
textSize,
textColor,
config.drawable,
activeItemType
config.index,
config.text,
textSize,
textColor,
config.drawable,
activeItemType
)
}

Expand All @@ -105,6 +107,12 @@ class ReadableBottomBar @JvmOverloads constructor(context: Context, attrs: Attri
this.itemSelectListener = itemSelectListener
}

fun setSelectedItem(position : Int){
getChildViewAt(position)?.callOnClick()
}

fun getChildViewAt(position : Int) = bottomBarViewItemList.getOrNull(position)

private fun drawBottomBarItems() {
val itemContainerLayout = LinearLayout(context).apply {
layoutParams = LinearLayout.LayoutParams(layoutWidth.toInt(), layoutHeight.toInt())
Expand Down Expand Up @@ -138,7 +146,7 @@ class ReadableBottomBar @JvmOverloads constructor(context: Context, attrs: Attri

}
}

bottomBarViewItemList.add(bottomBarItem)
itemContainerLayout.addView(bottomBarItem)

if (item.index == tabInitialSelectedIndex) {
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/res/layout/layout_bottombar_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.AppCompatTextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:singleLine="true" />

<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down