Merge pull request #523 from okcaptain/dev

Dev
pull/525/head^2
okcaptain 2 years ago committed by GitHub
commit df3ef46b12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 514
      app/schemas/com.fongmi.android.tv.db.AppDatabase/31.json
  2. 5
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/SettingActivity.java
  3. 3
      app/src/leanback/res/layout/activity_setting.xml
  4. 134
      app/src/main/java/com/fongmi/android/tv/bean/Download.java
  5. 2
      app/src/main/java/com/fongmi/android/tv/bean/Vod.java
  6. 20
      app/src/main/java/com/fongmi/android/tv/db/AppDatabase.java
  7. 23
      app/src/main/java/com/fongmi/android/tv/db/dao/DownloadDao.java
  8. 1
      app/src/main/java/com/fongmi/android/tv/model/SiteViewModel.java
  9. 32
      app/src/main/java/com/fongmi/android/tv/player/Download.java
  10. 7
      app/src/main/java/com/fongmi/android/tv/player/exo/ExoUtil.java
  11. 7
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  12. 5
      app/src/mobile/java/com/fongmi/android/tv/ui/fragment/SettingFragment.java
  13. 54
      app/src/mobile/java/com/fongmi/android/tv/utils/Downloader.java
  14. 3
      app/src/mobile/res/layout/fragment_setting.xml

@ -0,0 +1,514 @@
{
"formatVersion": 1,
"database": {
"version": 31,
"identityHash": "9677fed91d21861b5880fb1e1abfde48",
"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, `logo` TEXT, `home` 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": "logo",
"columnName": "logo",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "home",
"columnName": "home",
"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": []
},
{
"tableName": "Download",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `vodPic` TEXT, `vodName` TEXT, `url` TEXT, `header` TEXT, `createTime` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "vodPic",
"columnName": "vodPic",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "vodName",
"columnName": "vodName",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "url",
"columnName": "url",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "header",
"columnName": "header",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "createTime",
"columnName": "createTime",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"id"
]
},
"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, '9677fed91d21861b5880fb1e1abfde48')"
]
}
}

@ -347,7 +347,10 @@ public class SettingActivity extends BaseActivity implements BackupCallback, Con
public void success() {
if (allGranted) {
Notify.progress(getActivity());
App.post(() -> initConfig(), 3000);
App.post(() -> {
AppDatabase.reset();
initConfig();
}, 3000);
}
}
}));

@ -16,6 +16,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
@ -82,6 +83,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
@ -148,6 +150,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout

