Skip to content

Commit

Permalink
mylife: smoother references dictionary (fixes #5118) (#5148)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
pavi38 and dogi authored Jan 31, 2025
1 parent e3a0620 commit aeab732
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 26
targetSdkVersion 34
versionCode 2260
versionName "0.22.60"
versionCode 2261
versionName "0.22.61"
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 @@ -40,28 +40,32 @@ class DictionaryActivity : BaseActivity() {
}

private fun insertDictionary() {
if (list?.size == 0) {
val data = FileUtils.getStringFromFile(FileUtils.getSDPathFromUrl(Constants.DICTIONARY_URL))
val json = Gson().fromJson(data, JsonArray::class.java)
mRealm.executeTransactionAsync {
json.forEach { js ->
val doc = js.asJsonObject
var dict = it.where(RealmDictionary::class.java)
?.equalTo("id", UUID.randomUUID().toString())?.findFirst()
if (dict == null) {
dict = it.createObject(
RealmDictionary::class.java, UUID.randomUUID().toString()
)
if (list.isNullOrEmpty()) {
try {
val data = FileUtils.getStringFromFile(FileUtils.getSDPathFromUrl(Constants.DICTIONARY_URL))
val json = Gson().fromJson(data, JsonArray::class.java)
mRealm.executeTransactionAsync {
json?.forEach { js ->
val doc = js.asJsonObject
var dict = it.where(RealmDictionary::class.java)
?.equalTo("id", UUID.randomUUID().toString())?.findFirst()
if (dict == null) {
dict = it.createObject(
RealmDictionary::class.java, UUID.randomUUID().toString()
)
}
dict?.code = JsonUtils.getString("code", doc)
dict?.language = JsonUtils.getString("language", doc)
dict?.advanceCode = JsonUtils.getString("advance_code", doc)
dict?.word = JsonUtils.getString("word", doc)
dict?.meaning = JsonUtils.getString("meaning", doc)
dict?.definition = JsonUtils.getString("definition", doc)
dict?.synonym = JsonUtils.getString("synonym", doc)
dict?.antonym = JsonUtils.getString("antonoym", doc)
}
dict?.code = JsonUtils.getString("code", doc)
dict?.language = JsonUtils.getString("language", doc)
dict?.advanceCode = JsonUtils.getString("advance_code", doc)
dict?.word = JsonUtils.getString("word", doc)
dict?.meaning = JsonUtils.getString("meaning", doc)
dict?.definition = JsonUtils.getString("definition", doc)
dict?.synonym = JsonUtils.getString("synonym", doc)
dict?.antonym = JsonUtils.getString("antonoym", doc)
}
} catch (e: Exception) {
e.printStackTrace()
}
} else {
setClickListener()
Expand Down

0 comments on commit aeab732

Please sign in to comment.