1、服务器列表增加点击后自动跳转首页

2、首页增加切换服务器功能
This commit is contained in:
beyond committed 2026-08-27 05:45:54 +08:00
1 parent 6ee79f14cb
commit fc35ae95af
10 files changed
+264 -95

No files matched your search

@@ -9,7 +9,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
@Database(
entities = {IconLibraryEntity.class, ServerEntity.class},
version = 4,
version = 5,
exportSchema = false
)
public abstract class AppDatabase extends RoomDatabase {
@@ -69,7 +69,14 @@ public abstract class AppDatabase extends RoomDatabase {
}
};
public static AppDatabase getInstance(Context context) {
private static final Migration MIGRATION_4_5 = new Migration(4, 5) {
@Override
public void migrate(SupportSQLiteDatabase db) {
db.execSQL("ALTER TABLE servers ADD COLUMN isSelected INTEGER NOT NULL DEFAULT 0");
}
};
public static AppDatabase getInstance(Context context) {
if (instance == null) {
synchronized (AppDatabase.class) {
if (instance == null) {
@@ -77,11 +84,10 @@ public abstract class AppDatabase extends RoomDatabase {
context.getApplicationContext(),
AppDatabase.class,
"emby_player.db"
).addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4).build();
).addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5).build();
}
}
}
return instance;
}
}
@@ -22,4 +22,10 @@ public interface ServerDao {
void deleteLegacySampleServers();
@Query("DELETE FROM servers WHERE id = :serverId")
void deleteServer(String serverId);
}
@Query("UPDATE servers SET isSelected = 0")
void clearAllSelected();
@Query("UPDATE servers SET isSelected = 1 WHERE id = :serverId")
void setSelected(String serverId);
}
@@ -20,6 +20,7 @@ public class ServerEntity {
public String accessToken;
public String userId;
public String iconUrl;
public int isSelected;
@Ignore
public ServerEntity(
@@ -34,9 +35,10 @@ public class ServerEntity {
String accessToken,
String userId
) {
this(id, name, host, basePath, port, username, password, note, accessToken, userId, "");
this(id, name, host, basePath, port, username, password, note, accessToken, userId, "", 0);
}
@Ignore
public ServerEntity(
String id,
String name,
@@ -49,6 +51,23 @@ public class ServerEntity {
String accessToken,
String userId,
String iconUrl
) {
this(id, name, host, basePath, port, username, password, note, accessToken, userId, iconUrl, 0);
}
public ServerEntity(
String id,
String name,
String host,
String basePath,
String port,
String username,
String password,
String note,
String accessToken,
String userId,
String iconUrl,
int isSelected
) {
this.id = id;
this.name = name;
@@ -61,5 +80,6 @@ public class ServerEntity {
this.accessToken = accessToken;
this.userId = userId;
this.iconUrl = iconUrl == null ? "" : iconUrl;
this.isSelected = isSelected;
}
}