Android: Fix possible crash in TouchscreenControllerView

This commit is contained in:
Connor McLaughlin 2020-10-11 14:51:14 +10:00
parent 7775774761
commit 2ce9baa8ad

View file

@ -44,9 +44,6 @@ public class TouchscreenControllerView extends FrameLayout {
LayoutInflater inflater = LayoutInflater.from(getContext()); LayoutInflater inflater = LayoutInflater.from(getContext());
switch (viewType) switch (viewType)
{ {
case "none":
break;
case "digital": case "digital":
mMainView = inflater.inflate(R.layout.layout_touchscreen_controller_digital, this, true); mMainView = inflater.inflate(R.layout.layout_touchscreen_controller_digital, this, true);
break; break;
@ -59,11 +56,15 @@ public class TouchscreenControllerView extends FrameLayout {
mMainView = inflater.inflate(R.layout.layout_touchscreen_controller_analog_sticks, this, true); mMainView = inflater.inflate(R.layout.layout_touchscreen_controller_analog_sticks, this, true);
break; break;
case "none":
default: default:
mMainView = null; mMainView = null;
break; break;
} }
if (mMainView == null)
return;
mMainView.setOnTouchListener((view1, event) -> { mMainView.setOnTouchListener((view1, event) -> {
return handleTouchEvent(event); return handleTouchEvent(event);
}); });