reformat code

pull/32/head
gedoor 6 years ago
parent 0b019531f9
commit 3039f993f3
  1. 2
      app/src/main/java/io/legado/app/App.kt
  2. 4
      app/src/main/java/io/legado/app/base/BaseFragment.kt
  3. 2
      app/src/main/java/io/legado/app/base/adapter/InfiniteScrollListener.kt
  4. 7
      app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt
  5. 1
      app/src/main/java/io/legado/app/base/adapter/animations/SlideInBottomAnimation.kt
  6. 1
      app/src/main/java/io/legado/app/base/adapter/animations/SlideInLeftAnimation.kt
  7. 1
      app/src/main/java/io/legado/app/base/adapter/animations/SlideInRightAnimation.kt
  8. 10
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  9. 4
      app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
  10. 7
      app/src/main/java/io/legado/app/data/entities/Book.kt
  11. 6
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  12. 11
      app/src/main/java/io/legado/app/data/entities/Chapter.kt
  13. 14
      app/src/main/java/io/legado/app/data/entities/ExploreSearchUrl.kt
  14. 6
      app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt
  15. 4
      app/src/main/java/io/legado/app/data/entities/SearchKeyword.kt
  16. 2
      app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt
  17. 2
      app/src/main/java/io/legado/app/data/entities/rule/ChapterRule.kt
  18. 2
      app/src/main/java/io/legado/app/data/entities/rule/ContentRule.kt
  19. 2
      app/src/main/java/io/legado/app/data/entities/rule/ExploreRule.kt
  20. 2
      app/src/main/java/io/legado/app/data/entities/rule/PutRule.kt
  21. 4
      app/src/main/java/io/legado/app/data/entities/rule/Rule.kt
  22. 2
      app/src/main/java/io/legado/app/data/entities/rule/SearchRule.kt
  23. 1
      app/src/main/java/io/legado/app/help/permission/RequestSource.kt
  24. 1
      app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt
  25. 33
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt
  26. 3
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  27. 1
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  28. 1
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
  29. 30
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt
  30. 10
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt
  31. 1
      app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt
  32. 7
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt
  33. 2
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt
  34. 1
      app/src/main/java/io/legado/app/ui/search/SearchActivity.kt
  35. 6
      app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt
  36. 4
      app/src/main/java/io/legado/app/ui/sourceedit/SourceEditAdapter.kt
  37. 3
      app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt
  38. 7
      app/src/main/java/io/legado/app/ui/widget/RotateLoading.kt
  39. 2
      app/src/main/java/io/legado/app/ui/widget/dynamiclayout/ViewSwitcher.kt
  40. 2
      app/src/main/java/io/legado/app/utils/AnkoExtensions.kt
  41. 4
      app/src/main/java/io/legado/app/utils/MenuExtensions.kt
  42. 1
      app/src/main/java/io/legado/app/utils/StringExtensions.kt
  43. 3
      app/src/main/java/io/legado/app/utils/ViewModelKt.kt
  44. 24
      app/src/main/res/layout/item_bookshelf_list.xml
  45. 3
      app/src/main/res/layout/item_relace_rule.xml
  46. 2
      app/src/main/res/layout/item_source_edit.xml
  47. 4
      app/src/main/res/layout/view_dynamic.xml
  48. 4
      app/src/main/res/layout/view_error.xml

