pull/433/head
gedoor 4 years ago
parent 8383ffe63c
commit 3891fadc64
  1. 2
      app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt
  2. 2
      app/src/main/java/io/legado/app/ui/widget/SearchView.kt
  3. 1
      app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt
  4. 1
      app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt
  5. 1
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
  6. 1
      app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt
  7. 1
      app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt
  8. 31
      app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionAnimator.kt
  9. 5
      app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt
  10. 1
      app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt
  11. 2
      app/src/main/java/io/legado/app/utils/BitmapUtils.kt
  12. 2
      app/src/main/java/io/legado/app/utils/ColorUtils.kt
  13. 2
      app/src/main/java/io/legado/app/utils/ConstraintUtil.kt
  14. 1
      app/src/main/java/io/legado/app/utils/DocumentUtils.kt
  15. 2
      app/src/main/java/io/legado/app/utils/EventBusExtensions.kt
  16. 13
      app/src/main/java/io/legado/app/utils/FileUtils.kt
  17. 26
      app/src/main/java/io/legado/app/utils/FragmentExtensions.kt
  18. 31
      app/src/main/java/io/legado/app/utils/JsoupExtensions.kt
  19. 8
      app/src/main/java/io/legado/app/utils/LanguageUtils.kt
  20. 2
      app/src/main/java/io/legado/app/utils/StringUtils.kt
  21. 8
      app/src/main/java/io/legado/app/utils/ViewExtensions.kt

