Skip to content

Commit

Permalink
better null handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bellerbrock committed Sep 8, 2023
1 parent 7402053 commit c17771f
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import androidx.documentfile.provider.DocumentFile;
import androidx.preference.ListPreference;
Expand All @@ -16,8 +15,6 @@
import com.fieldbook.tracker.activities.DefineStorageActivity;
import com.fieldbook.tracker.activities.PreferencesActivity;

import java.util.Objects;

import org.phenoapps.utils.BaseDocumentTreeUtil;

public class GeneralPreferencesFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceChangeListener {
Expand Down Expand Up @@ -260,8 +257,12 @@ public void onResume() {

if (root != null && root.exists()) {

String path = Objects.requireNonNull(root.getUri().getLastPathSegment());
Log.d("GeneralPreferencesFragment", "path: " + path);
String path = root.getUri().getLastPathSegment();
if (path == null) {
// default to directory name if path is null
path = BaseDocumentTreeUtil.Companion.getStem(root.getUri(), context)
}

defaultStorageLocation.setSummary(path);

}
Expand Down

0 comments on commit c17771f

Please sign in to comment.