Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update realm in build gradle and start models migration (fixes #4773) #4774

Draft
wants to merge 57 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6724903
update realm in build gradle and start models migration
Okuro3499 Nov 13, 2024
f307e8c
Merge branch 'master' into 4773-migrate-to-realm-kotlin-sdk
Okuro3499 Nov 20, 2024
2db88db
more models migrated to kotlin
Okuro3499 Nov 20, 2024
f95444b
Merge branch 'master' into 4773-migrate-to-realm-kotlin-sdk
Okuro3499 Nov 22, 2024
da5e814
migrate more realm models to the kotlin sdk
Okuro3499 Nov 22, 2024
4accf1a
Update DatabaseService.kt
Okuro3499 Nov 22, 2024
bd69e86
update file class name
Okuro3499 Nov 25, 2024
3288ea7
Merge branch '4773-migrate-to-realm-kotlin-sdk' of https://github.com…
Okuro3499 Nov 25, 2024
dbfe2b7
Merge branch 'master' into 4773-migrate-to-realm-kotlin-sdk
Okuro3499 Nov 25, 2024
94135c3
migrate more file to kotlin realm sdk
Okuro3499 Nov 26, 2024
254dd48
migrate realmMylife
Okuro3499 Dec 3, 2024
f5f95ce
migrate realm rating
Okuro3499 Dec 6, 2024
dcee5de
migrate realm feedback
Okuro3499 Dec 6, 2024
8064d85
migrate realm myhealthpojo
Okuro3499 Dec 6, 2024
ae8c364
migrate realm realmStepExam and realmExamQuestion
Okuro3499 Dec 6, 2024
27389ba
delete commented code
Okuro3499 Dec 6, 2024
3d6fa7f
migrate more classes to kotlin realm
Okuro3499 Dec 9, 2024
443631a
migrate realmMyTeam
Okuro3499 Dec 10, 2024
3f4ff4a
migrate realmMyCourse and course progress
Okuro3499 Dec 10, 2024
bf5931f
migrate realmMyLibrary
Okuro3499 Dec 11, 2024
1a85145
migrate mainapplication
Okuro3499 Dec 11, 2024
28b82d0
cleanup
Okuro3499 Dec 11, 2024
6de988b
migrate baseContainer fragment
Okuro3499 Dec 11, 2024
b8fcf7c
migrate baseNewsFragment
Okuro3499 Dec 11, 2024
b62f96c
migrate baseRecyclerFragment
Okuro3499 Dec 11, 2024
381b3ab
migrate baseRecyclerParentFragment
Okuro3499 Dec 11, 2024
158d240
migrate baseRecyclerFragment
Okuro3499 Dec 13, 2024
588bc99
migrate manager sync
Okuro3499 Dec 13, 2024
74f6229
migrate myDownload service
Okuro3499 Dec 13, 2024
60b1a51
migrate service class to the kotlin realmsdk
Okuro3499 Dec 13, 2024
b4bc457
Merge branch 'master' into 4773-migrate-to-realm-kotlin-sdk
Okuro3499 Dec 13, 2024
4dbe865
resolve realmCourseProgress error
Okuro3499 Dec 17, 2024
7063068
migrate syncManager and task notification worker
Okuro3499 Dec 18, 2024
3f94d5f
migrate transaction syncManager
Okuro3499 Dec 18, 2024
31f96b6
Merge branch 'master' into 4773-migrate-to-realm-kotlin-sdk
Okuro3499 Dec 18, 2024
56c88fb
migrate service to realm kotlin sdk
Okuro3499 Dec 20, 2024
65d7834
migrate uploadManager to realm kotlin sdk
Okuro3499 Dec 20, 2024
9f11501
migrate uploadToShelfService to realm kotlin sdk
Okuro3499 Dec 20, 2024
0afd532
migrate UserProfileDbHandler to realm kotlin sdk
Okuro3499 Dec 20, 2024
5512adb
migrate settingsActivity
Okuro3499 Dec 23, 2024
ad0920f
migrate chatDetailFragment
Okuro3499 Dec 23, 2024
15af9d0
migrate chatHistoryListAdapter
Okuro3499 Dec 23, 2024
7629826
migrate chatHistoryListFragment
Okuro3499 Dec 23, 2024
6155cb2
migrate AddLinkFragment
Okuro3499 Dec 23, 2024
6886fa2
migrate community fragment
Okuro3499 Dec 27, 2024
8c5d777
migrate serviceFragment
Okuro3499 Dec 27, 2024
f061879
migrate adapterCourses and adapterSteps
Okuro3499 Dec 27, 2024
6ff90cd
migrate courseDetailFragment
Okuro3499 Dec 28, 2024
134be2e
migrate CourseProgressActivity
Okuro3499 Jan 2, 2025
cb245b5
migrate courseStepFragment
Okuro3499 Jan 2, 2025
7888348
migrate CoursesFragment
Okuro3499 Jan 2, 2025
5e80e93
migrate MyProgressFragment
Okuro3499 Jan 2, 2025
3b8196c
migrate takeCourseFragment
Okuro3499 Jan 2, 2025
766ed06
migrate baseDashboardFragment
Okuro3499 Jan 3, 2025
2fe24fb
migrate BaseDashboardFragmentPlugin
Okuro3499 Jan 3, 2025
73b7899
resolve realm submission error
Okuro3499 Jan 3, 2025
154ff6f
migrate BaseDashboardFragment
Okuro3499 Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
migrate baseRecyclerParentFragment
Okuro3499 committed Dec 11, 2024

Verified

This commit was signed with the committer’s verified signature.
jodal Stein Magnus Jodal
commit 381b3ab094cb7f7cf518791e50ec1e2eab5bc904
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.ole.planet.myplanet.base

import com.google.gson.JsonArray
import io.realm.RealmModel
import io.realm.Sort
import io.realm.kotlin.ext.query
import io.realm.kotlin.query.Sort
import org.ole.planet.myplanet.MainApplication.Companion.realm
import org.ole.planet.myplanet.model.RealmMyCourse
import org.ole.planet.myplanet.model.RealmMyLibrary
import org.ole.planet.myplanet.model.RealmStepExam
@@ -14,21 +15,21 @@ abstract class BaseRecyclerParentFragment<LI> : BaseResourceFragment() {
fun getList(c: Class<*>): List<LI> {
return when {
c == RealmStepExam::class.java -> {
mRealm.where(c).equalTo("type", "surveys").findAll().toList() as List<LI>
realm.query<RealmStepExam>("type == $0", "surveys").find() as List<LI>
}
isMyCourseLib -> {
getMyLibItems(c as Class<out RealmModel>)
getMyLibItems(c)
}
c == RealmMyLibrary::class.java -> {
RealmMyLibrary.getOurLibrary(model?.id, mRealm.where(c).equalTo("isPrivate", false).findAll().toList()) as List<LI>
val results = realm.query<RealmMyLibrary>("isPrivate == $0", false).find()
RealmMyLibrary.getOurLibrary(model?.id, results) as List<LI>
}
else -> {
val myLibItems = getMyLibItems(c as Class<out RealmModel>)
val results: List<RealmMyCourse> = mRealm.where(RealmMyCourse::class.java)
.isNotEmpty("courseTitle")
.findAll()
.toList()
val ourCourseItems = RealmMyCourse.getOurCourse(model?.id, results)
val myLibItems = getMyLibItems(c)
val results = realm.query<RealmMyCourse>()
.query("courseTitle != $0", "")
.find()
val ourCourseItems = RealmMyCourse.getOurCourse(model?.id ?: "", results)

when (c) {
RealmMyCourse::class.java -> {
@@ -57,47 +58,54 @@ abstract class BaseRecyclerParentFragment<LI> : BaseResourceFragment() {
fun getList(c: Class<*>, orderBy: String? = null, sort: Sort = Sort.ASCENDING): List<LI> {
return when {
c == RealmStepExam::class.java -> {
mRealm.where(c).equalTo("type", "surveys").sort(orderBy ?: "", sort).findAll().toList() as List<LI>
realm.query<RealmStepExam>("type == $0", "surveys").apply {
orderBy?.let { sort(it, sort) }
}.find() as List<LI>
}
isMyCourseLib -> {
getMyLibItems(c as Class<out RealmModel>, orderBy)
getMyLibItems(c, orderBy)
}
c == RealmMyLibrary::class.java -> {
RealmMyLibrary.getOurLibrary(model?.id, mRealm.where(c).equalTo("isPrivate", false).sort(orderBy ?: "", sort).findAll().toList()) as List<LI>
val results = realm.query<RealmMyLibrary>("isPrivate == $0", false).apply {
orderBy?.let { sort(it, sort) }
}.find()
RealmMyLibrary.getOurLibrary(model?.id, results) as List<LI>
}
else -> {
val results = mRealm.where(RealmMyCourse::class.java).sort(orderBy ?: "", sort).findAll().toList() as List<RealmMyCourse>
RealmMyCourse.getOurCourse(model?.id, results) as List<LI>
val results = realm.query<RealmMyCourse>().apply {
orderBy?.let { sort(it, sort) }
}.find()
RealmMyCourse.getOurCourse(model?.id ?: "", results) as List<LI>
}
}
}

@Suppress("UNCHECKED_CAST")
private fun <T : RealmModel> getMyLibItems(c: Class<T>, orderBy: String? = null): List<LI> {
val query = mRealm.where(c)
val realmResults = if (orderBy != null) {
query.sort(orderBy).findAll()
} else {
query.findAll()
}
val results: List<T> = realmResults.toList()
private fun getMyLibItems(c: Class<*>, orderBy: String? = null): List<LI> {
return when (c) {
RealmMyLibrary::class.java -> {
RealmMyLibrary.getMyLibraryByUserId(model?.id, results as? List<RealmMyLibrary> ?: emptyList()) as List<LI>
val results = realm.query<RealmMyLibrary>().apply {
orderBy?.let { sort(it) }
}.find()
RealmMyLibrary.getMyLibraryByUserId(model?.id, results) as List<LI>
}
RealmMyCourse::class.java -> {
RealmMyCourse.getMyCourseByUserId(model?.id, results as? List<RealmMyCourse> ?: emptyList()) as List<LI>
val results = realm.query<RealmMyCourse>().apply {
orderBy?.let { sort(it) }
}.find()
RealmMyCourse.getMyCourseByUserId(model?.id ?: "", results) as List<LI>
}
else -> throw IllegalArgumentException("Unsupported class: ${c.simpleName}")
}
}

fun getJsonArrayFromList(list: Set<String>): JsonArray {
val array = JsonArray()
list.forEach { array.add(it) }
return array
return JsonArray().apply {
list.forEach { add(it) }
}
}

companion object {
var isSurvey: Boolean = false
}
}
}