@ -79,7 +79,7 @@ class App : Application() {
}
}
fun applyDayNight(){
fun applyDayNight() {
upThemeStore()
initNightTheme()
}

@ -6,11 +6,9 @@ import android.view.MenuItem
import androidx.appcompat.view.SupportMenuInflater
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import io.legado.app.utils.setIconColor
abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId){
abstract class BaseFragment(contentLayoutId: Int = 0) : Fragment(contentLayoutId) {
var supportToolbar: Toolbar? = null
private set

@ -14,7 +14,7 @@ abstract class InfiniteScrollListener() : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
// if (dy < 0 || dataLoading.isDataLoading()) return
val layoutManager:LinearLayoutManager = recyclerView.layoutManager as LinearLayoutManager
val layoutManager: LinearLayoutManager = recyclerView.layoutManager as LinearLayoutManager
val visibleItemCount = recyclerView.childCount
val totalItemCount = layoutManager.itemCount
val firstVisibleItem = layoutManager.findFirstVisibleItemPosition()

@ -2,12 +2,7 @@ package io.legado.app.base.adapter
import android.view.animation.Interpolator
import android.view.animation.LinearInterpolator
import io.legado.app.base.adapter.animations.AlphaInAnimation
import io.legado.app.base.adapter.animations.BaseAnimation
import io.legado.app.base.adapter.animations.ScaleInAnimation
import io.legado.app.base.adapter.animations.SlideInBottomAnimation
import io.legado.app.base.adapter.animations.SlideInLeftAnimation
import io.legado.app.base.adapter.animations.SlideInRightAnimation
import io.legado.app.base.adapter.animations.*
/**
* Created by Invincible on 2017/12/15.

@ -3,7 +3,6 @@ package io.legado.app.base.adapter.animations
import android.animation.Animator
import android.animation.ObjectAnimator
import android.view.View
import io.legado.app.base.adapter.animations.BaseAnimation
class SlideInBottomAnimation : BaseAnimation {

@ -3,7 +3,6 @@ package io.legado.app.base.adapter.animations
import android.animation.Animator
import android.animation.ObjectAnimator
import android.view.View
import io.legado.app.base.adapter.animations.BaseAnimation
class SlideInLeftAnimation : BaseAnimation {

@ -3,7 +3,6 @@ package io.legado.app.base.adapter.animations
import android.animation.Animator
import android.animation.ObjectAnimator
import android.view.View
import io.legado.app.base.adapter.animations.BaseAnimation
class SlideInRightAnimation : BaseAnimation {

@ -7,15 +7,19 @@ import androidx.room.RoomDatabase
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import io.legado.app.data.dao.BookDao
import io.legado.app.data.dao.ReplaceRuleDao
import io.legado.app.data.dao.BookSourceDao
import io.legado.app.data.dao.ReplaceRuleDao
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.Chapter
import io.legado.app.data.entities.ReplaceRule
@Database(entities = [Book::class, BookSource::class, Chapter::class, ReplaceRule::class], version = 1, exportSchema = true)
@Database(
entities = [Book::class, BookSource::class, Chapter::class, ReplaceRule::class],
version = 1,
exportSchema = true
)
abstract class AppDatabase : RoomDatabase() {
companion object {
@ -46,5 +50,5 @@ abstract class AppDatabase : RoomDatabase() {
abstract fun bookDao(): BookDao
abstract fun replaceRuleDao(): ReplaceRuleDao
abstract fun bookSourceDao() : BookSourceDao
abstract fun bookSourceDao(): BookSourceDao
}

@ -11,10 +11,10 @@ interface BookSourceDao {
fun observeAll(): DataSource.Factory<Int, BookSource>
@Query("select * from book_sources where name like :searchKey or `group` like :searchKey or origin like :searchKey order by customOrder asc")
fun observeSearch(searchKey:String = ""): DataSource.Factory<Int, BookSource>
fun observeSearch(searchKey: String = ""): DataSource.Factory<Int, BookSource>
@Query("select * from book_sources where origin = :key")
fun findByKey(key:String): BookSource?
fun findByKey(key: String): BookSource?
@Query("select count(*) from book_sources")
fun allCount(): Int

@ -1,13 +1,16 @@
package io.legado.app.data.entities
import android.os.Parcelable
import androidx.room.*
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import io.legado.app.constant.AppConst.NOT_AVAILABLE
import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity(tableName = "books", indices = [(Index(value = ["descUrl"], unique = true))])
data class Book(@PrimaryKey
data class Book(
@PrimaryKey
var descUrl: String = "", // 详情页Url(本地书源存储完整文件路径)
var tocUrl: String = "", // 目录页Url (toc=table of Contents)
var sourceId: Int = -1, // 书源规则id(默认-1,表示本地书籍)

@ -1,7 +1,9 @@
package io.legado.app.data.entities
import android.os.Parcelable
import androidx.room.*
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import io.legado.app.constant.AppUtils.GSON_CONVERTER
import io.legado.app.data.entities.rule.*
import kotlinx.android.parcel.IgnoredOnParcel
@ -12,7 +14,7 @@ import kotlinx.android.parcel.Parcelize
tableName = "book_sources",
indices = [(Index(value = ["origin"], unique = false))]
)
data class BookSource (
data class BookSource(
@PrimaryKey
var origin: String = "", // 地址,包括 http/https
var name: String = "", // 名称

@ -4,18 +4,21 @@ import android.os.Parcelable
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity(tableName = "chapters",
@Entity(
tableName = "chapters",
primaryKeys = ["url", "bookUrl"],
indices = [(Index(value = ["url"], unique = true)), (Index(value = ["bookUrl", "index"], unique = true))],
foreignKeys = [(ForeignKey(entity = Book::class,
foreignKeys = [(ForeignKey(
entity = Book::class,
parentColumns = ["descUrl"],
childColumns = ["bookUrl"],
onDelete = ForeignKey.CASCADE))]) // 删除书籍时自动删除章节
onDelete = ForeignKey.CASCADE
))]
) // 删除书籍时自动删除章节
data class Chapter(
var url: String = "", // 章节地址
var title: String = "", // 章节标题

@ -8,13 +8,17 @@ import androidx.room.PrimaryKey
import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity(tableName = "explore_search_urls",
@Entity(
tableName = "explore_search_urls",
indices = [(Index(value = ["sourceId", "url"], unique = true))],
foreignKeys = [(ForeignKey(entity = BookSource::class,
foreignKeys = [(ForeignKey(
entity = BookSource::class,
parentColumns = ["sourceId"],
childColumns = ["sourceId"],
onDelete = ForeignKey.CASCADE))]) // 删除书源时自动删除章节
data class ExploreSearchUrl (
onDelete = ForeignKey.CASCADE
))]
) // 删除书源时自动删除章节
data class ExploreSearchUrl(
@PrimaryKey(autoGenerate = true)
var esId: Int = 0, // 编号
var sourceId: Int = 0, // 书源Id
@ -25,5 +29,5 @@ data class ExploreSearchUrl (
var defOrder: Int = 0, // 默认排序,是在编辑书源的时候的顺序
var usage: Int = 0, // 使用次数,用于按使用次数排序
var lastUseTime: Long = 0L // 最后一次使用的时间
) : Parcelable
) : Parcelable

@ -8,8 +8,10 @@ import androidx.room.PrimaryKey
import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity(tableName = "replace_rules",
indices = [(Index(value = ["id"]))])
@Entity(
tableName = "replace_rules",
indices = [(Index(value = ["id"]))]
)
data class ReplaceRule(
@PrimaryKey(autoGenerate = true)
var id: Int = 0,

@ -9,9 +9,9 @@ import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity(tableName = "search_keywords", indices = [(Index(value = ["word"], unique = true))])
data class SearchKeyword (
data class SearchKeyword(
@PrimaryKey
var word: String = "", // 搜索关键词
var usage: Int = 1, // 使用次数
var lastUseTime: Long = 0 // 最后一次使用时间
): Parcelable
) : Parcelable

@ -1,6 +1,6 @@
package io.legado.app.data.entities.rule
data class BookInfoRule (
data class BookInfoRule(
var name: Rule,
var author: Rule,
var desc: Rule,

@ -1,6 +1,6 @@
package io.legado.app.data.entities.rule
data class ChapterRule (
data class ChapterRule(
var chapterList: Rule,
var isReversed: Boolean = false,
var title: Rule,

@ -1,6 +1,6 @@
package io.legado.app.data.entities.rule
data class ContentRule (
data class ContentRule(
var fulltext: Rule,
var resourceUrl: Rule,
var nextUrl: Rule

@ -1,6 +1,6 @@
package io.legado.app.data.entities.rule
data class ExploreRule (
data class ExploreRule(
var bookList: Rule,
var name: Rule,
var author: Rule,

@ -1,6 +1,6 @@
package io.legado.app.data.entities.rule
data class PutRule (
data class PutRule(
var selector: Rule,
var key: String
)

@ -1,9 +1,9 @@
package io.legado.app.data.entities.rule
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.safeTrim
import io.legado.app.utils.splitNotBlank
data class Rule (
data class Rule(
var selectors: List<BaseRule>,
var regex: String?,
var replacement: String?,

@ -1,6 +1,6 @@
package io.legado.app.data.entities.rule
data class SearchRule (
data class SearchRule(
var bookList: Rule,
var name: Rule,
var author: Rule,

@ -2,7 +2,6 @@ package io.legado.app.help.permission
import android.content.Context
import android.content.Intent
import androidx.fragment.app.FragmentManager
interface RequestSource {

@ -3,7 +3,6 @@ package io.legado.app.lib.theme.view
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.Switch
import androidx.appcompat.widget.SwitchCompat
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore

@ -3,29 +3,16 @@ package io.legado.app.lib.webdav
import io.legado.app.lib.webdav.http.Handler
import io.legado.app.lib.webdav.http.HttpAuth
import io.legado.app.lib.webdav.http.OkHttp
import okhttp3.*
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.io.InputStream
import java.io.UnsupportedEncodingException
import java.lang.reflect.Field
import java.net.MalformedURLException
import java.net.URL
import java.net.URLEncoder
import java.util.ArrayList
import okhttp3.Credentials
import okhttp3.MediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.Response
import java.util.*
class WebDav @Throws(MalformedURLException::class)
constructor(url: String) {
@ -50,9 +37,9 @@ constructor(url: String) {
get() = url.toString()
private val inputStream: InputStream?
get() = getUrl()?.let {url ->
get() = getUrl()?.let { url ->
val request = Request.Builder().url(url)
HttpAuth.auth?.let {request.header("Authorization", Credentials.basic(it.user, it.pass)) }
HttpAuth.auth?.let { request.header("Authorization", Credentials.basic(it.user, it.pass)) }
try {
return okHttpClient.newCall(request.build()).execute().body()?.byteStream()
@ -113,9 +100,9 @@ constructor(url: String) {
@Throws(IOException::class)
@JvmOverloads
fun listFiles(propsList: ArrayList<String> = ArrayList()): List<WebDav> {
propFindResponse(propsList)?.let {response->
propFindResponse(propsList)?.let { response ->
if (response.isSuccessful) {
response.body()?.let {body->
response.body()?.let { body ->
return parseDir(body.string())
}
}
@ -136,14 +123,14 @@ constructor(url: String) {
} else {
String.format(DIR, requestProps.toString() + "\n")
}
getUrl()?.let {url->
getUrl()?.let { url ->
val request = Request.Builder()
.url(url)
// 添加RequestBody对象,可以只返回的属性。如果设为null,则会返回全部属性
// 注意:尽量手动指定需要返回的属性。若返回全部属性,可能后由于Prop.java里没有该属性名,而崩溃。
.method("PROPFIND", RequestBody.create(MediaType.parse("text/plain"), requestPropsStr))
HttpAuth.auth?.let {request.header("Authorization", Credentials.basic(it.user, it.pass)) }
HttpAuth.auth?.let { request.header("Authorization", Credentials.basic(it.user, it.pass)) }
request.header("Depth", if (depth < 0) "infinity" else Integer.toString(depth))
@ -156,7 +143,7 @@ constructor(url: String) {
val list = ArrayList<WebDav>()
val document = Jsoup.parse(s)
val elements = document.getElementsByTag("d:response")
getUrl()?.let { url->
getUrl()?.let { url ->
val baseUrl = if (url.endsWith("/")) url else "$url/"
for (element in elements) {
val href = element.getElementsByTag("d:href")[0].text()
@ -184,7 +171,7 @@ constructor(url: String) {
*/
@Throws(IOException::class)
fun makeAsDir(): Boolean {
getUrl()?.let { url->
getUrl()?.let { url ->
val request = Request.Builder()
.url(url)
.method("MKCOL", null)

@ -3,7 +3,6 @@ package io.legado.app.ui.config
import android.content.SharedPreferences
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AlertDialog
import androidx.preference.PreferenceFragmentCompat
import com.jeremyliao.liveeventbus.LiveEventBus
@ -87,7 +86,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnShar
if (App.INSTANCE.getPrefBoolean("isNightTheme", false) == isNightTheme) {
App.INSTANCE.upThemeStore()
LiveEventBus.get().with(Bus.recreate).post("")
Handler().postDelayed({activity?.recreate()}, 100)
Handler().postDelayed({ activity?.recreate() }, 100)
}
}

@ -1,7 +1,6 @@
package io.legado.app.ui.main
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager

@ -6,5 +6,4 @@ import androidx.lifecycle.AndroidViewModel
class MainViewModel(application: Application) : AndroidViewModel(application) {
}

@ -4,20 +4,16 @@ import android.view.LayoutInflater
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import android.widget.CompoundButton
import android.widget.PopupMenu
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.data.entities.BookSource
import io.legado.app.help.ItemTouchCallback
import io.legado.app.help.ItemTouchCallback.OnItemTouchCallbackListener
import io.legado.app.lib.theme.ThemeStore
import kotlinx.android.synthetic.main.item_book_source.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
import java.util.*
import kotlin.collections.HashSet
class BookSourceAdapter : PagedListAdapter<BookSource, BookSourceAdapter.MyViewHolder>(DIFF_CALLBACK) {
@ -48,8 +44,8 @@ class BookSourceAdapter : PagedListAdapter<BookSource, BookSourceAdapter.MyViewH
currentList?.let {
val srcSource = it[srcPosition]
val targetSource = it[targetPosition]
srcSource?.let { a->
targetSource?.let { b->
srcSource?.let { a ->
targetSource?.let { b ->
a.customOrder = targetPosition
b.customOrder = srcPosition
callBack?.update(a, b)
@ -86,25 +82,31 @@ class BookSourceAdapter : PagedListAdapter<BookSource, BookSourceAdapter.MyViewH
}
}
sw_enabled.isChecked = bookSource.isEnabled
sw_enabled.setOnClickListener{
sw_enabled.setOnClickListener {
bookSource.isEnabled = sw_enabled.isChecked
callBack?.update(bookSource)
}
iv_more.setOnClickListener{
iv_more.setOnClickListener {
val popupMenu = PopupMenu(context, iv_more)
popupMenu.menu.add(Menu.NONE, R.id.menu_edit, Menu.NONE, R.string.edit)
popupMenu.menu.add(Menu.NONE, R.id.menu_del, Menu.NONE, R.string.delete)
popupMenu.menu.add(Menu.NONE, R.id.menu_top, Menu.NONE, R.string.to_top)
popupMenu.setOnMenuItemClickListener {
when (it.itemId) {
R.id.menu_edit ->{
R.id.menu_edit -> {
callBack?.edit(bookSource)
true}
R.id.menu_del ->{
true
}
R.id.menu_del -> {
callBack?.del(bookSource)
true}
R.id.menu_top ->{ true}
else -> {false}
true
}
R.id.menu_top -> {
true
}
else -> {
false
}
}
}
popupMenu.show()

@ -24,7 +24,8 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.jetbrains.anko.startActivity
class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSourceAdapter.CallBack, SearchView.OnQueryTextListener {
class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSourceAdapter.CallBack,
SearchView.OnQueryTextListener {
private lateinit var adapter: BookSourceAdapter
private var bookSourceLiveDate: LiveData<PagedList<BookSource>>? = null
@ -68,9 +69,12 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour
search_view.setOnQueryTextListener(this)
}
private fun initDataObservers(searchKey:String = "") {
private fun initDataObservers(searchKey: String = "") {
bookSourceLiveDate?.removeObservers(viewLifecycleOwner)
val dataFactory = if (searchKey.isEmpty()) App.db.bookSourceDao().observeAll() else App.db.bookSourceDao().observeSearch(searchKey)
val dataFactory =
if (searchKey.isEmpty()) App.db.bookSourceDao().observeAll() else App.db.bookSourceDao().observeSearch(
searchKey
)
bookSourceLiveDate = LivePagedListBuilder(dataFactory, 30).build()
bookSourceLiveDate?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) })
}

@ -2,7 +2,6 @@ package io.legado.app.ui.main.findbook
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import io.legado.app.R
import io.legado.app.base.BaseFragment

@ -40,19 +40,21 @@ class ReplaceRuleActivity : BaseActivity<ReplaceRuleViewModel>() {
private fun initRecyclerView() {
rv_replace_rule.layoutManager = LinearLayoutManager(this)
adapter = ReplaceRuleAdapter(this)
adapter.onClickListener = object: ReplaceRuleAdapter.OnClickListener {
adapter.onClickListener = object : ReplaceRuleAdapter.OnClickListener {
override fun update(rule: ReplaceRule) {
doAsync {
App.db.replaceRuleDao().update(rule)
updateEnableAll()
}
}
override fun delete(rule: ReplaceRule) {
doAsync {
App.db.replaceRuleDao().delete(rule)
updateEnableAll()
}
}
override fun edit(rule: ReplaceRule) {
doAsync {
App.db.replaceRuleDao().enableAll(!allEnabled)
@ -67,7 +69,8 @@ class ReplaceRuleActivity : BaseActivity<ReplaceRuleViewModel>() {
DividerItemDecoration(this, DividerItemDecoration.VERTICAL).apply {
ContextCompat.getDrawable(baseContext, R.drawable.ic_divider)?.let {
Log.e(APP_TAG, it.toString())
this.setDrawable(it) }
this.setDrawable(it)
}
})
}

@ -1,7 +1,6 @@
package io.legado.app.ui.replacerule
import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -10,7 +9,6 @@ import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.constant.AppConst.APP_TAG
import io.legado.app.data.entities.ReplaceRule
import kotlinx.android.synthetic.main.item_relace_rule.view.*
import org.jetbrains.anko.sdk27.listeners.onClick

@ -4,7 +4,6 @@ import android.os.Bundle
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.utils.getViewModel
import org.jetbrains.anko.startActivity
class SearchActivity : BaseActivity<SearchViewModel>() {

@ -5,14 +5,14 @@ import android.view.Menu
import android.view.MenuItem
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.data.entities.BookSource
import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_source_edit.*
import kotlinx.coroutines.*
import org.jetbrains.anko.UI
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.jetbrains.anko.toast
class SourceEditActivity : BaseActivity<SourceEditViewModel>() {

@ -11,7 +11,7 @@ import kotlinx.android.synthetic.main.item_source_edit.view.*
class SourceEditAdapter : RecyclerView.Adapter<SourceEditAdapter.MyViewHolder>() {
var sourceEditEntities:ArrayList<SourceEditActivity.SourceEditEntity> = ArrayList()
var sourceEditEntities: ArrayList<SourceEditActivity.SourceEditEntity> = ArrayList()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_source_edit, parent, false))
@ -60,7 +60,7 @@ class SourceEditAdapter : RecyclerView.Adapter<SourceEditAdapter.MyViewHolder>()
}
override fun afterTextChanged(s: Editable?) {
sourceEditEntity.value=(s?.toString())
sourceEditEntity.value = (s?.toString())
}
}
editText.addTextChangedListener(textWatcher)

@ -4,14 +4,13 @@ import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import io.legado.app.App
import io.legado.app.data.dao.BookSourceDao
import io.legado.app.data.entities.BookSource
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
class SourceEditViewModel(application: Application) : AndroidViewModel(application) {
val sourceLiveData:MutableLiveData<BookSource> = MutableLiveData()
val sourceLiveData: MutableLiveData<BookSource> = MutableLiveData()
fun setBookSource(key: String) {
GlobalScope.launch {

@ -89,7 +89,12 @@ class RotateLoading : View {
arc = 10f
loadingRectF =
RectF((2 * thisWidth).toFloat(), (2 * thisWidth).toFloat(), (w - 2 * thisWidth).toFloat(), (h - 2 * thisWidth).toFloat())
RectF(
(2 * thisWidth).toFloat(),
(2 * thisWidth).toFloat(),
(w - 2 * thisWidth).toFloat(),
(h - 2 * thisWidth).toFloat()
)
shadowRectF = RectF(
(2 * thisWidth + shadowPosition).toFloat(),
(2 * thisWidth + shadowPosition).toFloat(),

@ -5,7 +5,7 @@ import androidx.annotation.StringRes
interface ViewSwitcher {
companion object{
companion object {
const val SHOW_CONTENT_VIEW = 0
const val SHOW_ERROR_VIEW = 1
const val SHOW_EMPTY_VIEW = 2

@ -1,10 +1,8 @@
package io.legado.app.utils
import android.app.Activity
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.view.View
import android.view.WindowManager
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes

@ -6,7 +6,9 @@ import androidx.appcompat.view.menu.MenuBuilder
import androidx.appcompat.view.menu.MenuItemImpl
import androidx.core.view.forEach
import io.legado.app.R
import io.legado.app.lib.theme.*
import io.legado.app.lib.theme.DrawableUtils
import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.lib.theme.isDarkTheme
fun Menu.setIconColor(context: Context): Menu = this.let { menu ->
if (menu is MenuBuilder) {

@ -1,4 +1,5 @@
package io.legado.app.utils
// import org.apache.commons.text.StringEscapeUtils
fun String?.safeTrim() = if (this.isNullOrBlank()) null else this.trim()

@ -9,4 +9,5 @@ fun <T : ViewModel> AppCompatActivity.getViewModel(clazz: Class<T>) = ViewModelP
fun <T : ViewModel> Fragment.getViewModel(clazz: Class<T>) = ViewModelProviders.of(this).get(clazz)
fun <T : ViewModel> Fragment.getViewModelOfActivity(clazz: Class<T>) = ViewModelProviders.of(requireActivity()).get(clazz)
fun <T : ViewModel> Fragment.getViewModelOfActivity(clazz: Class<T>) =
ViewModelProviders.of(requireActivity()).get(clazz)

@ -22,7 +22,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UnusedAttribute" />
tools:ignore="UnusedAttribute"/>
<FrameLayout
android:id="@+id/fl_has_new"
@ -38,7 +38,7 @@
android:layout_gravity="right"
android:layout_margin="5dp"
android:includeFontPadding="false"
tools:ignore="RtlHardcoded" />
tools:ignore="RtlHardcoded"/>
<com.victor.loading.rotate.RotateLoading
android:id="@+id/rl_loading"
@ -48,7 +48,7 @@
android:visibility="invisible"
app:loading_color="@color/colorAccent"
app:loading_width="2dp"
tools:ignore="RtlHardcoded" />
tools:ignore="RtlHardcoded"/>
</FrameLayout>
<TextView
@ -67,7 +67,7 @@
app:layout_constraintLeft_toRightOf="@+id/iv_cover"
app:layout_constraintRight_toLeftOf="@id/fl_has_new"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="RtlHardcoded,RtlSymmetry" />
tools:ignore="RtlHardcoded,RtlSymmetry"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_author"
@ -82,7 +82,7 @@
app:layout_constraintLeft_toRightOf="@+id/iv_cover"
app:layout_constraintTop_toTopOf="@+id/tv_author"
app:tint="@color/tv_text_secondary"
tools:ignore="RtlHardcoded,RtlSymmetry" />
tools:ignore="RtlHardcoded,RtlSymmetry"/>
<TextView
android:id="@+id/tv_author"
@ -98,7 +98,7 @@
app:layout_constraintLeft_toRightOf="@+id/iv_author"
app:layout_constraintRight_toLeftOf="@id/fl_has_new"
app:layout_constraintTop_toBottomOf="@+id/tv_name"
tools:ignore="RtlSymmetry" />
tools:ignore="RtlSymmetry"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_read"
@ -113,7 +113,7 @@
app:layout_constraintLeft_toRightOf="@+id/iv_cover"
app:layout_constraintTop_toTopOf="@+id/tv_read"
app:tint="@color/tv_text_secondary"
tools:ignore="RtlHardcoded,RtlSymmetry" />
tools:ignore="RtlHardcoded,RtlSymmetry"/>
<TextView
android:id="@+id/tv_read"
@ -127,7 +127,7 @@
app:layout_constraintBottom_toTopOf="@id/tv_last"
app:layout_constraintLeft_toRightOf="@+id/iv_read"
app:layout_constraintRight_toLeftOf="@id/fl_has_new"
app:layout_constraintTop_toBottomOf="@+id/tv_author" />
app:layout_constraintTop_toBottomOf="@+id/tv_author"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_last"
@ -142,7 +142,7 @@
app:layout_constraintLeft_toRightOf="@+id/iv_cover"
app:layout_constraintTop_toTopOf="@+id/tv_last"
app:tint="@color/tv_text_secondary"
tools:ignore="RtlHardcoded,RtlSymmetry" />
tools:ignore="RtlHardcoded,RtlSymmetry"/>
<TextView
android:id="@+id/tv_last"
@ -156,7 +156,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/iv_last"
app:layout_constraintRight_toLeftOf="@id/fl_has_new"
app:layout_constraintTop_toBottomOf="@+id/tv_read" />
app:layout_constraintTop_toBottomOf="@+id/tv_read"/>
<View
android:id="@+id/vw_select"
@ -164,12 +164,12 @@
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/btn_bg_press"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -2,7 +2,6 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -46,7 +45,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tv_name"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintBottom_toBottomOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_name"

@ -7,5 +7,5 @@
<io.legado.app.lib.theme.view.ATEEditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"/>
</io.legado.app.lib.theme.view.ATETextInputLayout>

@ -8,13 +8,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout="@layout/view_error" />
android:layout="@layout/view_error"/>
<ViewStub
android:id="@+id/progressViewStub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout="@layout/view_loading" />
android:layout="@layout/view_loading"/>
</merge>

@ -14,7 +14,7 @@
android:id="@+id/tv_error_message"
style="@style/Style.Text.Primary.Normal"
android:paddingTop="16dp"
android:paddingBottom="16dp" />
android:paddingBottom="16dp"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_error_retry"
@ -22,6 +22,6 @@
android:layout_height="wrap_content"
android:backgroundTint="@color/colorAccent"
android:minWidth="96dp"
android:text="@string/dynamic_click_retry" />
android:text="@string/dynamic_click_retry"/>
</LinearLayout>
Loading…
Cancel
Save