Skip to content

Commit

Permalink
ConfigActivity: fix NPE from onResume
Browse files Browse the repository at this point in the history
  • Loading branch information
woesss committed Feb 13, 2021
1 parent 98c1854 commit d35d6c2
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public class ConfigActivity extends BaseActivity implements View.OnClickListener
private View shaderContainer;
private ImageButton btShaderTune;
private String workDir;
private boolean needShow;

@SuppressLint({"StringFormatMatches", "StringFormatInvalid"})
@Override
Expand All @@ -149,9 +150,10 @@ public void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
String action = intent.getAction();
isProfile = ACTION_EDIT_PROFILE.equals(action);
boolean showSettings = isProfile || ACTION_EDIT.equals(action);
needShow = isProfile || ACTION_EDIT.equals(action);
String path = intent.getDataString();
if (path == null) {
needShow = false;
finish();
return;
}
Expand All @@ -165,6 +167,7 @@ public void onCreate(Bundle savedInstanceState) {
File convertedDir = appDir.getParentFile();
if (!appDir.isDirectory() || convertedDir == null
|| (workDir = convertedDir.getParent()) == null) {
needShow = false;
String storageName = "";
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);
Expand Down Expand Up @@ -195,7 +198,8 @@ public void onCreate(Bundle savedInstanceState) {
defProfile = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
.getString(PREF_DEFAULT_PROFILE, null);
loadConfig();
if (!params.isNew && !showSettings) {
if (!params.isNew && !needShow) {
needShow = false;
startMIDlet();
return;
}
Expand Down Expand Up @@ -553,7 +557,7 @@ private void loadKeyLayout() {

@Override
public void onPause() {
if (configDir != null) {
if (needShow && configDir != null) {
saveParams();
}
super.onPause();
Expand All @@ -562,7 +566,9 @@ public void onPause() {
@Override
protected void onResume() {
super.onResume();
loadParams(true);
if (needShow) {
loadParams(true);
}
}

@Override
Expand Down

0 comments on commit d35d6c2

Please sign in to comment.