diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java new file mode 100644 index 000000000..f39f29b72 --- /dev/null +++ b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java @@ -0,0 +1,13 @@ +package com.keylesspalace.tusky.db; + +import android.arch.persistence.room.Database; +import android.arch.persistence.room.RoomDatabase; + +/** + * Created by cto3543 on 28/06/2017. + */ + +@Database(entities = {TootEntity.class}, version = 2, exportSchema = false) +abstract public class AppDatabase extends RoomDatabase { + public abstract TootDao tootDao(); +} diff --git a/app/src/main/java/com/keylesspalace/tusky/db/MediaEntity.java b/app/src/main/java/com/keylesspalace/tusky/db/MediaEntity.java new file mode 100644 index 000000000..b23e8f426 --- /dev/null +++ b/app/src/main/java/com/keylesspalace/tusky/db/MediaEntity.java @@ -0,0 +1,18 @@ +package com.keylesspalace.tusky.db; + +import android.arch.persistence.room.ColumnInfo; +import android.arch.persistence.room.Entity; +import android.arch.persistence.room.PrimaryKey; + +/** + * Created by cto3543 on 28/06/2017. + */ + +@Entity +public class MediaEntity { + @PrimaryKey + private int uid; + + @ColumnInfo(name = "url") + private String text; +} diff --git a/app/src/main/java/com/keylesspalace/tusky/db/TootDao.java b/app/src/main/java/com/keylesspalace/tusky/db/TootDao.java new file mode 100644 index 000000000..39ea0e5e5 --- /dev/null +++ b/app/src/main/java/com/keylesspalace/tusky/db/TootDao.java @@ -0,0 +1,30 @@ +package com.keylesspalace.tusky.db; + +import android.arch.persistence.room.Dao; +import android.arch.persistence.room.Delete; +import android.arch.persistence.room.Insert; +import android.arch.persistence.room.Query; + +import java.util.List; + +/** + * Created by cto3543 on 28/06/2017. + */ + +@Dao +public interface TootDao { + @Query("SELECT * FROM TootEntity") + List loadAll(); + + @Query("SELECT * FROM TootEntity WHERE uid IN (:uid)") + List loadAllByUserId(int... uid); + + @Insert + long insert(TootEntity users); + + @Insert + void insertAll(TootEntity... users); + + @Delete + void delete(TootEntity user); +} diff --git a/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java b/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java new file mode 100644 index 000000000..4fc0f8e24 --- /dev/null +++ b/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java @@ -0,0 +1,35 @@ +package com.keylesspalace.tusky.db; + +import android.arch.persistence.room.ColumnInfo; +import android.arch.persistence.room.Entity; +import android.arch.persistence.room.PrimaryKey; + +/** + * Created by cto3543 on 28/06/2017. + */ + +@Entity +public class TootEntity { + @PrimaryKey(autoGenerate = true) + private int uid; + + @ColumnInfo(name = "text") + private String text; + + // set get + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } +}