Archived
Upgraded dependencies; started work on entry import & export via JSON
This commit is contained in:
@@ -12,6 +12,10 @@ interface EntryDao {
|
||||
@Query("SELECT * FROM entries ORDER BY position")
|
||||
fun getAllEntries(): LiveData<List<Entry>>
|
||||
|
||||
// Get entries synchronously (no LiveData)
|
||||
@Query("SELECT * FROM entries ORDER BY position")
|
||||
fun getAllEntriesSync(): List<Entry>
|
||||
|
||||
@Insert
|
||||
fun insertEntries(newEntries: List<Entry>)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.denizd.textbasic.db
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import com.denizd.textbasic.util.SettingsPreference
|
||||
import com.google.gson.Gson
|
||||
|
||||
class QuoteStorage private constructor(context: Context) {
|
||||
|
||||
@@ -139,4 +140,10 @@ class QuoteStorage private constructor(context: Context) {
|
||||
fun noMigrationNecessary() {
|
||||
prefs.edit().putBoolean(SettingsPreference.NEEDS_MIGRATION.key, false).apply()
|
||||
}
|
||||
|
||||
fun exportEntriesAsJson(): String = Gson().toJson(dao.getAllEntriesSync().map { e -> e.text })
|
||||
|
||||
fun importEntriesFromJson(json: String) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ class QuoteFragment : BaseFragment(R.layout.fragment_quote), QuoteAdapter.OnDele
|
||||
storage.migrateEntries()
|
||||
}
|
||||
|
||||
// Log.d("asdfasdf", storage.exportEntriesAsJson())
|
||||
|
||||
quoteAdapter = QuoteAdapter(storage.getAllQuotes(), this)
|
||||
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(context)
|
||||
|
||||
Reference in New Issue
Block a user