Skip to content

Commit

Permalink
fix: showActivityId
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Dec 25, 2024
1 parent a5c740f commit b29fd1a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
16 changes: 2 additions & 14 deletions app/src/main/kotlin/li/songe/gkd/data/ActionLog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.room.Update
import androidx.room.migration.AutoMigrationSpec
import kotlinx.coroutines.flow.Flow
import li.songe.gkd.util.format
import li.songe.gkd.util.getShowActivityId

@Entity(
tableName = "action_log",
Expand All @@ -30,20 +31,7 @@ data class ActionLog(
@ColumnInfo(name = "rule_key") val ruleKey: Int? = null,
) {

val showActivityId by lazy {
if (activityId != null) {
if (activityId.startsWith(
appId
)
) {
activityId.substring(appId.length)
} else {
activityId
}
} else {
null
}
}
val showActivityId by lazy { getShowActivityId(appId, activityId) }

val date by lazy { ctime.format("MM-dd HH:mm:ss SSS") }

Expand Down
16 changes: 2 additions & 14 deletions app/src/main/kotlin/li/songe/gkd/data/ActivityLog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.room.Query
import androidx.room.migration.AutoMigrationSpec
import kotlinx.coroutines.flow.Flow
import li.songe.gkd.util.format
import li.songe.gkd.util.getShowActivityId

@Entity(
tableName = "activity_log_v2",
Expand All @@ -23,20 +24,7 @@ data class ActivityLog(
@ColumnInfo(name = "app_id") val appId: String,
@ColumnInfo(name = "activity_id") val activityId: String? = null,
) {
val showActivityId by lazy {
if (activityId != null) {
if (activityId.startsWith(
appId
)
) {
activityId.substring(appId.length)
} else {
activityId
}
} else {
null
}
}
val showActivityId by lazy { getShowActivityId(appId, activityId) }
val date by lazy { ctime.format("MM-dd HH:mm:ss SSS") }

@Dao
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/kotlin/li/songe/gkd/util/Others.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ fun Bitmap.isEmptyBitmap(): Boolean {
return true
}

class InterruptRuleMatchException() : Exception()
class InterruptRuleMatchException() : Exception()

fun getShowActivityId(appId: String, activityId: String?) {
if (activityId != null) {
if (activityId.startsWith(appId) && activityId.getOrNull(appId.length) == '.') {
activityId.substring(appId.length)
} else {
activityId
}
} else {
null
}
}

0 comments on commit b29fd1a

Please sign in to comment.