pull/1395/head
gedoor 3 years ago
parent d2c7085962
commit 028d496b30
  1. 6
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditAdapter.kt
  3. 6
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditAdapter.kt
  4. 4
      app/src/main/java/io/legado/app/ui/widget/code/CodeViewExtensions.kt
  5. 6
      app/src/main/java/io/legado/app/ui/widget/dialog/CodeDialog.kt
  6. 27
      app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt
  7. 18
      app/src/main/res/layout/item_source_import.xml

@ -28,6 +28,7 @@ import io.legado.app.ui.widget.dialog.CodeDialog
import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import splitties.views.onClick
/**
@ -216,6 +217,11 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
override fun registerListener(holder: ItemViewHolder, binding: ItemSourceImportBinding) {
binding.apply {
root.onClick {
cbSourceName.isChecked = !cbSourceName.isChecked
viewModel.selectStatus[holder.layoutPosition] = cbSourceName.isChecked
upSelectText()
}
cbSourceName.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) {
viewModel.selectStatus[holder.layoutPosition] = isChecked

@ -9,9 +9,9 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.databinding.ItemSourceEditBinding
import io.legado.app.utils.addJsPattern
import io.legado.app.utils.addJsonPattern
import io.legado.app.utils.addLegadoPattern
import io.legado.app.ui.widget.code.addJsPattern
import io.legado.app.ui.widget.code.addJsonPattern
import io.legado.app.ui.widget.code.addLegadoPattern
class BookSourceEditAdapter : RecyclerView.Adapter<BookSourceEditAdapter.MyViewHolder>() {

@ -9,9 +9,9 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.databinding.ItemSourceEditBinding
import io.legado.app.utils.addJsPattern
import io.legado.app.utils.addJsonPattern
import io.legado.app.utils.addLegadoPattern
import io.legado.app.ui.widget.code.addJsPattern
import io.legado.app.ui.widget.code.addJsonPattern
import io.legado.app.ui.widget.code.addLegadoPattern
class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHolder>() {

@ -1,11 +1,9 @@
@file:Suppress("unused")
package io.legado.app.utils
package io.legado.app.ui.widget.code
import android.graphics.Color
import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.widget.code.CodeView
import splitties.init.appCtx
import java.util.regex.Pattern

@ -5,9 +5,9 @@ import android.view.View
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogCodeViewBinding
import io.legado.app.utils.addJsPattern
import io.legado.app.utils.addJsonPattern
import io.legado.app.utils.addLegadoPattern
import io.legado.app.ui.widget.code.addJsPattern
import io.legado.app.ui.widget.code.addJsonPattern
import io.legado.app.ui.widget.code.addLegadoPattern
import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding

@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.GravityCompat
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
@ -294,14 +295,14 @@ class FastScroller : LinearLayout {
if (event.x < mHandleView.x - ViewCompat.getPaddingStart(mHandleView)) {
return false
}
if (!mScrollbar.isVisible) {
return false
}
requestDisallowInterceptTouchEvent(true)
setHandleSelected(true)
handler.removeCallbacks(mScrollbarHider)
cancelAnimation(mScrollbarAnimator)
cancelAnimation(mBubbleAnimator)
if (!isViewVisible(mScrollbar)) {
showScrollbar()
}
if (mShowBubble && mSectionIndexer != null) {
showBubble()
}
@ -341,29 +342,29 @@ class FastScroller : LinearLayout {
}
private fun setRecyclerViewPosition(y: Float) {
if (mRecyclerView != null && mRecyclerView!!.adapter != null) {
val itemCount = mRecyclerView!!.adapter!!.itemCount
mRecyclerView?.adapter?.let { adapter ->
val itemCount = adapter.itemCount
val proportion: Float = when {
mHandleView.y == 0f -> 0f
mHandleView.y + mHandleHeight >= mViewHeight - sTrackSnapRange -> 1f
else -> y / mViewHeight.toFloat()
}
var scrolledItemCount = (proportion * itemCount).roundToInt()
if (isLayoutReversed(mRecyclerView!!.layoutManager!!)) {
if (isLayoutReversed(mRecyclerView?.layoutManager)) {
scrolledItemCount = itemCount - scrolledItemCount
}
val targetPos = getValueInRange(0, itemCount - 1, scrolledItemCount)
mRecyclerView!!.layoutManager!!.scrollToPosition(targetPos)
if (mShowBubble && mSectionIndexer != null) {
mBubbleView.text = mSectionIndexer!!.getSectionText(targetPos)
mRecyclerView?.layoutManager?.scrollToPosition(targetPos)
mSectionIndexer?.let { sectionIndexer ->
if (mShowBubble) {
mBubbleView.text = sectionIndexer.getSectionText(targetPos)
}
}
}
}
private fun getScrollProportion(recyclerView: RecyclerView?): Float {
if (recyclerView == null) {
return 0f
}
recyclerView ?: return 0f
val verticalScrollOffset = recyclerView.computeVerticalScrollOffset()
val verticalScrollRange = recyclerView.computeVerticalScrollRange()
val rangeDiff = (verticalScrollRange - mViewHeight).toFloat()
@ -401,7 +402,7 @@ class FastScroller : LinearLayout {
mHandleHeight = mHandleView.measuredHeight
}
private fun isLayoutReversed(layoutManager: RecyclerView.LayoutManager): Boolean {
private fun isLayoutReversed(layoutManager: RecyclerView.LayoutManager?): Boolean {
if (layoutManager is LinearLayoutManager) {
return layoutManager.reverseLayout
} else if (layoutManager is StaggeredGridLayoutManager) {

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
@ -8,25 +9,28 @@
<io.legado.app.lib.theme.view.ThemeCheckBox
android:id="@+id/cb_source_name"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1" />
android:maxLines="1"
tools:ignore="TouchTargetSizeCheck" />
<TextView
android:id="@+id/tv_source_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:padding="8dp"
android:textColor="@color/secondaryText" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_see"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:padding="8dp"
android:textColor="@color/secondaryText"
android:text="@string/see" />

Loading…
Cancel
Save