reformat code

pull/32/head
gedoor 6 years ago
parent 0b019531f9
commit 3039f993f3
  1. 2
      app/src/main/java/io/legado/app/base/BaseFragment.kt
  2. 7
      app/src/main/java/io/legado/app/base/adapter/ItemAnimation.kt
  3. 1
      app/src/main/java/io/legado/app/base/adapter/animations/SlideInBottomAnimation.kt
  4. 1
      app/src/main/java/io/legado/app/base/adapter/animations/SlideInLeftAnimation.kt
  5. 1
      app/src/main/java/io/legado/app/base/adapter/animations/SlideInRightAnimation.kt
  6. 8
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  7. 7
      app/src/main/java/io/legado/app/data/entities/Book.kt
  8. 4
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  9. 11
      app/src/main/java/io/legado/app/data/entities/Chapter.kt
  10. 10
      app/src/main/java/io/legado/app/data/entities/ExploreSearchUrl.kt
  11. 6
      app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt
  12. 2
      app/src/main/java/io/legado/app/data/entities/rule/Rule.kt
  13. 1
      app/src/main/java/io/legado/app/help/permission/RequestSource.kt
  14. 1
      app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt
  15. 17
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt
  16. 1
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  17. 1
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  18. 1
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
  19. 18
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceAdapter.kt
  20. 8
      app/src/main/java/io/legado/app/ui/main/booksource/BookSourceFragment.kt
  21. 1
      app/src/main/java/io/legado/app/ui/main/findbook/FindBookFragment.kt
  22. 5
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt
  23. 2
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt
  24. 1
      app/src/main/java/io/legado/app/ui/search/SearchActivity.kt
  25. 6
      app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt
  26. 1
      app/src/main/java/io/legado/app/ui/sourceedit/SourceEditViewModel.kt
  27. 7
      app/src/main/java/io/legado/app/ui/widget/RotateLoading.kt
  28. 2
      app/src/main/java/io/legado/app/utils/AnkoExtensions.kt
  29. 4
      app/src/main/java/io/legado/app/utils/MenuExtensions.kt
  30. 1
      app/src/main/java/io/legado/app/utils/StringExtensions.kt
  31. 3
      app/src/main/java/io/legado/app/utils/ViewModelKt.kt
  32. 1
      app/src/main/res/layout/item_relace_rule.xml

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

