Initial stub migrate to androidx room

This commit is contained in:
tarsin committed 2022-08-03 21:59:55 +08:00
1 parent 19891e6768
commit 9cb22b6e17
27 files changed
+988 -2786

No files matched your search

@@ -1,183 +1,34 @@
package com.hippo.ehviewer.dao;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import java.util.List;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "QUICK_SEARCH".
*/
public class QuickSearchDao extends AbstractDao<QuickSearch, Long> {
@Dao
public interface QuickSearchDao {
public static final String TABLENAME = "QUICK_SEARCH";
String TABLENAME = "QUICK_SEARCH";
/**
* Properties of entity QuickSearch.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property Name = new Property(1, String.class, "name", false, "NAME");
public final static Property Mode = new Property(2, int.class, "mode", false, "MODE");
public final static Property Category = new Property(3, int.class, "category", false, "CATEGORY");
public final static Property Keyword = new Property(4, String.class, "keyword", false, "KEYWORD");
public final static Property AdvanceSearch = new Property(5, int.class, "advanceSearch", false, "ADVANCE_SEARCH");
public final static Property MinRating = new Property(6, int.class, "minRating", false, "MIN_RATING");
public final static Property PageFrom = new Property(7, int.class, "pageFrom", false, "PAGE_FROM");
public final static Property PageTo = new Property(8, int.class, "pageTo", false, "PAGE_TO");
public final static Property Time = new Property(9, long.class, "time", false, "TIME");
}
@Query("SELECT * FROM QUICK_SEARCH ORDER BY TIME ASC")
List<QuickSearch> list();
@Query("SELECT * FROM QUICK_SEARCH ORDER BY TIME ASC LIMIT :limit OFFSET :offset")
List<QuickSearch> list(int offset, int limit);
public QuickSearchDao(DaoConfig config) {
super(config);
}
public QuickSearchDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
@Update
void update(List<QuickSearch> downloadLabels);
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"QUICK_SEARCH\" (" + //
"\"_id\" INTEGER PRIMARY KEY ," + // 0: id
"\"NAME\" TEXT," + // 1: name
"\"MODE\" INTEGER NOT NULL ," + // 2: mode
"\"CATEGORY\" INTEGER NOT NULL ," + // 3: category
"\"KEYWORD\" TEXT," + // 4: keyword
"\"ADVANCE_SEARCH\" INTEGER NOT NULL ," + // 5: advanceSearch
"\"MIN_RATING\" INTEGER NOT NULL ," + // 6: minRating
"\"PAGE_FROM\" INTEGER NOT NULL ," + // 7: pageFrom
"\"PAGE_TO\" INTEGER NOT NULL ," + // 8: pageTo
"\"TIME\" INTEGER NOT NULL );"); // 9: time
}
@Update
void update(QuickSearch quickSearch);
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"QUICK_SEARCH\"";
db.execSQL(sql);
}
@Insert
long insert(QuickSearch quickSearch);
@Override
protected final void bindValues(DatabaseStatement stmt, QuickSearch entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String name = entity.getName();
if (name != null) {
stmt.bindString(2, name);
}
stmt.bindLong(3, entity.getMode());
stmt.bindLong(4, entity.getCategory());
String keyword = entity.getKeyword();
if (keyword != null) {
stmt.bindString(5, keyword);
}
stmt.bindLong(6, entity.getAdvanceSearch());
stmt.bindLong(7, entity.getMinRating());
stmt.bindLong(8, entity.getPageFrom());
stmt.bindLong(9, entity.getPageTo());
stmt.bindLong(10, entity.getTime());
}
@Delete
void delete(QuickSearch quickSearch);
@Override
protected final void bindValues(SQLiteStatement stmt, QuickSearch entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String name = entity.getName();
if (name != null) {
stmt.bindString(2, name);
}
stmt.bindLong(3, entity.getMode());
stmt.bindLong(4, entity.getCategory());
String keyword = entity.getKeyword();
if (keyword != null) {
stmt.bindString(5, keyword);
}
stmt.bindLong(6, entity.getAdvanceSearch());
stmt.bindLong(7, entity.getMinRating());
stmt.bindLong(8, entity.getPageFrom());
stmt.bindLong(9, entity.getPageTo());
stmt.bindLong(10, entity.getTime());
}
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public QuickSearch readEntity(Cursor cursor, int offset) {
QuickSearch entity = new QuickSearch( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
cursor.getInt(offset + 2), // mode
cursor.getInt(offset + 3), // category
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // keyword
cursor.getInt(offset + 5), // advanceSearch
cursor.getInt(offset + 6), // minRating
cursor.getInt(offset + 7), // pageFrom
cursor.getInt(offset + 8), // pageTo
cursor.getLong(offset + 9) // time
);
return entity;
}
@Override
public void readEntity(Cursor cursor, QuickSearch entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setMode(cursor.getInt(offset + 2));
entity.setCategory(cursor.getInt(offset + 3));
entity.setKeyword(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setAdvanceSearch(cursor.getInt(offset + 5));
entity.setMinRating(cursor.getInt(offset + 6));
entity.setPageFrom(cursor.getInt(offset + 7));
entity.setPageTo(cursor.getInt(offset + 8));
entity.setTime(cursor.getLong(offset + 9));
}
@Override
protected final Long updateKeyAfterInsert(QuickSearch entity, long rowId) {
entity.setId(rowId);
return rowId;
}
@Override
public Long getKey(QuickSearch entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
@Override
public boolean hasKey(QuickSearch entity) {
return entity.getId() != null;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
}