Skip to content

Commit

Permalink
Remove non-null assertions in MemoPreferencesImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
shubertm committed Nov 29, 2023
1 parent 3858f14 commit 56e0e5f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
3 changes: 0 additions & 3 deletions app/src/main/java/dev/arkbuilders/arkmemo/models/Note.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package dev.arkbuilders.arkmemo.models

import dev.arkbuilders.arklib.ResourceId
import dev.arkbuilders.arklib.data.index.Resource
import java.time.LocalDate
import java.time.format.DateTimeFormatter

interface Note {
val title: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.nio.file.Path
interface MemoPreferences {
fun storePath(path: String)

fun getPath(): String?
fun getPath(): String

fun getNotesStorage(): Path
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.arkbuilders.arkmemo.preferences
import android.content.Context
import android.content.Context.MODE_PRIVATE
import dagger.hilt.android.qualifiers.ApplicationContext
import java.nio.file.Path
import javax.inject.Inject
import kotlin.io.path.Path

Expand All @@ -22,7 +23,7 @@ class MemoPreferencesImpl @Inject constructor(@ApplicationContext context: Conte
}
}

override fun getPath() = sharedPreferences.getString(CURRENT_NOTES_PATH, null)
override fun getPath(): String = sharedPreferences.getString(CURRENT_NOTES_PATH, "") ?: ""

override fun getNotesStorage() = Path(getPath()!!)
override fun getNotesStorage(): Path = Path(getPath())
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MainActivity : AppCompatActivity(R.layout.activity_main) {

}

if (memoPreferences.getPath() == null) {
if (memoPreferences.getPath().isEmpty()) {
FilePickerDialog.show(this, supportFragmentManager)

supportFragmentManager.onArkPathPicked(this) {
Expand Down

0 comments on commit 56e0e5f

Please sign in to comment.