@ -7,7 +7,7 @@ import android.widget.TextView
import io.legado.app.ui.widget.text.AccentBgTextView
import io.legado.app.utils.dp
@Suppress("unused")
@Suppress("unused", "MemberVisibilityCanBePrivate")
class LabelsBar(context: Context, attrs: AttributeSet?) : LinearLayout(context, attrs) {
private val unUsedViews = arrayListOf<TextView>()

@ -1,5 +1,6 @@
package io.legado.app.ui.widget
import android.annotation.SuppressLint
import android.app.SearchableInfo
import android.content.Context
import android.graphics.Canvas
@ -30,6 +31,7 @@ class SearchView : SearchView {
defStyleAttr: Int
) : super(context, attrs, defStyleAttr)
@SuppressLint("UseCompatLoadingForDrawables")
override fun onLayout(
changed: Boolean,
left: Int,

@ -16,6 +16,7 @@ import io.legado.app.utils.visible
import kotlinx.android.synthetic.main.view_select_action_bar.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
@Suppress("unused")
class SelectActionBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) {
private var callBack: CallBack? = null
private var selMenu: PopupMenu? = null

@ -17,6 +17,7 @@ import io.legado.app.utils.getCompatColor
*
* Created by lijiankun on 17/8/11.
*/
@Suppress("unused")
class ShadowLayout(
context: Context,
attrs: AttributeSet? = null

@ -21,6 +21,7 @@ import org.jetbrains.anko.backgroundColor
import org.jetbrains.anko.bottomPadding
import org.jetbrains.anko.topPadding
@Suppress("unused")
class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, attrs) {
val toolbar: Toolbar

@ -11,6 +11,7 @@ import android.view.View
import io.legado.app.R
@Suppress("unused", "MemberVisibilityCanBePrivate")
class RefreshProgressBar @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,

@ -17,6 +17,7 @@ import io.legado.app.utils.dp
* RotateLoading
* Created by Victor on 2015/4/28.
*/
@Suppress("MemberVisibilityCanBePrivate")
class RotateLoading : View {
private lateinit var mPaint: Paint

@ -20,6 +20,7 @@ import android.graphics.*
import android.view.View
import android.view.animation.AccelerateInterpolator
import java.util.*
import kotlin.math.pow
class ExplosionAnimator(private val mContainer: View, bitmap: Bitmap, bound: Rect) :
ValueAnimator() {
@ -99,20 +100,20 @@ class ExplosionAnimator(private val mContainer: View, bitmap: Bitmap, bound: Rec
}
private inner class Particle {
internal var alpha: Float = 0.toFloat()
internal var color: Int = 0
internal var cx: Float = 0.toFloat()
internal var cy: Float = 0.toFloat()
internal var radius: Float = 0.toFloat()
internal var baseCx: Float = 0.toFloat()
internal var baseCy: Float = 0.toFloat()
internal var baseRadius: Float = 0.toFloat()
internal var top: Float = 0.toFloat()
internal var bottom: Float = 0.toFloat()
internal var mag: Float = 0.toFloat()
internal var neg: Float = 0.toFloat()
internal var life: Float = 0.toFloat()
internal var overflow: Float = 0.toFloat()
var alpha: Float = 0.toFloat()
var color: Int = 0
var cx: Float = 0.toFloat()
var cy: Float = 0.toFloat()
var radius: Float = 0.toFloat()
var baseCx: Float = 0.toFloat()
var baseCy: Float = 0.toFloat()
var baseRadius: Float = 0.toFloat()
var top: Float = 0.toFloat()
var bottom: Float = 0.toFloat()
var mag: Float = 0.toFloat()
var neg: Float = 0.toFloat()
var life: Float = 0.toFloat()
var overflow: Float = 0.toFloat()
fun advance(factor: Float) {
@ -130,7 +131,7 @@ class ExplosionAnimator(private val mContainer: View, bitmap: Bitmap, bound: Rec
alpha = 1f - f
f = bottom * f2
cx = baseCx + f
cy = (baseCy - this.neg * Math.pow(f.toDouble(), 2.0)).toFloat() - f * mag
cy = (baseCy - this.neg * f.toDouble().pow(2.0)).toFloat() - f * mag
radius = V + (baseRadius - V) * f2
}
}

@ -29,6 +29,7 @@ import android.view.View
import java.util.*
@Suppress("unused")
class ExplosionView : View {
private var customDuration = ExplosionAnimator.DEFAULT_DURATION
@ -75,8 +76,8 @@ class ExplosionView : View {
this.customDuration = customDuration
}
fun addActionEvent(ievents: OnAnimatorListener) {
this.mZAnimatorListener = ievents
fun addActionEvent(iEvents: OnAnimatorListener) {
this.mZAnimatorListener = iEvents
}

@ -24,6 +24,7 @@ import io.legado.app.utils.sp
import kotlin.math.min
import kotlin.math.pow
@Suppress("unused", "MemberVisibilityCanBePrivate")
class CircleImageView(context: Context, attrs: AttributeSet) :
AppCompatImageView(
context,

@ -16,7 +16,7 @@ import java.io.IOException
import kotlin.math.*
@Suppress("unused", "WeakerAccess")
@Suppress("unused", "WeakerAccess", "MemberVisibilityCanBePrivate")
object BitmapUtils {
/**

@ -7,7 +7,7 @@ import androidx.annotation.FloatRange
import java.util.*
import kotlin.math.*
@Suppress("unused")
@Suppress("unused", "MemberVisibilityCanBePrivate")
object ColorUtils {
fun intToString(intColor: Int): String {

@ -6,6 +6,7 @@ import androidx.constraintlayout.widget.ConstraintSet
import androidx.transition.TransitionManager
@Suppress("MemberVisibilityCanBePrivate", "unused")
class ConstraintUtil(private val constraintLayout: ConstraintLayout) {
private var begin: ConstraintBegin? = null
@ -55,6 +56,7 @@ class ConstraintUtil(private val constraintLayout: ConstraintLayout) {
}
@Suppress("unused", "MemberVisibilityCanBePrivate")
class ConstraintBegin(
private val constraintLayout: ConstraintLayout,
private val applyConstraintSet: ConstraintSet

@ -8,6 +8,7 @@ import androidx.documentfile.provider.DocumentFile
import java.util.*
@Suppress("MemberVisibilityCanBePrivate")
object DocumentUtils {
fun exists(root: DocumentFile, fileName: String, vararg subDirs: String): Boolean {

@ -1,3 +1,5 @@
@file:Suppress("unused")
package io.legado.app.utils
import androidx.appcompat.app.AppCompatActivity

@ -11,7 +11,7 @@ import java.text.SimpleDateFormat
import java.util.*
import java.util.regex.Pattern
@Suppress("unused")
@Suppress("unused", "MemberVisibilityCanBePrivate")
object FileUtils {
fun exists(root: File, vararg subDirFiles: String): Boolean {
@ -489,11 +489,10 @@ object FileUtils {
*/
@JvmOverloads
fun writeText(filepath: String, content: String, charset: String = "utf-8"): Boolean {
try {
return try {
writeBytes(filepath, content.toByteArray(charset(charset)))
return true
} catch (e: UnsupportedEncodingException) {
return false
false
}
}
@ -569,15 +568,15 @@ object FileUtils {
* 获取文件名不包括扩展名
*/
fun getNameExcludeExtension(path: String): String {
try {
return try {
var fileName = File(path).name
val lastIndexOf = fileName.lastIndexOf(".")
if (lastIndexOf != -1) {
fileName = fileName.substring(0, lastIndexOf)
}
return fileName
fileName
} catch (e: Exception) {
return ""
""
}
}

@ -1,3 +1,5 @@
@file:Suppress("unused")
package io.legado.app.utils
import android.app.Activity
@ -14,7 +16,8 @@ import org.jetbrains.anko.defaultSharedPreferences
import org.jetbrains.anko.internals.AnkoInternals
@Suppress("DEPRECATION")
fun Fragment.isOnline() = requireContext().connectivityManager.activeNetworkInfo?.isConnected == true
fun Fragment.isOnline() =
requireContext().connectivityManager.activeNetworkInfo?.isConnected == true
fun Fragment.getPrefBoolean(key: String, defValue: Boolean = false) =
requireContext().defaultSharedPreferences.getBoolean(key, defValue)
@ -40,7 +43,10 @@ fun Fragment.getPrefString(key: String, defValue: String? = null) =
fun Fragment.putPrefString(key: String, value: String) =
requireContext().defaultSharedPreferences.edit { putString(key, value) }
fun Fragment.getPrefStringSet(key: String, defValue: MutableSet<String>? = null) =
fun Fragment.getPrefStringSet(
key: String,
defValue: MutableSet<String>? = null
): MutableSet<String>? =
requireContext().defaultSharedPreferences.getStringSet(key, defValue)
fun Fragment.putPrefStringSet(key: String, value: MutableSet<String>) =
@ -51,15 +57,23 @@ fun Fragment.removePref(key: String) =
fun Fragment.getCompatColor(@ColorRes id: Int): Int = requireContext().getCompatColor(id)
fun Fragment.getCompatDrawable(@DrawableRes id: Int): Drawable? = requireContext().getCompatDrawable(id)
fun Fragment.getCompatDrawable(@DrawableRes id: Int): Drawable? =
requireContext().getCompatDrawable(id)
fun Fragment.getCompatColorStateList(@ColorRes id: Int): ColorStateList? = requireContext().getCompatColorStateList(id)
fun Fragment.getCompatColorStateList(@ColorRes id: Int): ColorStateList? =
requireContext().getCompatColorStateList(id)
inline fun <reified T : Activity> Fragment.startActivity(vararg params: Pair<String, Any?>) =
AnkoInternals.internalStartActivity(requireActivity(), T::class.java, params)
inline fun <reified T : Activity> Fragment.startActivityForResult(requestCode: Int, vararg params: Pair<String, Any?>) =
startActivityForResult(AnkoInternals.createIntent(requireActivity(), T::class.java, params), requestCode)
inline fun <reified T : Activity> Fragment.startActivityForResult(
requestCode: Int,
vararg params: Pair<String, Any?>
) =
startActivityForResult(
AnkoInternals.createIntent(requireActivity(), T::class.java, params),
requestCode
)
inline fun <reified T : Service> Fragment.startService(vararg params: Pair<String, Any?>) =
AnkoInternals.internalStartService(requireActivity(), T::class.java, params)

@ -10,41 +10,38 @@ import org.jsoup.select.NodeVisitor
fun Element.textArray(): Array<String> {
val accum = StringUtil.borrowBuilder()
val sb = StringUtil.borrowBuilder()
NodeTraversor.traverse(object : NodeVisitor {
override fun head(node: Node, depth: Int) {
if (node is TextNode) {
appendNormalisedText(accum, node)
appendNormalisedText(sb, node)
} else if (node is Element) {
if (accum.isNotEmpty() &&
if (sb.isNotEmpty() &&
(node.isBlock || node.tag().name == "br") &&
!lastCharIsWhitespace(accum)
) accum.append("\n")
!lastCharIsWhitespace(sb)
) sb.append("\n")
}
}
override fun tail(node: Node, depth: Int) {
if (node is Element) {
if (node.isBlock && node.nextSibling() is TextNode && !lastCharIsWhitespace(
accum
)
) accum.append("\n")
if (node.isBlock && node.nextSibling() is TextNode
&& !lastCharIsWhitespace(sb)
) {
sb.append("\n")
}
}
}
}, this)
val text = StringUtil.releaseBuilder(accum).trim { it <= ' ' }
val text = StringUtil.releaseBuilder(sb).trim { it <= ' ' }
return text.splitNotBlank("\n")
}
private fun appendNormalisedText(accum: StringBuilder, textNode: TextNode) {
private fun appendNormalisedText(sb: StringBuilder, textNode: TextNode) {
val text = textNode.wholeText
if (preserveWhitespace(textNode.parentNode()) || textNode is CDataNode)
accum.append(text)
else StringUtil.appendNormalisedWhitespace(
accum,
text,
lastCharIsWhitespace(accum)
)
sb.append(text)
else StringUtil.appendNormalisedWhitespace(sb, text, lastCharIsWhitespace(sb))
}
private fun preserveWhitespace(node: Node?): Boolean {

@ -72,14 +72,6 @@ object LanguageUtils {
@Suppress("DEPRECATION")
locale = context.resources.configuration.locale
}
/*
Log.d("h11128", "displayName " + locale.displayName)
Log.d("h11128", "displayCountry " + locale.displayCountry)
Log.d("h11128", "displayLanguage " + locale.displayLanguage)
Log.d("h11128", "Language " + locale.language)
Log.d("h11128", "Country " + locale.country)
*/
return locale
}

@ -12,7 +12,7 @@ import kotlin.math.abs
import kotlin.math.log10
import kotlin.math.pow
@Suppress("unused")
@Suppress("unused", "MemberVisibilityCanBePrivate")
object StringUtils {
private const val HOUR_OF_DAY = 24
private const val DAY_OF_YESTERDAY = 2

@ -7,7 +7,6 @@ import android.graphics.Canvas
import android.os.Build
import android.view.View
import android.view.View.*
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.RadioGroup
import android.widget.SeekBar
@ -80,13 +79,6 @@ fun View.screenshot(): Bitmap? {
}.getOrNull()
}
fun View.setMargin(left: Int, top: Int, right: Int, bottom: Int) {
if (layoutParams is ViewGroup.MarginLayoutParams) {
(layoutParams as ViewGroup.MarginLayoutParams).setMargins(left, top, right, bottom)
requestLayout()
}
}
fun SeekBar.progressAdd(int: Int) {
progress += int
}

Loading…
Cancel
Save