diff --git a/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt b/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt index a2f354772..4d51c5b80 100644 --- a/app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/LabelsBar.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() diff --git a/app/src/main/java/io/legado/app/ui/widget/SearchView.kt b/app/src/main/java/io/legado/app/ui/widget/SearchView.kt index 6d340c6d7..2f83c8594 100644 --- a/app/src/main/java/io/legado/app/ui/widget/SearchView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/SearchView.kt @@ -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, diff --git a/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt b/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt index 7cba90778..fd478ae42 100644 --- a/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt @@ -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 diff --git a/app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt b/app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt index 0f6ad3200..76668e772 100644 --- a/app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt +++ b/app/src/main/java/io/legado/app/ui/widget/ShadowLayout.kt @@ -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 diff --git a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt index 2143b4e48..a30873671 100644 --- a/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/TitleBar.kt @@ -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 diff --git a/app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt b/app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt index df123bfcd..1791b3be7 100644 --- a/app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/anima/RefreshProgressBar.kt @@ -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, diff --git a/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt b/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt index 7a5e436c3..13c4f346d 100644 --- a/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt +++ b/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt @@ -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 diff --git a/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionAnimator.kt b/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionAnimator.kt index 9b80b1825..6542ea55f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionAnimator.kt +++ b/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionAnimator.kt @@ -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 } } diff --git a/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt b/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt index c79695a51..9eef530f2 100644 --- a/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/anima/explosion_field/ExplosionView.kt @@ -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 } diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt index 43e3f5506..b1d1a5376 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt @@ -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, diff --git a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt index 7786bfed4..6be7ea2c3 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -16,7 +16,7 @@ import java.io.IOException import kotlin.math.* -@Suppress("unused", "WeakerAccess") +@Suppress("unused", "WeakerAccess", "MemberVisibilityCanBePrivate") object BitmapUtils { /** diff --git a/app/src/main/java/io/legado/app/utils/ColorUtils.kt b/app/src/main/java/io/legado/app/utils/ColorUtils.kt index 8a9a35052..800cd3c8b 100644 --- a/app/src/main/java/io/legado/app/utils/ColorUtils.kt +++ b/app/src/main/java/io/legado/app/utils/ColorUtils.kt @@ -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 { diff --git a/app/src/main/java/io/legado/app/utils/ConstraintUtil.kt b/app/src/main/java/io/legado/app/utils/ConstraintUtil.kt index b7ef740cc..bb2cc7bad 100644 --- a/app/src/main/java/io/legado/app/utils/ConstraintUtil.kt +++ b/app/src/main/java/io/legado/app/utils/ConstraintUtil.kt @@ -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 diff --git a/app/src/main/java/io/legado/app/utils/DocumentUtils.kt b/app/src/main/java/io/legado/app/utils/DocumentUtils.kt index 041189c7f..64bc9e233 100644 --- a/app/src/main/java/io/legado/app/utils/DocumentUtils.kt +++ b/app/src/main/java/io/legado/app/utils/DocumentUtils.kt @@ -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 { diff --git a/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt b/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt index 0d9473a3c..c0aedf8b3 100644 --- a/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt @@ -1,3 +1,5 @@ +@file:Suppress("unused") + package io.legado.app.utils import androidx.appcompat.app.AppCompatActivity diff --git a/app/src/main/java/io/legado/app/utils/FileUtils.kt b/app/src/main/java/io/legado/app/utils/FileUtils.kt index ef67fab8b..ecb22f244 100644 --- a/app/src/main/java/io/legado/app/utils/FileUtils.kt +++ b/app/src/main/java/io/legado/app/utils/FileUtils.kt @@ -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 "" + "" } } diff --git a/app/src/main/java/io/legado/app/utils/FragmentExtensions.kt b/app/src/main/java/io/legado/app/utils/FragmentExtensions.kt index de7f10b96..2e812a241 100644 --- a/app/src/main/java/io/legado/app/utils/FragmentExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/FragmentExtensions.kt @@ -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? = null) = +fun Fragment.getPrefStringSet( + key: String, + defValue: MutableSet? = null +): MutableSet? = requireContext().defaultSharedPreferences.getStringSet(key, defValue) fun Fragment.putPrefStringSet(key: String, value: MutableSet) = @@ -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 Fragment.startActivity(vararg params: Pair) = AnkoInternals.internalStartActivity(requireActivity(), T::class.java, params) -inline fun Fragment.startActivityForResult(requestCode: Int, vararg params: Pair) = - startActivityForResult(AnkoInternals.createIntent(requireActivity(), T::class.java, params), requestCode) +inline fun Fragment.startActivityForResult( + requestCode: Int, + vararg params: Pair +) = + startActivityForResult( + AnkoInternals.createIntent(requireActivity(), T::class.java, params), + requestCode + ) inline fun Fragment.startService(vararg params: Pair) = AnkoInternals.internalStartService(requireActivity(), T::class.java, params) diff --git a/app/src/main/java/io/legado/app/utils/JsoupExtensions.kt b/app/src/main/java/io/legado/app/utils/JsoupExtensions.kt index 3f347e4a1..2c9829ddd 100644 --- a/app/src/main/java/io/legado/app/utils/JsoupExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/JsoupExtensions.kt @@ -10,41 +10,38 @@ import org.jsoup.select.NodeVisitor fun Element.textArray(): Array { - 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 { diff --git a/app/src/main/java/io/legado/app/utils/LanguageUtils.kt b/app/src/main/java/io/legado/app/utils/LanguageUtils.kt index def23e1e8..7a8572ded 100644 --- a/app/src/main/java/io/legado/app/utils/LanguageUtils.kt +++ b/app/src/main/java/io/legado/app/utils/LanguageUtils.kt @@ -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 } diff --git a/app/src/main/java/io/legado/app/utils/StringUtils.kt b/app/src/main/java/io/legado/app/utils/StringUtils.kt index 4ee24ba2a..8ee17662d 100644 --- a/app/src/main/java/io/legado/app/utils/StringUtils.kt +++ b/app/src/main/java/io/legado/app/utils/StringUtils.kt @@ -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 diff --git a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt index 7ed6d8cd6..122f814a0 100644 --- a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt @@ -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 }