fixed several NullPointerExceptions related to the MainView
This commit is contained in:
parent
267436c4b4
commit
6e0113c0d5
3 changed files with 30 additions and 11 deletions
|
|
@ -2,6 +2,8 @@ package io.github.sspanak.tt9.ui.main;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.ime.TraditionalT9;
|
import io.github.sspanak.tt9.ime.TraditionalT9;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.util.Logger;
|
import io.github.sspanak.tt9.util.Logger;
|
||||||
|
|
@ -10,7 +12,7 @@ public class MainView {
|
||||||
private final static String LOG_TAG = MainView.class.getSimpleName();
|
private final static String LOG_TAG = MainView.class.getSimpleName();
|
||||||
|
|
||||||
protected final TraditionalT9 tt9;
|
protected final TraditionalT9 tt9;
|
||||||
protected BaseMainLayout main;
|
@Nullable protected BaseMainLayout main;
|
||||||
private boolean darkTheme;
|
private boolean darkTheme;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -60,8 +62,9 @@ public class MainView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public View getView() {
|
public View getView() {
|
||||||
return main.getView();
|
return main != null ? main.getView() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render() {
|
public void render() {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,10 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (main == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
main.getView().removeOnAttachStateChangeListener(this);
|
main.getView().removeOnAttachStateChangeListener(this);
|
||||||
main.getView().addOnAttachStateChangeListener(this);
|
main.getView().addOnAttachStateChangeListener(this);
|
||||||
|
|
||||||
|
|
@ -63,8 +67,10 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
|
||||||
|
|
||||||
@Override public void onViewDetachedFromWindow(@NonNull View v) {}
|
@Override public void onViewDetachedFromWindow(@NonNull View v) {}
|
||||||
@Override public void onViewAttachedToWindow(@NonNull View v) {
|
@Override public void onViewAttachedToWindow(@NonNull View v) {
|
||||||
main.preventEdgeToEdge();
|
if (main != null) {
|
||||||
setHeight(height, heightSmall, heightNumpad);
|
main.preventEdgeToEdge();
|
||||||
|
setHeight(height, heightSmall, heightNumpad);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -136,6 +142,10 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
|
||||||
|
|
||||||
|
|
||||||
private void expand(int delta) {
|
private void expand(int delta) {
|
||||||
|
if (main == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SettingsStore settings = tt9.getSettings();
|
SettingsStore settings = tt9.getSettings();
|
||||||
|
|
||||||
if (settings.isMainLayoutTray()) {
|
if (settings.isMainLayoutTray()) {
|
||||||
|
|
@ -159,7 +169,7 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
|
||||||
private void shrink(int delta) {
|
private void shrink(int delta) {
|
||||||
SettingsStore settings = tt9.getSettings();
|
SettingsStore settings = tt9.getSettings();
|
||||||
|
|
||||||
if (settings.isMainLayoutTray()) {
|
if (main == null || settings.isMainLayoutTray()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,7 +190,7 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
|
||||||
|
|
||||||
|
|
||||||
private boolean changeHeight(int delta, int minHeight, int maxHeight) {
|
private boolean changeHeight(int delta, int minHeight, int maxHeight) {
|
||||||
int keyboardHeight = main.getKeyboardHeight();
|
int keyboardHeight = main != null ? main.getKeyboardHeight() : -1;
|
||||||
if (keyboardHeight == 0) {
|
if (keyboardHeight == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +200,7 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
|
||||||
|
|
||||||
|
|
||||||
private boolean setHeight(int height, int minHeight, int maxHeight) {
|
private boolean setHeight(int height, int minHeight, int maxHeight) {
|
||||||
if (main == null || main.getView() == null || height < minHeight) {
|
if (main == null || height < minHeight) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,6 +214,10 @@ public class ResizableMainView extends MainView implements View.OnAttachStateCha
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fitMain() {
|
private void fitMain() {
|
||||||
|
if (main == null || main instanceof MainLayoutStealth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
calculateSnapHeights();
|
calculateSnapHeights();
|
||||||
int heightLow, heightHigh, heightMain = main.getHeight(true);
|
int heightLow, heightHigh, heightMain = main.getHeight(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,20 @@ package io.github.sspanak.tt9.ui.tray;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.ime.modes.InputMode;
|
import io.github.sspanak.tt9.ime.modes.InputMode;
|
||||||
import io.github.sspanak.tt9.ime.voice.VoiceInputOps;
|
import io.github.sspanak.tt9.ime.voice.VoiceInputOps;
|
||||||
import io.github.sspanak.tt9.util.Logger;
|
import io.github.sspanak.tt9.util.Logger;
|
||||||
|
|
||||||
public class StatusBar {
|
public class StatusBar {
|
||||||
private final TextView statusView;
|
@Nullable private final TextView statusView;
|
||||||
private String statusText;
|
@Nullable private String statusText;
|
||||||
|
|
||||||
|
|
||||||
public StatusBar(View mainView) {
|
public StatusBar(@Nullable View mainView) {
|
||||||
statusView = mainView.findViewById(R.id.status_bar);
|
statusView = mainView != null ? mainView.findViewById(R.id.status_bar) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue