Skip to content

Commit

Permalink
settings: more realm stability (fixes #2670) (#2671)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Nov 2, 2023
1 parent 510c414 commit adaf5f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1130
versionName "0.11.30"
versionCode 1131
versionName "0.11.31"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,9 @@ private void onLogin() {
}

public void settingDialog() {
Realm sRealm = null;
try {
mRealm = Realm.getDefaultInstance();
sRealm = Realm.getDefaultInstance();
DialogServerUrlBinding dialogServerUrlBinding = DialogServerUrlBinding.inflate(LayoutInflater.from(this));
MaterialDialog.Builder builder = new MaterialDialog.Builder(LoginActivity.this);
builder.title(R.string.action_settings)
Expand All @@ -741,7 +742,7 @@ public void settingDialog() {
positiveAction = dialog.getActionButton(DialogAction.POSITIVE);
spnCloud = dialogServerUrlBinding.spnCloud;

List<RealmCommunity> communities = mRealm.where(RealmCommunity.class).sort("weight", Sort.ASCENDING).findAll();
List<RealmCommunity> communities = sRealm.where(RealmCommunity.class).sort("weight", Sort.ASCENDING).findAll();
List<RealmCommunity> nonEmptyCommunities = new ArrayList<>();
for (RealmCommunity community : communities) {
if (community.isValid() && !TextUtils.isEmpty(community.getName())) {
Expand Down Expand Up @@ -779,8 +780,8 @@ public void onNothingSelected(AdapterView<?> adapterView) {
dialog.show();
sync(dialog);
} finally {
if (mRealm != null && !mRealm.isClosed()) {
mRealm.close();
if (sRealm != null && !sRealm.isClosed()) {
sRealm.close();
}
}
}
Expand All @@ -789,11 +790,10 @@ private void onChangeServerUrl() {
try {
mRealm = Realm.getDefaultInstance();
RealmCommunity selected = (RealmCommunity) spnCloud.getSelectedItem();
Utilities.log((selected == null) + " selected ");
if (selected == null) {
return;
}
if (selected.isValid()){
if (selected.isValid()) {
serverUrl.setText(selected.getLocalDomain());
protocol_checkin.check(R.id.radio_https);
settings.getString("serverProtocol", "https://");
Expand Down

0 comments on commit adaf5f6

Please sign in to comment.