@ -0,0 +1,134 @@
package com.fongmi.android.tv.bean;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import com.fongmi.android.tv.App;
import com.fongmi.android.tv.db.AppDatabase;
import com.github.catvod.utils.Util;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
@Entity
public class Download {
@NonNull
@PrimaryKey
@SerializedName("id")
private String id;
@SerializedName("vodPic")
private String vodPic;
@SerializedName("vodName")
private String vodName;
@SerializedName("url")
private String url;
@SerializedName("header")
private String header;
@SerializedName("createTime")
private long createTime;
public static Download objectFrom(String str) {
return App.gson().fromJson(str, Download.class);
}
public static List<Download> arrayFrom(String str) {
Type listType = new TypeToken<List<Download>>() {}.getType();
List<Download> items = App.gson().fromJson(str, listType);
return items == null ? Collections.emptyList() : items;
}
public Download(String vodName, String vodPic, String url, String header) {
this.id = Util.md5(url);
this.vodName = vodName;
this.vodPic = vodPic;
this.url = url;
this.header = header;
setCreateTime(System.currentTimeMillis());
}
@NonNull
public String getId() {
return id;
}
public void setId(@NonNull String id) {
this.id = id;
}
public String getVodPic() {
return vodPic;
}
public void setVodPic(String vodPic) {
this.vodPic = vodPic;
}
public String getVodName() {
return vodName;
}
public void setVodName(String vodName) {
this.vodName = vodName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getHeader() {
return header;
}
public void setHeader(String header) {
this.header = header;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public static List<Download> get() {
return AppDatabase.get().getDownloadDao().find();
}
public static void delete(String url) {
AppDatabase.get().getDownloadDao().delete(Util.md5(url));
}
public static void delete(Download download) {
AppDatabase.get().getDownloadDao().delete(download.getId());
}
public static void clear() {
AppDatabase.get().getDownloadDao().delete();
}
public Download delete() {
AppDatabase.get().getDownloadDao().delete(getId());
return this;
}
public Download save() {
AppDatabase.get().getDownloadDao().insertOrUpdate(this);
return this;
}
@NonNull
@Override
public String toString() {
return App.gson().toJson(this);
}
}

@ -245,7 +245,7 @@ public class Vod implements Parcelable {
}
public String getVodName(String name) {
if (getVodName().isEmpty()) setVodName(name);
if (!TextUtils.isEmpty(name)) setVodName(name);
return getVodName();
}

@ -13,6 +13,7 @@ import com.fongmi.android.tv.App;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.bean.Config;
import com.fongmi.android.tv.bean.Device;
import com.fongmi.android.tv.bean.Download;
import com.fongmi.android.tv.bean.History;
import com.fongmi.android.tv.bean.Keep;
import com.fongmi.android.tv.bean.Live;
@ -20,6 +21,7 @@ import com.fongmi.android.tv.bean.Site;
import com.fongmi.android.tv.bean.Track;
import com.fongmi.android.tv.db.dao.ConfigDao;
import com.fongmi.android.tv.db.dao.DeviceDao;
import com.fongmi.android.tv.db.dao.DownloadDao;
import com.fongmi.android.tv.db.dao.HistoryDao;
import com.fongmi.android.tv.db.dao.KeepDao;
import com.fongmi.android.tv.db.dao.LiveDao;
@ -34,10 +36,10 @@ import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Locale;
@Database(entities = {Keep.class, Site.class, Live.class, Track.class, Config.class, Device.class, History.class}, version = AppDatabase.VERSION)
@Database(entities = {Keep.class, Site.class, Live.class, Track.class, Config.class, Device.class, History.class, Download.class}, version = AppDatabase.VERSION)
public abstract class AppDatabase extends RoomDatabase {
public static final int VERSION = 30;
public static final int VERSION = 31;
public static final String NAME = "tv";
public static final String SYMBOL = "@@@";
public static final String BACKUP_SUFFIX = "tv.backup";
@ -49,6 +51,10 @@ public abstract class AppDatabase extends RoomDatabase {
return instance;
}
public static void reset() {
instance = null;
}
public static void backup() {
if (Setting.getBackupMode() == 0) backup(new com.fongmi.android.tv.impl.Callback());
}
@ -109,6 +115,7 @@ public abstract class AppDatabase extends RoomDatabase {
.addMigrations(MIGRATION_27_28)
.addMigrations(MIGRATION_28_29)
.addMigrations(MIGRATION_29_30)
.addMigrations(MIGRATION_30_31)
.allowMainThreadQueries().fallbackToDestructiveMigration().build();
}
@ -126,6 +133,8 @@ public abstract class AppDatabase extends RoomDatabase {
public abstract HistoryDao getHistoryDao();
public abstract DownloadDao getDownloadDao();
static final Migration MIGRATION_11_12 = new Migration(11, 12) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
@ -271,4 +280,11 @@ public abstract class AppDatabase extends RoomDatabase {
database.execSQL("ALTER TABLE Config ADD COLUMN logo TEXT DEFAULT NULL");
}
};
static final Migration MIGRATION_30_31 = new Migration(30, 31) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE Download (`id` TEXT NOT NULL, vodPic TEXT, vodName TEXT, url TEXT, header TEXT, createTime INTEGER NOT NULL, PRIMARY KEY (`id`))");
}
};
}

@ -0,0 +1,23 @@
package com.fongmi.android.tv.db.dao;
import androidx.room.Dao;
import androidx.room.Query;
import com.fongmi.android.tv.bean.Download;
import java.util.List;
@Dao
public abstract class DownloadDao extends BaseDao<Download> {
@Query("SELECT * FROM Download ORDER BY createTime DESC")
public abstract List<Download> find();
@Query("SELECT * FROM Download WHERE id = :id ORDER BY createTime DESC")
public abstract Download find(String id);
@Query("DELETE FROM Download WHERE id = :id")
public abstract void delete(String id);
@Query("DELETE FROM Download")
public abstract void delete();
}

