Cleanup code
This commit is contained in:
1 parent
b07fd2bc4f
commit
7b81a9aa50
29 files changed
+40
-86
No files matched your search
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.hippo.ehviewer.client
|
||||
|
||||
import android.text.TextUtils
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import java.util.regex.Pattern
|
||||
@@ -123,9 +122,9 @@ object EhUtils {
|
||||
|
||||
fun getSuitableTitle(gi: GalleryInfo): String {
|
||||
return if (Settings.showJpnTitle) {
|
||||
if (TextUtils.isEmpty(gi.titleJpn)) gi.title else gi.titleJpn
|
||||
if (gi.titleJpn.isNullOrEmpty()) gi.title else gi.titleJpn
|
||||
} else {
|
||||
if (TextUtils.isEmpty(gi.title)) gi.titleJpn else gi.title
|
||||
if (gi.title.isNullOrEmpty()) gi.titleJpn else gi.title
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.hippo.ehviewer.client.parser
|
||||
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.text.TextUtils
|
||||
import com.hippo.ehviewer.client.EhUrl
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder
|
||||
import java.io.UnsupportedEncodingException
|
||||
@@ -87,7 +86,7 @@ object GalleryListUrlParser {
|
||||
return null
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(uploader)) {
|
||||
if (uploader.isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
val builder = ListUrlBuilder()
|
||||
@@ -116,7 +115,7 @@ object GalleryListUrlParser {
|
||||
return null
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(tag)) {
|
||||
if (tag.isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
val builder = ListUrlBuilder()
|
||||
@@ -128,7 +127,7 @@ object GalleryListUrlParser {
|
||||
// TODO get page
|
||||
private fun parseToplist(path: String): ListUrlBuilder? {
|
||||
val uri = Uri.parse(path)
|
||||
if (uri == null || TextUtils.isEmpty(uri.getQueryParameter("tl"))) {
|
||||
if (uri == null || uri.getQueryParameter("tl").isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
val tl = uri.getQueryParameter("tl")!!.toInt()
|
||||
|
||||
@@ -3,6 +3,6 @@ package com.hippo.ehviewer.ui.legacy
|
||||
import android.content.Context
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
open class BaseDialogBuilder constructor(
|
||||
open class BaseDialogBuilder(
|
||||
context: Context,
|
||||
) : MaterialAlertDialogBuilder(context)
|
||||
@@ -20,7 +20,7 @@ import android.view.LayoutInflater
|
||||
import android.widget.CheckBox
|
||||
import com.hippo.ehviewer.R
|
||||
|
||||
class CheckBoxDialogBuilder constructor(
|
||||
class CheckBoxDialogBuilder(
|
||||
context: Context,
|
||||
message: String?,
|
||||
checkText: String?,
|
||||
|
||||
@@ -26,7 +26,7 @@ import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.hippo.ehviewer.R
|
||||
|
||||
class EditTextDialogBuilder constructor(
|
||||
class EditTextDialogBuilder(
|
||||
context: Context,
|
||||
text: String?,
|
||||
hint: String?,
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.AbstractComposeView
|
||||
import com.google.accompanist.themeadapter.material3.Mdc3Theme
|
||||
@@ -15,7 +15,7 @@ class SimpleRatingView @JvmOverloads constructor(
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0,
|
||||
) : AbstractComposeView(context, attrs, defStyle) {
|
||||
var rating by mutableStateOf(0f)
|
||||
var rating by mutableFloatStateOf(0f)
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
@@ -1055,7 +1054,7 @@ class DownloadsScene :
|
||||
override fun onClick(v: View) {
|
||||
context ?: return
|
||||
val text = mBuilder.text
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
if (text.isEmpty()) {
|
||||
mBuilder.setError(getString(R.string.label_text_is_empty))
|
||||
} else if (getString(R.string.default_download_label_name) == text) {
|
||||
mBuilder.setError(getString(R.string.label_text_is_invalid))
|
||||
@@ -1085,7 +1084,7 @@ class DownloadsScene :
|
||||
override fun onClick(v: View) {
|
||||
context ?: return
|
||||
val text = mBuilder.text
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
if (text.isEmpty()) {
|
||||
mBuilder.setError(getString(R.string.label_text_is_empty))
|
||||
} else if (getString(R.string.default_download_label_name) == text) {
|
||||
mBuilder.setError(getString(R.string.label_text_is_invalid))
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.app.Activity
|
||||
import android.content.DialogInterface
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
@@ -265,7 +264,7 @@ class FavoritesScene :
|
||||
}
|
||||
}
|
||||
val keyword = mUrlBuilder!!.keyword
|
||||
if (TextUtils.isEmpty(keyword)) {
|
||||
if (keyword.isNullOrEmpty()) {
|
||||
if (favCatName != mOldFavCat) {
|
||||
setSearchBarHint(getString(R.string.favorites_title, favCatName))
|
||||
}
|
||||
@@ -622,7 +621,7 @@ class FavoritesScene :
|
||||
} else {
|
||||
mHelper.onGetPageData(taskId, 1, 0, null, null, list)
|
||||
}
|
||||
if (TextUtils.isEmpty(keyword)) {
|
||||
if (keyword.isNullOrEmpty()) {
|
||||
mFavLocalCount = list.size
|
||||
Settings.favLocalCount = mFavLocalCount
|
||||
if (mDrawerAdapter != null) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.TextUtils
|
||||
import android.text.style.ImageSpan
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
@@ -488,7 +487,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
|
||||
var text = builder.text.trim { it <= ' ' }
|
||||
|
||||
// Check name empty
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
if (text.isEmpty()) {
|
||||
withUIContext {
|
||||
builder.setError(getString(R.string.name_is_empty))
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
|
||||
}
|
||||
}
|
||||
|
||||
private inner class SuggestionAdapter constructor(private val mInflater: LayoutInflater) :
|
||||
private inner class SuggestionAdapter(private val mInflater: LayoutInflater) :
|
||||
RecyclerView.Adapter<SuggestionHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SuggestionHolder {
|
||||
@@ -246,7 +246,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
|
||||
}
|
||||
}
|
||||
|
||||
inner class TagSuggestion constructor(
|
||||
inner class TagSuggestion(
|
||||
private var mHint: String?,
|
||||
private var mKeyword: String,
|
||||
) :
|
||||
@@ -272,7 +272,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
|
||||
}
|
||||
}
|
||||
|
||||
inner class KeywordSuggestion constructor(private val mKeyword: String) : Suggestion() {
|
||||
inner class KeywordSuggestion(private val mKeyword: String) : Suggestion() {
|
||||
|
||||
override fun getText(textView: TextView): CharSequence? {
|
||||
return if (textView.id == android.R.id.text1) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.PersistableBundle
|
||||
import android.text.TextUtils
|
||||
import android.view.textclassifier.TextClassifier
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.ui.MainActivity
|
||||
@@ -64,5 +63,5 @@ fun ClipboardManager.getUrlFromClipboard(context: Context): String? {
|
||||
}
|
||||
val item = primaryClip?.getItemAt(0)
|
||||
val string = item?.coerceToText(context).toString()
|
||||
return if (!TextUtils.isEmpty(string)) string else null
|
||||
return string.ifEmpty { null }
|
||||
}
|
||||
@@ -4,5 +4,5 @@ import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
class IntList constructor(private val delegate: MutableList<Int> = mutableListOf()) :
|
||||
class IntList(private val delegate: MutableList<Int> = mutableListOf()) :
|
||||
Parcelable, MutableList<Int> by delegate
|
||||
@@ -4,5 +4,5 @@ import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
class LongList constructor(private val delegate: MutableList<Long> = mutableListOf()) :
|
||||
class LongList(private val delegate: MutableList<Long> = mutableListOf()) :
|
||||
Parcelable, MutableList<Long> by delegate
|
||||
@@ -35,7 +35,6 @@ import android.os.Environment
|
||||
import android.os.ParcelFileDescriptor
|
||||
import android.os.ParcelFileDescriptor.MODE_READ_ONLY
|
||||
import android.provider.MediaStore
|
||||
import android.text.TextUtils
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
@@ -397,7 +396,7 @@ class ReaderActivity : EhActivity() {
|
||||
var mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||
MimeTypeMap.getFileExtensionFromUrl(filename),
|
||||
)
|
||||
if (TextUtils.isEmpty(mimeType)) {
|
||||
if (mimeType.isNullOrEmpty()) {
|
||||
mimeType = "image/jpeg"
|
||||
}
|
||||
|
||||
@@ -482,7 +481,7 @@ class ReaderActivity : EhActivity() {
|
||||
var mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||
MimeTypeMap.getFileExtensionFromUrl(filename),
|
||||
)
|
||||
if (TextUtils.isEmpty(mimeType)) {
|
||||
if (mimeType.isNullOrEmpty()) {
|
||||
mimeType = "image/jpeg"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
|
||||
/**
|
||||
* Checks whether if the device has a display cutout (i.e. notch, camera cutout, etc.).
|
||||
@@ -9,6 +8,5 @@ import android.os.Build
|
||||
* Only works in Android 9+.
|
||||
*/
|
||||
fun Activity.hasDisplayCutout(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
|
||||
window.decorView.rootWindowInsets?.displayCutout != null
|
||||
return window.decorView.rootWindowInsets?.displayCutout != null
|
||||
}
|
||||
Reference in new issue
Block a user