|
|
@ -8,6 +8,7 @@ import android.view.ViewGroup |
|
|
|
import android.widget.ImageView |
|
|
|
import android.widget.ImageView |
|
|
|
import android.widget.PopupMenu |
|
|
|
import android.widget.PopupMenu |
|
|
|
import androidx.core.os.bundleOf |
|
|
|
import androidx.core.os.bundleOf |
|
|
|
|
|
|
|
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.base.adapter.ItemViewHolder |
|
|
|
import io.legado.app.base.adapter.ItemViewHolder |
|
|
@ -27,6 +28,51 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
|
|
|
|
|
|
|
private val selected = linkedSetOf<BookSource>() |
|
|
|
private val selected = linkedSetOf<BookSource>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val diffItemCallback: DiffUtil.ItemCallback<BookSource> |
|
|
|
|
|
|
|
get() = object : DiffUtil.ItemCallback<BookSource>() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun areItemsTheSame(oldItem: BookSource, newItem: BookSource): Boolean { |
|
|
|
|
|
|
|
return oldItem.bookSourceUrl == newItem.bookSourceUrl |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun areContentsTheSame(oldItem: BookSource, newItem: BookSource): Boolean { |
|
|
|
|
|
|
|
if (oldItem.bookSourceName != newItem.bookSourceName) |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
if (oldItem.bookSourceGroup != newItem.bookSourceGroup) |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
if (oldItem.enabled != newItem.enabled) |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
if (oldItem.enabledExplore != newItem.enabledExplore |
|
|
|
|
|
|
|
|| oldItem.exploreUrl != newItem.exploreUrl |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun getChangePayload(oldItem: BookSource, newItem: BookSource): Any? { |
|
|
|
|
|
|
|
val payload = Bundle() |
|
|
|
|
|
|
|
if (oldItem.bookSourceName != newItem.bookSourceName) { |
|
|
|
|
|
|
|
payload.putString("name", newItem.bookSourceName) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (oldItem.bookSourceGroup != newItem.bookSourceGroup) { |
|
|
|
|
|
|
|
payload.putString("group", newItem.bookSourceGroup) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (oldItem.enabled != newItem.enabled) { |
|
|
|
|
|
|
|
payload.putBoolean("enabled", newItem.enabled) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (oldItem.enabledExplore != newItem.enabledExplore |
|
|
|
|
|
|
|
|| oldItem.exploreUrl != newItem.exploreUrl |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
payload.putBoolean("showExplore", true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (payload.isEmpty) { |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return payload |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun getViewBinding(parent: ViewGroup): ItemBookSourceBinding { |
|
|
|
override fun getViewBinding(parent: ViewGroup): ItemBookSourceBinding { |
|
|
|
return ItemBookSourceBinding.inflate(inflater, parent, false) |
|
|
|
return ItemBookSourceBinding.inflate(inflater, parent, false) |
|
|
|
} |
|
|
|
} |
|
|
|