Skip to content

Commit

Permalink
refactor: use updateLayoutParams() extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy-Geenexus committed Aug 30, 2024
1 parent 961a972 commit 172f53e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.core.os.bundleOf
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupActionBarWithNavController
Expand Down Expand Up @@ -85,13 +86,11 @@ class ExifEraserActivity : AppCompatActivity() {
val insets = windowInsetsCompat.getInsets(
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
)
root.setLayoutParams(
(root.layoutParams as FrameLayout.LayoutParams).apply {
leftMargin = insets.left
topMargin = insets.top
rightMargin = insets.right
}
)
root.updateLayoutParams<FrameLayout.LayoutParams> {
leftMargin = insets.left
topMargin = insets.top
rightMargin = insets.right
}
windowInsetsCompat
}
root.addView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import android.widget.FrameLayout
import androidx.core.net.toUri
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.transition.MaterialSharedAxis
import com.none.tom.exiferaser.R
Expand All @@ -52,11 +53,7 @@ class HelpFragment :
super.onViewCreated(view, savedInstanceState)
ViewCompat.setOnApplyWindowInsetsListener(view) { _, windowInsetsCompat ->
val insets = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.navigationBars())
view.setLayoutParams(
(view.layoutParams as FrameLayout.LayoutParams).apply {
bottomMargin = insets.bottom
}
)
view.updateLayoutParams<FrameLayout.LayoutParams> { bottomMargin = insets.bottom }
WindowInsetsCompat.CONSUMED
}
binding.helpAndFeedback.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ class ImageProcessingFragment : BaseFragment<FragmentImageProcessingBinding>(
super.onViewCreated(view, savedInstanceState)
ViewCompat.setOnApplyWindowInsetsListener(view) { _, windowInsetsCompat ->
val insets = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.navigationBars())
view.setLayoutParams(
(view.layoutParams as FrameLayout.LayoutParams).apply {
bottomMargin = insets.bottom
}
)
view.updateLayoutParams<FrameLayout.LayoutParams> { bottomMargin = insets.bottom }
WindowInsetsCompat.CONSUMED
}
val menuProvider = object : MenuProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.doOnLayout
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -100,11 +101,7 @@ class ImageProcessingDetailsFragment :
super.onViewCreated(view, savedInstanceState)
ViewCompat.setOnApplyWindowInsetsListener(view) { _, windowInsetsCompat ->
val insets = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.navigationBars())
view.setLayoutParams(
(view.layoutParams as FrameLayout.LayoutParams).apply {
bottomMargin = insets.bottom
}
)
view.updateLayoutParams<FrameLayout.LayoutParams> { bottomMargin = insets.bottom }
WindowInsetsCompat.CONSUMED
}
binding.details.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.activity.result.contract.ActivityResultContracts.OpenDocumentTre
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.setFragmentResultListener
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
Expand Down Expand Up @@ -77,11 +78,7 @@ class SettingsFragment :
super.onViewCreated(view, savedInstanceState)
ViewCompat.setOnApplyWindowInsetsListener(view) { _, windowInsetsCompat ->
val insets = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.navigationBars())
view.setLayoutParams(
(view.layoutParams as FrameLayout.LayoutParams).apply {
bottomMargin = insets.bottom
}
)
view.updateLayoutParams<FrameLayout.LayoutParams> { bottomMargin = insets.bottom }
WindowInsetsCompat.CONSUMED
}
binding.preferences.apply {
Expand Down

0 comments on commit 172f53e

Please sign in to comment.