Skip to content

Commit

Permalink
migrate realmCourseActivity to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Nov 30, 2023
1 parent ef77f15 commit be2f6b4
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 135 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.ole.planet.myplanet.model

import com.google.gson.JsonObject
import io.realm.Realm
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import org.ole.planet.myplanet.utilities.NetworkUtils
import java.util.Date
import java.util.UUID

open class RealmCourseActivity : RealmObject() {
@PrimaryKey
private var _id: String? = null
@JvmField
var createdOn: String? = null
private var _rev: String? = null
@JvmField
var time: Long = 0
@JvmField
var title: String? = null
@JvmField
var courseId: String? = null
@JvmField
var parentCode: String? = null
@JvmField
var type: String? = null
@JvmField
var user: String? = null
fun get_rev(): String? {
return _rev
}

fun set_rev(_rev: String?) {
this._rev = _rev
}

fun get_id(): String? {
return _id
}

fun set_id(_id: String?) {
this._id = _id
}

companion object {
@JvmStatic
fun createActivity(realm: Realm, userModel: RealmUserModel, course: RealmMyCourse) {
if (!realm.isInTransaction) realm.beginTransaction()
val activity = realm.createObject(
RealmCourseActivity::class.java, UUID.randomUUID().toString()
)
activity.type = "visit"
activity.title = course.courseTitle
activity.courseId = course.courseId
activity.time = Date().time
activity.parentCode = userModel.parentCode
activity.createdOn = userModel.planetCode
activity.createdOn = userModel.planetCode
activity.user = userModel.name
realm.commitTransaction()
}

@JvmStatic
fun serializeSerialize(realm_courseActivities: RealmCourseActivity): JsonObject {
val ob = JsonObject()
ob.addProperty("user", realm_courseActivities.user)
ob.addProperty("courseId", realm_courseActivities.courseId)
ob.addProperty("type", realm_courseActivities.type)
ob.addProperty("title", realm_courseActivities.title)
ob.addProperty("time", realm_courseActivities.time)
ob.addProperty("createdOn", realm_courseActivities.createdOn)
ob.addProperty("parentCode", realm_courseActivities.parentCode)
ob.addProperty("androidId", NetworkUtils.getUniqueIdentifier())
ob.addProperty("deviceName", NetworkUtils.getDeviceName())
return ob
}
}
}

0 comments on commit be2f6b4

Please sign in to comment.