Added book entity

pull/12/head
atbest 6 years ago committed by GitHub
commit 7daa65030e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/build.gradle
  2. 33
      app/src/main/java/io/legado/app/data/entities/Book.kt
  3. 7
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -34,6 +34,12 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material: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' implementation 'androidx.paging:paging-runtime:2.1.0'
def anko_version = '0.10.8' def anko_version = '0.10.8'

@ -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)
}

@ -8,8 +8,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
import com.google.android.material.navigation.NavigationView import com.google.android.material.navigation.NavigationView
import com.google.android.material.snackbar.Snackbar
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.longSnackbar
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.* import kotlinx.android.synthetic.main.app_bar_main.*
@ -22,10 +22,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
fab.setOnClickListener { view -> fab.setOnClickListener { it.longSnackbar(R.string.action) }
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}
val toggle = ActionBarDrawerToggle( val toggle = ActionBarDrawerToggle(
this, drawer_layout, toolbar, this, drawer_layout, toolbar,

Loading…
Cancel
Save