Skip to content

Commit

Permalink
Fix crashing on pressing back button
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed Jul 3, 2024
1 parent f4e2ade commit 4ba9bf5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,16 @@ abstract class ScopedFragment : Fragment(), SharedPreferences.OnSharedPreference
requireActivity().onBackPressedDispatcher.addCallback(this) {
Log.d(tag ?: TAG, "onBackPressed")
parentFragmentManager.popBackStackImmediate()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
requireView().clearViewTranslationCallback()

try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
requireView().clearViewTranslationCallback()
}
requireView().clearAnimation()
Log.i(TAG, "setupBackPressedDispatcher: Animations cleared")
} catch (e: IllegalStateException) {
Log.e(TAG, "setupBackPressedDispatcher: ", e)
}
requireView().clearAnimation()
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/app/simple/inure/util/FileSizeHelper.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.simple.inure.util

import android.annotation.SuppressLint
import android.os.Build
import app.simple.inure.preferences.FormattingPreferences
import java.io.File
Expand Down Expand Up @@ -120,6 +121,7 @@ object FileSizeHelper {
}
}

@SuppressLint("DefaultLocale")
private fun Long.humanReadableByteCountBinary(): String {
val absB = if (this == Long.MIN_VALUE) Long.MAX_VALUE else abs(this)
if (absB < 1024) {
Expand All @@ -137,6 +139,7 @@ object FileSizeHelper {
return String.format("%.1f %ciB", value / 1024.0, ci.current())
}

@SuppressLint("DefaultLocale")
private fun Long.humanReadableByteCountSI(): String {
var bytes = this
if (-1000 < bytes && bytes < 1000) {
Expand Down

0 comments on commit 4ba9bf5

Please sign in to comment.