mirror of
https://github.com/NiciDieNase/chaosflix
synced 2025-02-17 05:28:24 +00:00
migrate Watchlist and PlaybackProgress to Room and Kotlin
This commit is contained in:
parent
6e862eeca0
commit
4135cfca69
8 changed files with 75 additions and 133 deletions
|
@ -1,6 +1,7 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1.51'
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
|
@ -11,6 +12,8 @@ buildscript {
|
|||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
|
@ -30,6 +33,7 @@ ext{
|
|||
buildToolsVersion = "26.0.1"
|
||||
supportLibraryVersion = "26.1.0"
|
||||
constraintLayoutVersion = "1.0.2"
|
||||
archCompVersion = "1.0.0-alpha9-1"
|
||||
minSDK = 22
|
||||
targetSDK = 26
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
apply plugin: 'com.android.library'
|
||||
<<<<<<< HEAD
|
||||
apply plugin: 'android-maven'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
|
@ -11,17 +11,6 @@ android {
|
|||
minSdkVersion 17
|
||||
// minSdkVersion rootProject.ext.minSDK
|
||||
targetSdkVersion rootProject.ext.targetSDK
|
||||
=======
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "25.0.2"
|
||||
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 25
|
||||
>>>>>>> extracte module common
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
|
@ -42,19 +31,23 @@ android {
|
|||
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
group="de.nicidienase.chaosflix"
|
||||
version="1.0.0"
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
|
||||
implementation 'com.android.support:multidex:1.0.2'
|
||||
implementation "android.arch.lifecycle:runtime:1.0.3"
|
||||
implementation "android.arch.lifecycle:extensions:1.0.0-alpha9-1"
|
||||
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha9-1"
|
||||
|
||||
implementation 'com.github.satyan:sugar:1.4'
|
||||
implementation "android.arch.lifecycle:extensions:${rootProject.ext.archCompVersion}"
|
||||
annotationProcessor "android.arch.lifecycle:compiler:${rootProject.ext.archCompVersion}"
|
||||
implementation "android.arch.lifecycle:common-java8:1.0.0-beta1"
|
||||
implementation "android.arch.persistence.room:runtime:${rootProject.ext.archCompVersion}"
|
||||
annotationProcessor "android.arch.persistence.room:compiler:${rootProject.ext.archCompVersion}"
|
||||
implementation "android.arch.persistence.room:rxjava2:${rootProject.ext.archCompVersion}"
|
||||
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.1.3'
|
||||
|
||||
|
@ -63,26 +56,14 @@ dependencies {
|
|||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
|
||||
implementation 'joda-time:joda-time:2.9.9'
|
||||
implementation 'org.joda:joda-convert:1.8'
|
||||
=======
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:appcompat-v7:25.4.0'
|
||||
compile 'com.android.support:multidex:1.0.2'
|
||||
|
||||
compile 'com.github.satyan:sugar:1.4'
|
||||
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
||||
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
|
||||
|
||||
compile 'com.squareup.retrofit2:retrofit:2.2.0'
|
||||
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
|
||||
compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
|
||||
compile 'joda-time:joda-time:2.9.9'
|
||||
compile 'org.joda:joda-convert:1.8'
|
||||
>>>>>>> extracte module common
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
||||
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package de.nicidienase.chaosflix.common.entities
|
||||
|
||||
import android.arch.persistence.room.Database
|
||||
import android.arch.persistence.room.RoomDatabase
|
||||
|
||||
/**
|
||||
* Created by felix on 04.10.17.
|
||||
*/
|
||||
|
||||
@Database(entities = arrayOf(PlaybackProgress::class), version = 5)
|
||||
abstract class ChaosflixDatabase : RoomDatabase() {
|
||||
abstract fun playbackProgressDao(): PlaybackProgressDao
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package de.nicidienase.chaosflix.common.entities;
|
||||
|
||||
import com.orm.SugarRecord;
|
||||
|
||||
/**
|
||||
* Created by felix on 06.04.17.
|
||||
*/
|
||||
|
||||
public class PlaybackProgress extends SugarRecord {
|
||||
int eventId;
|
||||
long progress;
|
||||
long recordingId;
|
||||
|
||||
public PlaybackProgress() {
|
||||
}
|
||||
|
||||
public PlaybackProgress(int eventId, long progress, long recordingId) {
|
||||
this.eventId = eventId;
|
||||
this.progress = progress;
|
||||
this.recordingId = recordingId;
|
||||
}
|
||||
|
||||
public int getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public void setEventId(int eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public long getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void setProgress(long progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public long getRecordingId() {
|
||||
return recordingId;
|
||||
}
|
||||
|
||||
public void setRecordingId(long recordingId) {
|
||||
this.recordingId = recordingId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package de.nicidienase.chaosflix.common.entities
|
||||
|
||||
import android.arch.persistence.room.Entity
|
||||
import android.arch.persistence.room.PrimaryKey
|
||||
|
||||
/**
|
||||
* Created by felix on 06.04.17.
|
||||
*/
|
||||
|
||||
@Entity
|
||||
class PlaybackProgress (@PrimaryKey var eventId: Int = 0, var progress: Long = 0){}
|
|
@ -0,0 +1,20 @@
|
|||
package de.nicidienase.chaosflix.common.entities
|
||||
|
||||
import android.arch.persistence.room.Dao
|
||||
import android.arch.persistence.room.Query
|
||||
|
||||
/**
|
||||
* Created by felix on 04.10.17.
|
||||
*/
|
||||
|
||||
@Dao
|
||||
interface PlaybackProgressDao{
|
||||
@Query("SELECT * from playback_progress")
|
||||
fun getAll(): List<PlaybackProgress>
|
||||
|
||||
@Query("SELECT * from playback_progress WHERE id = (:id)")
|
||||
fun getProgressForEvent(id:Int):PlaybackProgress
|
||||
|
||||
@Query("DELETE from playback_progress WHERE id = (:id)")
|
||||
fun deleteProgress(id:Int)
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
package de.nicidienase.chaosflix.common.entities;
|
||||
|
||||
import com.orm.SugarRecord;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by felix on 19.04.17.
|
||||
*/
|
||||
|
||||
public class WatchlistItem extends SugarRecord {
|
||||
int eventId;
|
||||
long timestamp;
|
||||
|
||||
public WatchlistItem() {
|
||||
}
|
||||
|
||||
public WatchlistItem(int eventId) {
|
||||
this.setId((long) eventId);
|
||||
this.eventId = eventId;
|
||||
setAdded(new DateTime(new Date()));
|
||||
}
|
||||
|
||||
public WatchlistItem(int eventId, DateTime added) {
|
||||
this.setId((long) eventId);
|
||||
this.eventId = eventId;
|
||||
setAdded(added);
|
||||
}
|
||||
|
||||
public int getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public void setEventId(int eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public DateTime getAdded() {
|
||||
return new DateTime(timestamp);
|
||||
}
|
||||
|
||||
public void setAdded(DateTime added) {
|
||||
timestamp = added.getMillis();
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package de.nicidienase.chaosflix.common.entities
|
||||
|
||||
import android.arch.persistence.room.Entity
|
||||
|
||||
import org.joda.time.DateTime
|
||||
|
||||
import java.util.Date
|
||||
|
||||
/**
|
||||
* Created by felix on 19.04.17.
|
||||
*/
|
||||
|
||||
@Entity
|
||||
class WatchlistItem (var id: Int = 0, var eventId: Int = id, var added: DateTime = DateTime(Date())) {}
|
Loading…
Add table
Reference in a new issue