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

actions: refactor RealmCourseActivity to kotlin (fixes #2754) #2758

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1167
versionName "0.11.67"
versionCode 1168
versionName "0.11.68"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down

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
}
}
}