Skip to content

Commit 5868f06

Browse files
committed
Prevent NPE and log ex through debugtool not log
1 parent 894f894 commit 5868f06

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,16 @@ public void resizeView(final int newWidth, final int newHeight) {
133133
@Override
134134
public void run() {
135135
try {
136-
Constructor<? extends ViewGroup.LayoutParams> ctor =
137-
mainView.getLayoutParams().getClass().getDeclaredConstructor(int.class, int.class);
138-
mainView.setLayoutParams(ctor.newInstance(newWidth, newHeight));
139-
mainView.requestLayout();
140-
invalidate();
141-
onViewResized(newWidth, newHeight);
136+
if (mainView != null) {
137+
Constructor<? extends ViewGroup.LayoutParams> ctor =
138+
mainView.getLayoutParams().getClass().getDeclaredConstructor(int.class, int.class);
139+
mainView.setLayoutParams(ctor.newInstance(newWidth, newHeight));
140+
mainView.requestLayout();
141+
invalidate();
142+
onViewResized(newWidth, newHeight);
143+
}
142144
} catch (Exception e) {
143-
e.printStackTrace();
145+
DebugTool.logError(TAG, "Exception thrown during view resize", e);
144146
}
145147
}
146148
});

0 commit comments

Comments
 (0)