@ -278,6 +278,7 @@ public class SiteViewModel extends ViewModel {
ArrayList<String> ids = new ArrayList<>();
if (site.getCategories().isEmpty()) for (Vod item : result.getList()) ids.add(item.getVodId());
else for (Vod item : result.getList()) if (site.getCategories().contains(item.getTypeName())) ids.add(item.getVodId());
if (ids.isEmpty()) return result.clear();
ArrayMap<String, String> params = new ArrayMap<>();
params.put("ac", site.getType() == 0 ? "videolist" : "detail");
params.put("ids", TextUtils.join(",", ids));

@ -1,32 +0,0 @@
package com.fongmi.android.tv.player;
import android.app.Activity;
import com.fongmi.android.tv.bean.Result;
public class Download{
private static class Loader {
static volatile Download INSTANCE = new Download();
}
public static Download get() {
return Loader.INSTANCE;
}
public void title(String title) {
}
public Download result(Result result) {
return this;
}
public void start(Activity activity) {
}
}

@ -27,12 +27,9 @@ import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.bean.Drm;
import com.fongmi.android.tv.bean.Sub;
import com.fongmi.android.tv.player.Players;
import com.fongmi.android.tv.server.Server;
import com.fongmi.android.tv.utils.Sniffer;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -99,8 +96,6 @@ public class ExoUtil {
}
public static MediaItem getMediaItem(Map<String, String> headers, Uri uri, String mimeType, Drm drm, List<Sub> subs, int decode) {
boolean m3u8Ad = uri.toString().contains(".m3u8") && (Setting.isRemoveAd() || Sniffer.getRegex(uri).size() > 0);
if (m3u8Ad) uri = Uri.parse(Server.get().getAddress(true).concat("/m3u8?url=").concat(URLEncoder.encode(uri.toString())));
MediaItem.Builder builder = new MediaItem.Builder().setUri(uri);
builder.setAllowChunklessPreparation(decode == Players.HARD);
builder.setRequestMetadata(getRequestMetadata(headers, uri));
@ -108,7 +103,7 @@ public class ExoUtil {
if (drm != null) builder.setDrmConfiguration(drm.get());
if (mimeType != null) builder.setMimeType(mimeType);
builder.setForceUseRtpTcp(Setting.getRtsp() == 1);
builder.setAds(Arrays.asList("9999"));
builder.setAds(Sniffer.getRegex(uri));
builder.setMediaId(uri.toString());
return builder.build();
}

@ -63,7 +63,7 @@ import com.fongmi.android.tv.event.PlayerEvent;
import com.fongmi.android.tv.event.RefreshEvent;
import com.fongmi.android.tv.impl.SubtitleCallback;
import com.fongmi.android.tv.model.SiteViewModel;
import com.fongmi.android.tv.player.Download;
import com.fongmi.android.tv.utils.Downloader;
import com.fongmi.android.tv.player.exo.ExoUtil;
import com.fongmi.android.tv.player.Players;
import com.fongmi.android.tv.player.Source;
@ -488,7 +488,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
});
mViewModel.ep.observe(this, episode -> {
Notify.progress(this);
Download.get().title(mBinding.name.getText() + "-" + episode.getName());
Downloader.get().title(mBinding.name.getText() + "-" + episode.getName());
mViewModel.download(getKey(), getFlag().getFlag(), episode.getUrl());
});
}
@ -546,6 +546,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
mBinding.progressLayout.showContent();
mBinding.video.setTag(item.getVodPic(getPic()));
mBinding.name.setText(item.getVodName(getName()));
Downloader.get().image(item.getVodPic());
setText(mBinding.remark, 0, item.getVodRemarks());
setText(mBinding.site, R.string.detail_site, getSite().getName());
setText(mBinding.content, 0, Html.fromHtml(item.getVodContent()).toString());
@ -633,7 +634,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
}
private void setDownload(Result result) {
Download.get().result(result).start(this);
Downloader.get().result(result).start(this);
}
private void checkDanmu(String danmu) {

@ -383,7 +383,10 @@ public class SettingFragment extends BaseFragment implements BackupCallback, Con
public void success() {
if (allGranted) {
Notify.progress(getActivity());
App.post(() -> initConfig(), 3000);
App.post(() -> {
AppDatabase.reset();
initConfig();
}, 3000);
}
}
}));

@ -0,0 +1,54 @@
package com.fongmi.android.tv.utils;
import android.app.Activity;
import com.fongmi.android.tv.bean.Result;
import java.util.Map;
public class Downloader {
private Result result;
private Activity activity;
private String title;
private String image;
private static class Loader {
static volatile Downloader INSTANCE = new Downloader();
}
public static Downloader get() {
return Loader.INSTANCE;
}
public Downloader title(String title) {
this.title = title;
return this;
}
public Downloader image(String image) {
this.image = image;
return this;
}
public Downloader result(Result result) {
this.result = result;
return this;
}
public void start(Activity activity) {
this.activity = activity;
if (result.hasMsg()) {
Notify.show(result.getMsg());
} else {
download();
}
}
private void download() {
download(result.getHeaders(), result.getRealUrl());
}
private void download(Map<String, String> headers, String url) {
IDMUtil.downloadFile(activity, UrlUtil.fixDownloadUrl(url), title, headers, false, false);
}
}

@ -73,6 +73,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
@ -130,6 +131,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
@ -187,6 +189,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout

Loading…
Cancel
Save