@ -2,12 +2,7 @@ package io.legado.app.base.adapter
import android.view.animation.Interpolator import android.view.animation.Interpolator
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import io.legado.app.base.adapter.animations.AlphaInAnimation import io.legado.app.base.adapter.animations.*
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
/** /**
* Created by Invincible on 2017/12/15. * 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.Animator
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.view.View import android.view.View
import io.legado.app.base.adapter.animations.BaseAnimation
class SlideInBottomAnimation : BaseAnimation { class SlideInBottomAnimation : BaseAnimation {

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

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

@ -7,15 +7,19 @@ import androidx.room.RoomDatabase
import androidx.room.migration.Migration import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase import androidx.sqlite.db.SupportSQLiteDatabase
import io.legado.app.data.dao.BookDao 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.BookSourceDao
import io.legado.app.data.dao.ReplaceRuleDao
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.Chapter import io.legado.app.data.entities.Chapter
import io.legado.app.data.entities.ReplaceRule 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() { abstract class AppDatabase : RoomDatabase() {
companion object { companion object {

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

@ -1,7 +1,9 @@
package io.legado.app.data.entities package io.legado.app.data.entities
import android.os.Parcelable 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.constant.AppUtils.GSON_CONVERTER
import io.legado.app.data.entities.rule.* import io.legado.app.data.entities.rule.*
import kotlinx.android.parcel.IgnoredOnParcel import kotlinx.android.parcel.IgnoredOnParcel

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

@ -8,12 +8,16 @@ import androidx.room.PrimaryKey
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
@Parcelize @Parcelize
@Entity(tableName = "explore_search_urls", @Entity(
tableName = "explore_search_urls",
indices = [(Index(value = ["sourceId", "url"], unique = true))], indices = [(Index(value = ["sourceId", "url"], unique = true))],
foreignKeys = [(ForeignKey(entity = BookSource::class, foreignKeys = [(ForeignKey(
entity = BookSource::class,
parentColumns = ["sourceId"], parentColumns = ["sourceId"],
childColumns = ["sourceId"], childColumns = ["sourceId"],
onDelete = ForeignKey.CASCADE))]) // 删除书源时自动删除章节 onDelete = ForeignKey.CASCADE
))]
) // 删除书源时自动删除章节
data class ExploreSearchUrl( data class ExploreSearchUrl(
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
var esId: Int = 0, // 编号 var esId: Int = 0, // 编号

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

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

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

@ -3,7 +3,6 @@ package io.legado.app.lib.theme.view
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import android.widget.Switch
import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.SwitchCompat
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore 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.Handler
import io.legado.app.lib.webdav.http.HttpAuth import io.legado.app.lib.webdav.http.HttpAuth
import io.legado.app.lib.webdav.http.OkHttp import io.legado.app.lib.webdav.http.OkHttp
import okhttp3.*
import org.jsoup.Jsoup 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.File
import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.io.UnsupportedEncodingException import java.io.UnsupportedEncodingException
import java.lang.reflect.Field
import java.net.MalformedURLException import java.net.MalformedURLException
import java.net.URL import java.net.URL
import java.net.URLEncoder import java.net.URLEncoder
import java.util.ArrayList import java.util.*
import okhttp3.Credentials
import okhttp3.MediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.Response
class WebDav @Throws(MalformedURLException::class) class WebDav @Throws(MalformedURLException::class)
constructor(url: String) { constructor(url: String) {

@ -3,7 +3,6 @@ package io.legado.app.ui.config
import android.content.SharedPreferences import android.content.SharedPreferences
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.jeremyliao.liveeventbus.LiveEventBus import com.jeremyliao.liveeventbus.LiveEventBus

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

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

@ -4,20 +4,16 @@ import android.view.LayoutInflater
import android.view.Menu import android.view.Menu
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.CompoundButton
import android.widget.PopupMenu import android.widget.PopupMenu
import androidx.paging.PagedListAdapter import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R import io.legado.app.R
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.ItemTouchCallback
import io.legado.app.help.ItemTouchCallback.OnItemTouchCallbackListener import io.legado.app.help.ItemTouchCallback.OnItemTouchCallbackListener
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.ThemeStore
import kotlinx.android.synthetic.main.item_book_source.view.* import kotlinx.android.synthetic.main.item_book_source.view.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
import java.util.*
import kotlin.collections.HashSet
class BookSourceAdapter : PagedListAdapter<BookSource, BookSourceAdapter.MyViewHolder>(DIFF_CALLBACK) { class BookSourceAdapter : PagedListAdapter<BookSource, BookSourceAdapter.MyViewHolder>(DIFF_CALLBACK) {
@ -99,12 +95,18 @@ class BookSourceAdapter : PagedListAdapter<BookSource, BookSourceAdapter.MyViewH
when (it.itemId) { when (it.itemId) {
R.id.menu_edit -> { R.id.menu_edit -> {
callBack?.edit(bookSource) callBack?.edit(bookSource)
true} true
}
R.id.menu_del -> { R.id.menu_del -> {
callBack?.del(bookSource) callBack?.del(bookSource)
true} true
R.id.menu_top ->{ true} }
else -> {false} R.id.menu_top -> {
true
}
else -> {
false
}
} }
} }
popupMenu.show() popupMenu.show()

@ -24,7 +24,8 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.jetbrains.anko.startActivity 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 lateinit var adapter: BookSourceAdapter
private var bookSourceLiveDate: LiveData<PagedList<BookSource>>? = null private var bookSourceLiveDate: LiveData<PagedList<BookSource>>? = null
@ -70,7 +71,10 @@ class BookSourceFragment : BaseFragment(R.layout.fragment_book_source), BookSour
private fun initDataObservers(searchKey: String = "") { private fun initDataObservers(searchKey: String = "") {
bookSourceLiveDate?.removeObservers(viewLifecycleOwner) 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 = LivePagedListBuilder(dataFactory, 30).build()
bookSourceLiveDate?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) }) bookSourceLiveDate?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) })
} }

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

@ -47,12 +47,14 @@ class ReplaceRuleActivity : BaseActivity<ReplaceRuleViewModel>() {
updateEnableAll() updateEnableAll()
} }
} }
override fun delete(rule: ReplaceRule) { override fun delete(rule: ReplaceRule) {
doAsync { doAsync {
App.db.replaceRuleDao().delete(rule) App.db.replaceRuleDao().delete(rule)
updateEnableAll() updateEnableAll()
} }
} }
override fun edit(rule: ReplaceRule) { override fun edit(rule: ReplaceRule) {
doAsync { doAsync {
App.db.replaceRuleDao().enableAll(!allEnabled) App.db.replaceRuleDao().enableAll(!allEnabled)
@ -67,7 +69,8 @@ class ReplaceRuleActivity : BaseActivity<ReplaceRuleViewModel>() {
DividerItemDecoration(this, DividerItemDecoration.VERTICAL).apply { DividerItemDecoration(this, DividerItemDecoration.VERTICAL).apply {
ContextCompat.getDrawable(baseContext, R.drawable.ic_divider)?.let { ContextCompat.getDrawable(baseContext, R.drawable.ic_divider)?.let {
Log.e(APP_TAG, it.toString()) Log.e(APP_TAG, it.toString())
this.setDrawable(it) } this.setDrawable(it)
}
}) })
} }

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

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

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

@ -4,7 +4,6 @@ import android.app.Application
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import io.legado.app.App import io.legado.app.App
import io.legado.app.data.dao.BookSourceDao
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch

@ -89,7 +89,12 @@ class RotateLoading : View {
arc = 10f arc = 10f
loadingRectF = 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( shadowRectF = RectF(
(2 * thisWidth + shadowPosition).toFloat(), (2 * thisWidth + shadowPosition).toFloat(),
(2 * thisWidth + shadowPosition).toFloat(), (2 * thisWidth + shadowPosition).toFloat(),

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

@ -6,7 +6,9 @@ import androidx.appcompat.view.menu.MenuBuilder
import androidx.appcompat.view.menu.MenuItemImpl import androidx.appcompat.view.menu.MenuItemImpl
import androidx.core.view.forEach import androidx.core.view.forEach
import io.legado.app.R 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 -> fun Menu.setIconColor(context: Context): Menu = this.let { menu ->
if (menu is MenuBuilder) { if (menu is MenuBuilder) {

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

@ -2,7 +2,6 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">

Loading…
Cancel
Save