Fix[input]: eliminate all improper calls to requestLayout();

This commit is contained in:
artdeell 2024-04-21 20:54:43 +03:00
parent 7d674f2181
commit 08bd0f2b64
2 changed files with 8 additions and 2 deletions

View File

@ -141,6 +141,12 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if(v.equals(mParentView)) repositionView();
// We need to check whether dimensions match or not because here we are looking specifically for changes of dimensions
// and Android keeps calling this without dimensions actually changing for some reason.
if(v.equals(mParentView) && (left != oldLeft || right != oldRight || top != oldTop || bottom != oldBottom)) {
// Need to post this, because it is not correct to resize the view
// during a layout pass.
post(this::repositionView);
}
}
}

View File

@ -31,7 +31,7 @@
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/main_touchpad"
android:translationZ="1dp"
android:focusable="false"
android:visibility="gone"/>