|
|
|
|
@ -2,6 +2,7 @@ package com.fongmi.android.tv.bean; |
|
|
|
|
|
|
|
|
|
import android.text.TextUtils; |
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
import androidx.room.Entity; |
|
|
|
|
import androidx.room.Index; |
|
|
|
|
import androidx.room.PrimaryKey; |
|
|
|
|
@ -9,6 +10,8 @@ import androidx.room.PrimaryKey; |
|
|
|
|
import com.fongmi.android.tv.App; |
|
|
|
|
import com.fongmi.android.tv.Setting; |
|
|
|
|
import com.fongmi.android.tv.db.AppDatabase; |
|
|
|
|
import com.fongmi.android.tv.utils.FileUtil; |
|
|
|
|
import com.github.catvod.utils.Path; |
|
|
|
|
import com.github.catvod.utils.Prefers; |
|
|
|
|
import com.google.gson.annotations.SerializedName; |
|
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
|
@ -46,6 +49,10 @@ public class Config { |
|
|
|
|
return items == null ? Collections.emptyList() : items; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Config objectFrom(String str) { |
|
|
|
|
return App.gson().fromJson(str, Config.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Config create(int type) { |
|
|
|
|
return new Config().type(type); |
|
|
|
|
} |
|
|
|
|
@ -192,6 +199,7 @@ public class Config { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void delete(String url, int type) { |
|
|
|
|
if (type == 2) Path.clear(FileUtil.getWall(0)); |
|
|
|
|
if (type == 2) AppDatabase.get().getConfigDao().delete(type); |
|
|
|
|
else AppDatabase.get().getConfigDao().delete(url, type); |
|
|
|
|
} |
|
|
|
|
@ -225,6 +233,10 @@ public class Config { |
|
|
|
|
return item == null ? create(type, url, name) : item.type(type).name(name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Config find(Config config) { |
|
|
|
|
return find(config, config.getType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
@ -260,6 +272,12 @@ public class Config { |
|
|
|
|
Keep.delete(getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
|
@Override |
|
|
|
|
public String toString() { |
|
|
|
|
return App.gson().toJson(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean equals(Object obj) { |
|
|
|
|
if (this == obj) return true; |
|
|
|
|
|