-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
- Loading branch information
Showing
4 changed files
with
98 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 0 additions & 135 deletions
135
app/src/main/java/org/ole/planet/myplanet/model/RealmApkLog.java
This file was deleted.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
app/src/main/java/org/ole/planet/myplanet/model/RealmApkLog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package org.ole.planet.myplanet.model | ||
|
||
import android.content.Context | ||
import com.google.gson.JsonObject | ||
import io.realm.RealmObject | ||
import io.realm.annotations.Ignore | ||
import io.realm.annotations.PrimaryKey | ||
import org.ole.planet.myplanet.utilities.NetworkUtils | ||
|
||
open class RealmApkLog : RealmObject() { | ||
@PrimaryKey | ||
var id: String? = null | ||
@JvmField | ||
var type: String? = null | ||
private var _rev: String? = null | ||
@JvmField | ||
var error: String? = null | ||
@JvmField | ||
var page: String? = null | ||
@JvmField | ||
var parentCode: String? = null | ||
@JvmField | ||
var version: String? = null | ||
@JvmField | ||
var createdOn: String? = null | ||
@JvmField | ||
var time: String? = null | ||
fun get_rev(): String? { | ||
return _rev | ||
} | ||
|
||
fun set_rev(_rev: String?) { | ||
this._rev = _rev | ||
} | ||
|
||
fun setError(e: Throwable) { | ||
error += "--------- Stack trace ---------\n\n" | ||
appendReport(e) | ||
error += "--------- Cause ---------\n\n" | ||
val cause = e.cause | ||
appendReport(cause) | ||
} | ||
|
||
private fun appendReport(cause: Throwable?) { | ||
if (cause != null) { | ||
error += """ | ||
$cause | ||
""".trimIndent() | ||
val arr = cause.stackTrace | ||
for (i in arr.indices) { | ||
error += """ ${arr[i]} | ||
""" | ||
} | ||
} | ||
error += "-------------------------------\n\n" | ||
} | ||
|
||
companion object { | ||
@JvmField | ||
@Ignore | ||
val ERROR_TYPE_EXCEPTION = "exception" | ||
|
||
@JvmField | ||
@Ignore | ||
val ERROR_TYPE_CRASH = "crash" | ||
|
||
@JvmField | ||
@Ignore | ||
val ERROR_TYPE_ANR = "AnR" | ||
@JvmStatic | ||
fun serialize(log: RealmApkLog, context: Context?): JsonObject { | ||
val `object` = JsonObject() | ||
`object`.addProperty("type", log.type) | ||
`object`.addProperty("error", log.error) | ||
`object`.addProperty("page", log.page) | ||
`object`.addProperty("time", log.time) | ||
`object`.addProperty("version", log.version) | ||
`object`.addProperty("createdOn", log.createdOn) | ||
`object`.addProperty("androidId", log.createdOn) | ||
`object`.addProperty("createdOn", log.createdOn) | ||
`object`.addProperty("androidId", NetworkUtils.getUniqueIdentifier()) | ||
`object`.addProperty("deviceName", NetworkUtils.getDeviceName()) | ||
`object`.addProperty("customDeviceName", NetworkUtils.getCustomDeviceName(context)) | ||
`object`.addProperty("parentCode", log.parentCode) | ||
return `object` | ||
} | ||
} | ||
} |