fix NPE and update keyboard visibility

This commit is contained in:
Anthony Calosa
2024-10-31 17:28:30 +08:00
parent 550f738833
commit 52d77c6862
3 changed files with 9 additions and 5 deletions

View File

@@ -159,7 +159,6 @@ public class Forge implements ApplicationListener {
public void create() {
//install our error handler
ExceptionHandler.registerErrorHandling();
FThreads.invokeInEdtLater(() -> getDeviceAdapter().closeSplashScreen());
GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android);
@@ -258,6 +257,8 @@ public class Forge implements ApplicationListener {
/* call preloadExtendedArt here, if we put it above we will *
* get error: No OpenGL context found in the current thread. */
preloadExtendedArt();
// should be after create method but try to close this at a later time.
getDeviceAdapter().closeSplashScreen();
});
};
//see if app or assets need updating
@@ -1092,7 +1093,7 @@ public class Forge implements ApplicationListener {
System.out.println(message);
}
public static void startKeyInput(KeyInputAdapter adapter, boolean numeric) {
public static void startKeyInput(KeyInputAdapter adapter) {
if (keyInputAdapter == adapter) {
return;
}
@@ -1100,7 +1101,9 @@ public class Forge implements ApplicationListener {
keyInputAdapter.onInputEnd(); //make sure previous adapter is ended
}
keyInputAdapter = adapter;
Gdx.input.setOnscreenKeyboardVisible(true, numeric ? Input.OnscreenKeyboardType.NumberPad : Input.OnscreenKeyboardType.Default);
}
public static void setOnScreenKeyboard(boolean val, boolean numeric) {
Gdx.input.setOnscreenKeyboardVisible(val, numeric ? Input.OnscreenKeyboardType.NumberPad : Input.OnscreenKeyboardType.Default);
}
public static boolean endKeyInput() {

View File

@@ -676,7 +676,7 @@ public class CardImageRenderer {
if (cv == null || isFaceDown)
cv = card;
CardStateView csv = cv.getState(true);
text = cv.getText(csv, needTranslation ? CardTranslation.getTranslationTexts(csv) : null);
text = cv.getText(csv, needTranslation && csv != null ? CardTranslation.getTranslationTexts(csv) : null);
} else {
text = !card.isSplitCard() ?

View File

@@ -234,6 +234,7 @@ public class FTextField extends FDisplayObject implements ITextField {
public boolean startEdit() {
if (readOnly) { return false; }
Forge.setOnScreenKeyboard(true, isNumeric);
if (isEditing) { return true; } //do nothing if already editing
selStart = 0; //select all before starting input
@@ -345,7 +346,7 @@ public class FTextField extends FDisplayObject implements ITextField {
public void onInputEnd() {
endEdit();
}
}, isNumeric);
});
isEditing = true;
return true;
}