-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature|fix] Support statistics of recently shared stickers; fix a d…
…atabase singleton code bug; fix sticker color theme bug
- Loading branch information
Showing
27 changed files
with
331 additions
and
51 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
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/skyd/rays/model/bean/StickerShareTimeBean.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,41 @@ | ||
package com.skyd.rays.model.bean | ||
|
||
import android.os.Parcelable | ||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.ForeignKey | ||
import com.skyd.rays.base.BaseBean | ||
import kotlinx.parcelize.Parcelize | ||
import kotlinx.serialization.Serializable | ||
|
||
const val STICKER_SHARE_TIME_TABLE_NAME = "StickerShareTime" | ||
|
||
@Parcelize | ||
@Serializable | ||
@Entity( | ||
tableName = STICKER_SHARE_TIME_TABLE_NAME, | ||
primaryKeys = [ | ||
StickerShareTimeBean.STICKER_UUID_COLUMN, | ||
StickerShareTimeBean.SHARE_TIME_COLUMN | ||
], | ||
foreignKeys = [ | ||
ForeignKey( | ||
entity = StickerBean::class, | ||
parentColumns = [StickerBean.UUID_COLUMN], | ||
childColumns = [StickerShareTimeBean.STICKER_UUID_COLUMN], | ||
onDelete = ForeignKey.CASCADE | ||
) | ||
] | ||
) | ||
data class StickerShareTimeBean( | ||
@ColumnInfo(name = STICKER_UUID_COLUMN) | ||
var stickerUuid: String, | ||
@ColumnInfo(name = SHARE_TIME_COLUMN) | ||
var shareTime: Long, | ||
) : BaseBean, Parcelable { | ||
companion object { | ||
const val STICKER_UUID_COLUMN = "stickerUuid" | ||
const val SHARE_TIME_COLUMN = "shareTime" | ||
} | ||
} | ||
|
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
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/skyd/rays/model/db/dao/cache/StickerShareTimeDao.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,51 @@ | ||
package com.skyd.rays.model.db.dao.cache | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import androidx.room.Transaction | ||
import com.skyd.rays.model.bean.STICKER_SHARE_TIME_TABLE_NAME | ||
import com.skyd.rays.model.bean.StickerShareTimeBean | ||
|
||
@Dao | ||
interface StickerShareTimeDao { | ||
@Transaction | ||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
fun updateShareTime(stickerShareTimeBean: StickerShareTimeBean) | ||
|
||
@Transaction | ||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
fun updateShareTime(stickerShareTimeList: List<StickerShareTimeBean>) | ||
|
||
@Transaction | ||
@Query( | ||
""" | ||
SELECT ${StickerShareTimeBean.SHARE_TIME_COLUMN} FROM $STICKER_SHARE_TIME_TABLE_NAME | ||
WHERE ${StickerShareTimeBean.STICKER_UUID_COLUMN} LIKE :uuid | ||
""" | ||
) | ||
fun getShareTimeByUuid(uuid: String): List<Long> | ||
|
||
@Transaction | ||
@Query("DELETE FROM $STICKER_SHARE_TIME_TABLE_NAME") | ||
fun deleteAll(): Int | ||
|
||
@Transaction | ||
@Query( | ||
""" | ||
DELETE FROM $STICKER_SHARE_TIME_TABLE_NAME | ||
WHERE ${StickerShareTimeBean.STICKER_UUID_COLUMN} LIKE :uuid | ||
""" | ||
) | ||
fun deleteShareTimeByUuid(uuid: String): Int | ||
|
||
@Transaction | ||
@Query( | ||
""" | ||
DELETE FROM $STICKER_SHARE_TIME_TABLE_NAME | ||
WHERE ${StickerShareTimeBean.SHARE_TIME_COLUMN} < :timestamp | ||
""" | ||
) | ||
fun deleteShareTimeBefore(timestamp: Long): Int | ||
} |
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
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/skyd/rays/model/db/migration/Migration7To8.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,25 @@ | ||
package com.skyd.rays.model.db.migration | ||
|
||
import androidx.room.migration.Migration | ||
import androidx.sqlite.db.SupportSQLiteDatabase | ||
import com.skyd.rays.model.bean.STICKER_SHARE_TIME_TABLE_NAME | ||
import com.skyd.rays.model.bean.STICKER_TABLE_NAME | ||
import com.skyd.rays.model.bean.StickerBean | ||
import com.skyd.rays.model.bean.StickerShareTimeBean | ||
|
||
class Migration7To8 : Migration(7, 8) { | ||
override fun migrate(db: SupportSQLiteDatabase) { | ||
db.execSQL( | ||
""" | ||
CREATE TABLE $STICKER_SHARE_TIME_TABLE_NAME ( | ||
${StickerShareTimeBean.STICKER_UUID_COLUMN} TEXT NOT NULL, | ||
${StickerShareTimeBean.SHARE_TIME_COLUMN} INTEGER NOT NULL, | ||
PRIMARY KEY (${StickerShareTimeBean.STICKER_UUID_COLUMN}, ${StickerShareTimeBean.SHARE_TIME_COLUMN}) | ||
FOREIGN KEY (${StickerShareTimeBean.STICKER_UUID_COLUMN}) | ||
REFERENCES $STICKER_TABLE_NAME(${StickerBean.UUID_COLUMN}) | ||
ON DELETE CASCADE | ||
) | ||
""" | ||
) | ||
} | ||
} |
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
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
Oops, something went wrong.