Skip to content

Commit

Permalink
feat: 收藏视频添加子标题&修复收藏视频的时间
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Dec 20, 2024
1 parent 2db046f commit 0f48cb1
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 3 deletions.
156 changes: 156 additions & 0 deletions app/schemas/com.muedsa.tvbox.room.AppDatabase/2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "9962e622da90216c9c87bb7fdc2d98c2",
"entities": [
{
"tableName": "favorite_media",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`plugin_package` TEXT NOT NULL, `media_id` TEXT NOT NULL, `media_title` TEXT NOT NULL, `media_detail_url` TEXT NOT NULL, `media_sub_title` TEXT DEFAULT NULL, `cover_image_url` TEXT NOT NULL, `card_width` INTEGER NOT NULL, `card_height` INTEGER NOT NULL, `update_at` INTEGER NOT NULL DEFAULT (CURRENT_TIMESTAMP), PRIMARY KEY(`plugin_package`, `media_id`))",
"fields": [
{
"fieldPath": "pluginPackage",
"columnName": "plugin_package",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "mediaId",
"columnName": "media_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "mediaTitle",
"columnName": "media_title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "mediaDetailUrl",
"columnName": "media_detail_url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "mediaSubTitle",
"columnName": "media_sub_title",
"affinity": "TEXT",
"defaultValue": "NULL"
},
{
"fieldPath": "coverImageUrl",
"columnName": "cover_image_url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "cardWidth",
"columnName": "card_width",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "cardHeight",
"columnName": "card_height",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updateAt",
"columnName": "update_at",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "(CURRENT_TIMESTAMP)"
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"plugin_package",
"media_id"
]
},
"indices": [
{
"name": "index_favorite_media_update_at",
"unique": false,
"columnNames": [
"update_at"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_favorite_media_update_at` ON `${TABLE_NAME}` (`update_at`)"
}
]
},
{
"tableName": "episode_progress",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`plugin_package` TEXT NOT NULL, `media_id` TEXT NOT NULL, `episode_id` TEXT NOT NULL, `progress` INTEGER NOT NULL DEFAULT 0, `duration` INTEGER NOT NULL DEFAULT 0, `update_at` INTEGER NOT NULL DEFAULT (CURRENT_TIMESTAMP), PRIMARY KEY(`plugin_package`, `media_id`, `episode_id`))",
"fields": [
{
"fieldPath": "pluginPackage",
"columnName": "plugin_package",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "mediaId",
"columnName": "media_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "episodeId",
"columnName": "episode_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "progress",
"columnName": "progress",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "duration",
"columnName": "duration",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "updateAt",
"columnName": "update_at",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "(CURRENT_TIMESTAMP)"
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"plugin_package",
"media_id",
"episode_id"
]
},
"indices": [
{
"name": "index_episode_progress_update_at",
"unique": false,
"columnNames": [
"update_at"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_episode_progress_update_at` ON `${TABLE_NAME}` (`update_at`)"
}
]
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9962e622da90216c9c87bb7fdc2d98c2')"
]
}
}
9 changes: 8 additions & 1 deletion app/src/main/java/com/muedsa/tvbox/room/AppDatabase.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package com.muedsa.tvbox.room

import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.RoomDatabase
import com.muedsa.tvbox.room.dao.EpisodeProgressDao
import com.muedsa.tvbox.room.dao.FavoriteMediaDao
import com.muedsa.tvbox.room.model.EpisodeProgressModel
import com.muedsa.tvbox.room.model.FavoriteMediaModel

@Database(entities = [FavoriteMediaModel::class, EpisodeProgressModel::class], version = 1)
@Database(
entities = [FavoriteMediaModel::class, EpisodeProgressModel::class],
version = 2,
autoMigrations = [
AutoMigration(from = 1, to = 2)
]
)
abstract class AppDatabase : RoomDatabase() {

abstract fun favoriteMediaDao(): FavoriteMediaDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data class FavoriteMediaModel(
@ColumnInfo(name = "media_id") val mediaId: String,
@ColumnInfo(name = "media_title") val mediaTitle: String,
@ColumnInfo(name = "media_detail_url") val mediaDetailUrl: String,
@ColumnInfo(name = "media_sub_title", defaultValue = "NULL") val mediaSubTitle: String?,
@ColumnInfo(name = "cover_image_url") val coverImageUrl: String,
@ColumnInfo(name = "card_width") val cardWidth: Int,
@ColumnInfo(name = "card_height") val cardHeight: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ class MediaDetailScreenViewModel @Inject constructor(
mediaId = favoriteMediaCard.id,
mediaTitle = favoriteMediaCard.title,
mediaDetailUrl = favoriteMediaCard.detailUrl,
mediaSubTitle = favoriteMediaCard.subTitle,
coverImageUrl = favoriteMediaCard.coverImageUrl,
cardWidth = favoriteMediaCard.cardWidth,
cardHeight = favoriteMediaCard.cardHeight
cardHeight = favoriteMediaCard.cardHeight,
updateAt = System.currentTimeMillis(),
)
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ fun FavoriteMediaScreen(
url = item.coverImageUrl,
imageSize = DpSize(item.cardWidth.dp, item.cardHeight.dp),
type = CardType.STANDARD,
model = ContentModel(title = item.mediaTitle),
model = ContentModel(
title = item.mediaTitle,
subtitle = item.mediaSubTitle,
),
onItemFocus = {
backgroundState.url = item.coverImageUrl
backgroundState.type = ScreenBackgroundType.BLUR
Expand Down

0 comments on commit 0f48cb1

Please sign in to comment.