diff --git a/app/schemas/com.fongmi.android.tv.db.AppDatabase/30.json b/app/schemas/com.fongmi.android.tv.db.AppDatabase/30.json new file mode 100644 index 000000000..e830c7d5e --- /dev/null +++ b/app/schemas/com.fongmi.android.tv.db.AppDatabase/30.json @@ -0,0 +1,464 @@ +{ + "formatVersion": 1, + "database": { + "version": 30, + "identityHash": "0e0f8a59490a282acc85e2c2f5f133a7", + "entities": [ + { + "tableName": "Keep", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `siteName` TEXT, `vodName` TEXT, `vodPic` TEXT, `createTime` INTEGER NOT NULL, `type` INTEGER NOT NULL, `cid` INTEGER NOT NULL, PRIMARY KEY(`key`))", + "fields": [ + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "siteName", + "columnName": "siteName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "vodName", + "columnName": "vodName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "vodPic", + "columnName": "vodPic", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "createTime", + "columnName": "createTime", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "cid", + "columnName": "cid", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "key" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "Site", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `searchable` INTEGER, `changeable` INTEGER, PRIMARY KEY(`key`))", + "fields": [ + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "searchable", + "columnName": "searchable", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "changeable", + "columnName": "changeable", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "key" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "Live", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `boot` INTEGER NOT NULL, `pass` INTEGER NOT NULL, PRIMARY KEY(`name`))", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "boot", + "columnName": "boot", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "pass", + "columnName": "pass", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "name" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "Track", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `group` INTEGER NOT NULL, `track` INTEGER NOT NULL, `player` INTEGER NOT NULL, `key` TEXT, `name` TEXT, `selected` INTEGER NOT NULL, `adaptive` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "group", + "columnName": "group", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "track", + "columnName": "track", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "player", + "columnName": "player", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "selected", + "columnName": "selected", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "adaptive", + "columnName": "adaptive", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_Track_key_player_type", + "unique": true, + "columnNames": [ + "key", + "player", + "type" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Track_key_player_type` ON `${TABLE_NAME}` (`key`, `player`, `type`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "Config", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `time` INTEGER NOT NULL, `url` TEXT, `json` TEXT, `name` TEXT, `home` TEXT, `logo` TEXT, `parse` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "time", + "columnName": "time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "url", + "columnName": "url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "json", + "columnName": "json", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "home", + "columnName": "home", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "logo", + "columnName": "logo", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "parse", + "columnName": "parse", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_Config_url_type", + "unique": true, + "columnNames": [ + "url", + "type" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Config_url_type` ON `${TABLE_NAME}` (`url`, `type`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "Device", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `uuid` TEXT, `name` TEXT, `ip` TEXT, `type` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "uuid", + "columnName": "uuid", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "ip", + "columnName": "ip", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_Device_uuid_name", + "unique": true, + "columnNames": [ + "uuid", + "name" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_Device_uuid_name` ON `${TABLE_NAME}` (`uuid`, `name`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "History", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `vodPic` TEXT, `vodName` TEXT, `vodFlag` TEXT, `vodRemarks` TEXT, `episodeUrl` TEXT, `revSort` INTEGER NOT NULL, `revPlay` INTEGER NOT NULL, `createTime` INTEGER NOT NULL, `opening` INTEGER NOT NULL, `ending` INTEGER NOT NULL, `position` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `speed` REAL NOT NULL, `player` INTEGER NOT NULL, `scale` INTEGER NOT NULL, `cid` INTEGER NOT NULL, PRIMARY KEY(`key`))", + "fields": [ + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "vodPic", + "columnName": "vodPic", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "vodName", + "columnName": "vodName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "vodFlag", + "columnName": "vodFlag", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "vodRemarks", + "columnName": "vodRemarks", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "episodeUrl", + "columnName": "episodeUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "revSort", + "columnName": "revSort", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "revPlay", + "columnName": "revPlay", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "createTime", + "columnName": "createTime", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "opening", + "columnName": "opening", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "ending", + "columnName": "ending", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "position", + "columnName": "position", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "speed", + "columnName": "speed", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "player", + "columnName": "player", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "scale", + "columnName": "scale", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "cid", + "columnName": "cid", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "key" + ] + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "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, '0e0f8a59490a282acc85e2c2f5f133a7')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fongmi/android/tv/api/config/VodConfig.java b/app/src/main/java/com/fongmi/android/tv/api/config/VodConfig.java index bd9b95bcb..c620ac24f 100644 --- a/app/src/main/java/com/fongmi/android/tv/api/config/VodConfig.java +++ b/app/src/main/java/com/fongmi/android/tv/api/config/VodConfig.java @@ -166,6 +166,7 @@ public class VodConfig { initOther(object); if (loadLive && object.has("lives")) initLive(object); jarLoader.parseJar("", Json.safeString(object, "spider")); + config.logo(Json.safeString(object, "logo")); config.json(object.toString()).update(); App.post(callback::success); } catch (Throwable e) { diff --git a/app/src/main/java/com/fongmi/android/tv/bean/Config.java b/app/src/main/java/com/fongmi/android/tv/bean/Config.java index d29e2fe4e..9f17dbce0 100644 --- a/app/src/main/java/com/fongmi/android/tv/bean/Config.java +++ b/app/src/main/java/com/fongmi/android/tv/bean/Config.java @@ -32,6 +32,8 @@ public class Config { private String json; @SerializedName("name") private String name; + @SerializedName("logo") + private String logo; @SerializedName("home") private String home; @SerializedName("parse") @@ -79,6 +81,14 @@ public class Config { this.url = url; } + public String getJson() { + return json; + } + + public void setJson(String json) { + this.json = json; + } + public String getName() { return name; } @@ -87,12 +97,12 @@ public class Config { this.name = name; } - public String getJson() { - return json; + public String getLogo() { + return logo; } - public void setJson(String json) { - this.json = json; + public void setLogo(String logo) { + this.logo = logo; } public String getHome() { @@ -129,13 +139,18 @@ public class Config { return this; } + public Config json(String json) { + setJson(json); + return this; + } + public Config name(String name) { setName(name); return this; } - public Config json(String json) { - setJson(json); + public Config logo(String logo) { + setLogo(logo); return this; } @@ -207,7 +222,7 @@ public class Config { public static Config find(Config config, int type) { Config item = AppDatabase.get().getConfigDao().find(config.getUrl(), type); - return item == null ? create(type, config.getUrl(), config.getName()) : item.type(type).name(config.getName()); + return item == null ? create(type, config.getUrl(), config.getName()) : item.type(type).name(config.getName()).logo(config.getLogo()); } public static Config find(Depot depot, int type) { diff --git a/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java b/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java index 9da1d38c4..1bc57cac8 100644 --- a/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java +++ b/app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java @@ -38,7 +38,7 @@ import java.util.Locale; @Database(entities = {Keep.class, Site.class, Live.class, Track.class, Config.class, Device.class, History.class}, version = AppDatabase.VERSION) public abstract class AppDatabase extends RoomDatabase { - public static final int VERSION = 29; + public static final int VERSION = 30; public static final String NAME = "tv"; public static final String SYMBOL = "@@@"; @@ -108,6 +108,7 @@ public abstract class AppDatabase extends RoomDatabase { .addMigrations(MIGRATION_26_27) .addMigrations(MIGRATION_27_28) .addMigrations(MIGRATION_28_29) + .addMigrations(MIGRATION_29_30) .allowMainThreadQueries().fallbackToDestructiveMigration().build(); } @@ -263,4 +264,11 @@ public abstract class AppDatabase extends RoomDatabase { database.execSQL("ALTER TABLE Site_Backup RENAME to Site"); } }; + + static final Migration MIGRATION_29_30 = new Migration(29, 30) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + database.execSQL("ALTER TABLE Config ADD COLUMN logo TEXT DEFAULT NULL"); + } + }; } diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/fragment/VodFragment.java b/app/src/mobile/java/com/fongmi/android/tv/ui/fragment/VodFragment.java index 48b911016..a2c0b17fc 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/fragment/VodFragment.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/fragment/VodFragment.java @@ -2,9 +2,11 @@ package com.fongmi.android.tv.ui.fragment; import android.app.Activity; import android.content.Intent; +import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -15,7 +17,10 @@ import androidx.lifecycle.ViewModelProvider; import androidx.viewbinding.ViewBinding; import androidx.viewpager.widget.ViewPager; +import com.bumptech.glide.request.target.CustomTarget; +import com.bumptech.glide.request.transition.Transition; import com.fongmi.android.tv.App; +import com.fongmi.android.tv.R; import com.fongmi.android.tv.Setting; import com.fongmi.android.tv.api.config.VodConfig; import com.fongmi.android.tv.bean.Class; @@ -41,8 +46,11 @@ import com.fongmi.android.tv.ui.dialog.LinkDialog; import com.fongmi.android.tv.ui.dialog.ReceiveDialog; import com.fongmi.android.tv.ui.dialog.SiteDialog; import com.fongmi.android.tv.utils.FileChooser; +import com.fongmi.android.tv.utils.ImgUtil; import com.github.catvod.net.OkHttp; import com.github.catvod.utils.Trans; +import com.google.android.material.shape.RelativeCornerSize; +import com.google.android.material.shape.ShapeAppearanceModel; import com.google.common.net.HttpHeaders; import org.greenrobot.eventbus.EventBus; @@ -239,6 +247,28 @@ public class VodFragment extends BaseFragment implements SiteCallback, FilterCal mBinding.pager.setAdapter(new PageAdapter(getChildFragmentManager())); } + private void setLogo() { + ImgUtil.load(VodConfig.get().getConfig().getLogo(), R.drawable.ic_logo, new CustomTarget<>() { + @Override + public void onResourceReady(@NonNull Drawable drawable, @Nullable Transition transition) { + mBinding.logo.setShapeAppearanceModel(new ShapeAppearanceModel.Builder().setAllCornerSizes(new RelativeCornerSize(0.5f)).build()); + mBinding.logo.setScaleType(ImageView.ScaleType.CENTER_CROP); + mBinding.logo.setImageDrawable(drawable); + } + + @Override + public void onLoadFailed(@Nullable Drawable errorDrawable) { + mBinding.logo.setShapeAppearanceModel(new ShapeAppearanceModel.Builder().setAllCornerSizes(0).build()); + mBinding.logo.setScaleType(ImageView.ScaleType.FIT_CENTER); + mBinding.logo.setImageResource(R.drawable.ic_logo); + } + + @Override + public void onLoadCleared(@Nullable Drawable drawable) { + } + }); + } + public Result getResult() { return mResult == null ? new Result() : mResult; } @@ -246,6 +276,9 @@ public class VodFragment extends BaseFragment implements SiteCallback, FilterCal @Subscribe(threadMode = ThreadMode.MAIN) public void onRefreshEvent(RefreshEvent event) { switch (event.getType()) { + case CONFIG: + setLogo(); + break; case EMPTY: hideProgress(); break; diff --git a/app/src/mobile/res/layout/fragment_vod.xml b/app/src/mobile/res/layout/fragment_vod.xml index 2ce09d4c8..34b4dcf77 100644 --- a/app/src/mobile/res/layout/fragment_vod.xml +++ b/app/src/mobile/res/layout/fragment_vod.xml @@ -24,7 +24,7 @@ android:paddingBottom="4dp" app:layout_scrollFlags="scroll|enterAlways"> -