Minor cleanup in calls to getContext()

This commit is contained in:
Sam Lantinga
2025-10-02 10:49:31 -07:00
parent ed6b6bb7fc
commit 11a66bd18c

View File

@@ -894,7 +894,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
protected static class SDLCommandHandler extends Handler { protected static class SDLCommandHandler extends Handler {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
Context context = SDL.getContext(); Context context = getContext();
if (context == null) { if (context == null) {
Log.e(TAG, "error handling message, getContext() returned null"); Log.e(TAG, "error handling message, getContext() returned null");
return; return;
@@ -1018,7 +1018,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
} }
} }
if (bShouldWait && (SDLActivity.getContext() != null)) { if (bShouldWait && (getContext() != null)) {
// We'll wait for the surfaceChanged() method, which will notify us // We'll wait for the surfaceChanged() method, which will notify us
// when called. That way, we know our current size is really the // when called. That way, we know our current size is really the
// size we need, instead of grabbing a size that's still got // size we need, instead of grabbing a size that's still got
@@ -1028,9 +1028,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
// take a surprisingly long time for the surface resize, but // take a surprisingly long time for the surface resize, but
// then we'll just give up and return. // then we'll just give up and return.
// //
synchronized (SDLActivity.getContext()) { synchronized (getContext()) {
try { try {
SDLActivity.getContext().wait(500); getContext().wait(500);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
ie.printStackTrace(); ie.printStackTrace();
} }
@@ -1213,7 +1213,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return false; return false;
} }
InputMethodManager imm = (InputMethodManager) SDL.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
return imm.isAcceptingText(); return imm.isAcceptingText();
} }
@@ -1423,7 +1423,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
params.topMargin = y; params.topMargin = y;
if (mTextEdit == null) { if (mTextEdit == null) {
mTextEdit = new SDLDummyEdit(SDL.getContext()); mTextEdit = new SDLDummyEdit(getContext());
mLayout.addView(mTextEdit, params); mLayout.addView(mTextEdit, params);
} else { } else {
@@ -1434,7 +1434,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
mTextEdit.setVisibility(View.VISIBLE); mTextEdit.setVisibility(View.VISIBLE);
mTextEdit.requestFocus(); mTextEdit.requestFocus();
InputMethodManager imm = (InputMethodManager) SDL.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mTextEdit, 0); imm.showSoftInput(mTextEdit, 0);
mScreenKeyboardShown = true; mScreenKeyboardShown = true;
@@ -1928,7 +1928,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
} }
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) { if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
try { try {
mSurface.setPointerIcon(PointerIcon.getSystemIcon(SDL.getContext(), cursor_type)); mSurface.setPointerIcon(PointerIcon.getSystemIcon(getContext(), cursor_type));
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }