Skip to content

Commit

Permalink
Merge pull request #54 from st235/fix/cleanup
Browse files Browse the repository at this point in the history
Fix/cleanup
  • Loading branch information
st235 authored Sep 11, 2020
2 parents 6af52df + 98e5db1 commit 06173aa
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 49 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ dependencies {
implementation project(':lib-expandablebottombar')

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'

implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package="github.com.st235.expandablebottombar">

<application
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ class ShowCaseAdapter(
onItemClickListener(items[adapterPosition])
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ProgrammaticallyCreatedDemoActivity : AppCompatActivity() {
anim.start()
}

bottomBar.onItemReselectedListener = { v, i ->
bottomBar.onItemReselectedListener = { _, i ->
Log.d("ExpandableBottomBar", "OnReselected: ${i.itemId}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class FirstFragment: Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_one, container, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class NavigationComponentActivity: AppCompatActivity() {
*/
ExpandableBottomBarNavigationUI.setupWithNavController(bottomNavigation, navigationController)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class SecondFragment: Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_two, container, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class ThirdFragment: Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_three, container, false)
}
}
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activiy_navigation.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand All @@ -14,7 +15,8 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/navigation" />
app:navGraph="@navigation/navigation"
tools:ignore="FragmentTagUsage" />

<github.com.st235.lib_expandablebottombar.ExpandableBottomBar
android:id="@+id/bottomNavigation"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/fragment_one.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand All @@ -9,6 +10,7 @@
android:text="Hello Fragment 1"
android:textColor="#000"
android:layout_gravity="center"
android:textSize="22sp" />
android:textSize="22sp"
tools:ignore="HardcodedText" />

</FrameLayout>
6 changes: 4 additions & 2 deletions app/src/main/res/layout/fragment_three.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello Fragment 3"
android:textColor="#000"
android:layout_gravity="center"
android:textSize="22sp" />
android:textSize="22sp"
tools:ignore="HardcodedText" />

</FrameLayout>
6 changes: 4 additions & 2 deletions app/src/main/res/layout/fragment_two.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello Fragment 2"
android:textColor="#000"
android:layout_gravity="center"
android:textSize="22sp" />
android:textSize="22sp"
tools:ignore="HardcodedText" />

</FrameLayout>
3 changes: 0 additions & 3 deletions app/src/main/res/menu/navigation_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
android:id="@+id/fragment1"
android:title="@string/text"
android:icon="@drawable/ic_home"
app:showAsAction="always"
app:exb_color="#FF8888" />

<item
android:id="@+id/fragment2"
android:title="@string/text4"
android:icon="@drawable/ic_settings"
app:showAsAction="always"
app:exb_color="@color/colorSettings" />

<item
android:id="@+id/fragment3"
android:title="@string/text3"
android:icon="@drawable/ic_bookmarks"
app:showAsAction="always"
app:exb_color="#fa2" />
</menu>
3 changes: 0 additions & 3 deletions app/src/main/res/values/dimens.xml

This file was deleted.

1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<string name="text2">Likes</string>
<string name="text3">Bookmarks</string>
<string name="text4">Settings</string>
<string name="title_activity_coordinator_layout">CoordinatorLayoutActivity</string>

<string name="programmatically_title">Manually created</string>
<string name="programmatically_description">This showcase demonstrates the basic usage of library.\nSee: https://github.com/st235/ExpandableBottomBar#usage</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext {
vers = [
versionCode: 37,
versionCode: 38,
versionName: "1.2.4"
]
info = [
Expand Down
10 changes: 5 additions & 5 deletions lib-expandablebottombar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ class ExpandableBottomBarParserTest {
ExpandableBottomBarMenuItem(R.id.icon_id, R.drawable.item_icon, iconText, Color.WHITE)
assertThat(items, contains(actualItem))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import github.com.st235.lib_expandablebottombar.ExpandableBottomBar.ItemStyle.Co
import github.com.st235.lib_expandablebottombar.behavior.ExpandableBottomBarBehavior
import github.com.st235.lib_expandablebottombar.parsers.ExpandableBottomBarParser
import github.com.st235.lib_expandablebottombar.state.SavedState
import github.com.st235.lib_expandablebottombar.utils.*
import github.com.st235.lib_expandablebottombar.utils.AnimationHelper
import github.com.st235.lib_expandablebottombar.utils.DrawableHelper
import github.com.st235.lib_expandablebottombar.utils.StyleController
import github.com.st235.lib_expandablebottombar.utils.applyForApiLAndHigher
import github.com.st235.lib_expandablebottombar.utils.clamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package github.com.st235.lib_expandablebottombar

import android.content.Context
import android.graphics.Color
import androidx.annotation.*
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.IdRes
import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import java.lang.IllegalStateException

Expand Down Expand Up @@ -91,4 +95,4 @@ data class ExpandableBottomBarMenuItem(

fun build(): List<ExpandableBottomBarMenuItem> = items
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ class ExpandableBottomBarScrollableBehavior<V: View>:
override fun onNestedScroll(coordinatorLayout: CoordinatorLayout, child: V, target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, type: Int, consumed: IntArray) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type, consumed)

if (lastKnownRunnable != null) {
handler.removeCallbacks(lastKnownRunnable)
lastKnownRunnable = null
}

removeActiveRunnable()
cancelAnimation()

lastKnownDirection = dyConsumed
Expand All @@ -49,14 +45,13 @@ class ExpandableBottomBarScrollableBehavior<V: View>:
override fun onStopNestedScroll(coordinatorLayout: CoordinatorLayout, child: V, target: View, type: Int) {
super.onStopNestedScroll(coordinatorLayout, child, target, type)

if (lastKnownRunnable != null) {
handler.removeCallbacks(lastKnownRunnable)
}
removeActiveRunnable()

lastKnownRunnable = Runnable {
val delayedAnimationRunnable = Runnable {
animateWithDirection(child)
}
handler.postDelayed(lastKnownRunnable, 500L)
handler.postDelayed(delayedAnimationRunnable, 500L)
lastKnownRunnable = delayedAnimationRunnable
}

private fun getScrollRange(child: V, dy: Int): Float {
Expand Down Expand Up @@ -98,4 +93,12 @@ class ExpandableBottomBarScrollableBehavior<V: View>:
animator = null
}
}

private fun removeActiveRunnable() {
val runnableToDelete = lastKnownRunnable
if (runnableToDelete != null) {
handler.removeCallbacks(runnableToDelete)
lastKnownRunnable = null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object ExpandableBottomBarNavigationUI {
expandableBottomBar: ExpandableBottomBar,
navigationController: NavController
) {
expandableBottomBar.onItemSelectedListener = { v, menuItem ->
expandableBottomBar.onItemSelectedListener = { _, menuItem ->
onNavDestinationSelected(menuItem, navigationController)
}

Expand Down Expand Up @@ -90,4 +90,4 @@ object ExpandableBottomBarNavigationUI {
return startDestination
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ object AnimationHelper {
fun <T: View> translateViewTo(child: T, translation: Float): Animator {
val animator = ValueAnimator.ofFloat(child.translationY, translation)
animator.interpolator = DecelerateInterpolator()
animator.addUpdateListener { animator ->
val animatedValue = animator?.animatedValue as Float
animator.addUpdateListener {
val animatedValue = it.animatedValue as Float
child.translationY = animatedValue
}

return animator
}

}
}

0 comments on commit 06173aa

Please sign in to comment.