Skip to content

Commit

Permalink
actions: refactor BottomNavigationViewHelper utilities to kotlin (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 and dogi authored Dec 27, 2023
1 parent d2fc210 commit bc49076
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1237
versionName "0.12.37"
versionCode 1238
versionName "0.12.38"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.ole.planet.myplanet.utilities

import android.annotation.SuppressLint
import com.google.android.material.bottomnavigation.BottomNavigationItemView
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
import com.google.android.material.bottomnavigation.BottomNavigationView

object BottomNavigationViewHelper {
@JvmStatic
@SuppressLint("RestrictedApi")
fun disableShiftMode(view: BottomNavigationView) {
val menuView = view.getChildAt(0) as BottomNavigationMenuView
try {
val shiftingMode = menuView.javaClass.getDeclaredField("mShiftingMode")
shiftingMode.isAccessible = true
shiftingMode.setBoolean(menuView, false)
shiftingMode.isAccessible = false
for (i in 0 until menuView.childCount) {
val item = menuView.getChildAt(i) as BottomNavigationItemView
item.setChecked(item.itemData!!.isChecked)
}
} catch (e: NoSuchFieldException) {
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
}
}
}

0 comments on commit bc49076

Please sign in to comment.