diff --git a/app/build.gradle b/app/build.gradle index 22574a10c..4891fcbfd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,6 +34,12 @@ dependencies { implementation 'androidx.cardview:cardview:1.0.0' implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' + kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0' + + implementation 'androidx.room:room-runtime:2.0.0' + kapt 'androidx.room:room-compiler:2.0.0' + implementation 'androidx.paging:paging-runtime:2.1.0' //anko diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt new file mode 100644 index 000000000..8082605ab --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -0,0 +1,33 @@ +package io.legado.app.data.entities + +import android.os.Parcelable +import androidx.room.* +import kotlinx.android.parcel.Parcelize +import java.util.* + +@Parcelize +@Entity(tableName = "books", + indices = [(Index(value = ["url"]))]) +data class Book(@PrimaryKey + var url: String = "", + var name: String = "", + var tag: String = "", + var author: String? = null, + var coverUrl: String? = null, + var customCoverUrl: String? = null, + var introduction: String? = null, + var charset: String? = null, + var type: Int = 0, // 0: text, 1: audio + var latestChapterName: String? = null, + var lastUpdateTime: Date? = null, + var latestChapterTime: Date? = null, + var durChapterIndex: Int = 0, + var durChapterPage: Int = 0, + var totalChapterNum: Int = 0, + var hasNewChapter: Boolean = false, + var allowUpdate: Boolean = true + ) : Parcelable { + + fun getUnreadChapterNum() = Math.max(totalChapterNum - durChapterIndex - 1, 0) + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 5e1b735d6..18d6c561a 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -8,8 +8,8 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.view.GravityCompat import androidx.drawerlayout.widget.DrawerLayout import com.google.android.material.navigation.NavigationView -import com.google.android.material.snackbar.Snackbar import io.legado.app.R +import io.legado.app.utils.longSnackbar import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.app_bar_main.* @@ -22,10 +22,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte setSupportActionBar(toolbar) - fab.setOnClickListener { view -> - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - .setAction("Action", null).show() - } + fab.setOnClickListener { it.longSnackbar(R.string.action) } val toggle = ActionBarDrawerToggle( this, drawer_layout, toolbar,