|
|
|
@ -49,41 +49,9 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 { |
|
|
|
@ -109,17 +77,19 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
swtEnabled.isChecked = item.enabled |
|
|
|
|
cbBookSource.isChecked = selected.contains(item) |
|
|
|
|
ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" |
|
|
|
|
ivDebugText.visibility = if(ivDebugText.text.toString().length > 1) View.VISIBLE else View.GONE |
|
|
|
|
ivDebugText.visibility = |
|
|
|
|
if (ivDebugText.text.toString().length > 1) View.VISIBLE else View.GONE |
|
|
|
|
upShowExplore(ivExplore, item) |
|
|
|
|
} else { |
|
|
|
|
payload.keySet().map { |
|
|
|
|
when (it) { |
|
|
|
|
"selected" -> cbBookSource.isChecked = selected.contains(item) |
|
|
|
|
"selected" -> cbBookSource.isChecked = selected.contains(item) |
|
|
|
|
"checkSourceMessage" -> { |
|
|
|
|
ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" |
|
|
|
|
val isEmpty = ivDebugText.text.toString().isEmpty() |
|
|
|
|
var isFinalMessage = ivDebugText.text.toString().contains(Regex("成功|失败")) |
|
|
|
|
if (!isEmpty && !Debug.isChecking && !isFinalMessage){ |
|
|
|
|
var isFinalMessage = |
|
|
|
|
ivDebugText.text.toString().contains(Regex("成功|失败")) |
|
|
|
|
if (!isEmpty && !Debug.isChecking && !isFinalMessage) { |
|
|
|
|
Debug.updateFinalMessage(item.bookSourceUrl, "失败") |
|
|
|
|
ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" |
|
|
|
|
isFinalMessage = true |
|
|
|
@ -190,6 +160,8 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
qyMenu.setTitle(R.string.enable_explore) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
val loginMenu = popupMenu.menu.findItem(R.id.menu_login) |
|
|
|
|
loginMenu.isVisible = !source.loginUrl.isNullOrBlank() |
|
|
|
|
popupMenu.setOnMenuItemClickListener { menuItem -> |
|
|
|
|
when (menuItem.itemId) { |
|
|
|
|
R.id.menu_top -> callBack.toTop(source) |
|
|
|
|