-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
actions: refactor
BottomNavigationViewHelper
utilities to kotlin (f…
…ixes open-learning-exchange#2883) (open-learning-exchange#2888) Co-authored-by: dogi <[email protected]>
- Loading branch information
Showing
3 changed files
with
30 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
app/src/main/java/org/ole/planet/myplanet/utilities/BottomNavigationViewHelper.java
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
app/src/main/java/org/ole/planet/myplanet/utilities/BottomNavigationViewHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |