Fix onApplyWindowInsets infinite call
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,7 +3,7 @@
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="../../../../../../layout/custom_preview.xml" value="0.284375" />
|
||||
<entry key="../../../../../../layout/custom_preview.xml" value="0.1" />
|
||||
<entry key="../../../../../../opt/usr/android-sdk/platforms/android-30/data/res/drawable/list_divider_material.xml" value="0.28512820512820514" />
|
||||
<entry key="../../../../../../opt/usr/android-sdk/platforms/android-30/data/res/layout/simple_dropdown_item_1line.xml" value="0.24739583333333334" />
|
||||
<entry key="../../../../.gradle/caches/transforms-3/0998d1b3fbd6b77213a827054a7dfcfd/transformed/appcompat-1.2.0/res/layout/abc_alert_dialog_material.xml" value="0.25885416666666666" />
|
||||
|
||||
@@ -31,6 +31,8 @@ abstract class BaseActivity<B : ViewBinding> : AppCompatActivity(), OnApplyWindo
|
||||
ExceptionResolver(this, supportFragmentManager)
|
||||
}
|
||||
|
||||
private var lastInsets: Insets = Insets.NONE
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
if (get<AppSettings>().isAmoledTheme) {
|
||||
setTheme(R.style.AppTheme_Amoled)
|
||||
@@ -61,7 +63,11 @@ abstract class BaseActivity<B : ViewBinding> : AppCompatActivity(), OnApplyWindo
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat {
|
||||
val baseInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
|
||||
onWindowInsetsChanged(Insets.max(baseInsets, imeInsets))
|
||||
val newInsets = Insets.max(baseInsets, imeInsets)
|
||||
if (newInsets != lastInsets) {
|
||||
onWindowInsetsChanged(newInsets)
|
||||
lastInsets = newInsets
|
||||
}
|
||||
return insets
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ abstract class BaseFragment<B : ViewBinding> : Fragment(), OnApplyWindowInsetsLi
|
||||
ExceptionResolver(viewLifecycleOwner, childFragmentManager)
|
||||
}
|
||||
|
||||
private var lastInsets: Insets = Insets.NONE
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
@@ -54,7 +56,11 @@ abstract class BaseFragment<B : ViewBinding> : Fragment(), OnApplyWindowInsetsLi
|
||||
}
|
||||
|
||||
override fun onApplyWindowInsets(v: View?, insets: WindowInsetsCompat): WindowInsetsCompat {
|
||||
onWindowInsetsChanged(insets.getInsets(WindowInsetsCompat.Type.systemBars()))
|
||||
val newInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
if (newInsets != lastInsets) {
|
||||
onWindowInsetsChanged(newInsets)
|
||||
lastInsets = newInsets
|
||||
}
|
||||
return insets
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user