mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 01:25:07 +01:00
fix tapping on ext settings/install
This commit is contained in:
parent
7be208d630
commit
a830e0ccee
@ -6,9 +6,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.core.view.get
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewpager.widget.PagerAdapter.POSITION_NONE
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
@ -51,11 +49,11 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||||||
/**
|
/**
|
||||||
* Adapter containing the list of extensions
|
* Adapter containing the list of extensions
|
||||||
*/
|
*/
|
||||||
private var adapter: ExtensionAdapter? = null
|
private var extAdapter: ExtensionAdapter? = null
|
||||||
private var migAdapter: FlexibleAdapter<IFlexible<*>>? = null
|
private var migAdapter: FlexibleAdapter<IFlexible<*>>? = null
|
||||||
|
|
||||||
val adapters
|
val adapters
|
||||||
get() = listOf(adapter, migAdapter)
|
get() = listOf(extAdapter, migAdapter)
|
||||||
|
|
||||||
val presenter = ExtensionBottomPresenter(this)
|
val presenter = ExtensionBottomPresenter(this)
|
||||||
|
|
||||||
@ -78,8 +76,8 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||||||
|
|
||||||
fun onCreate(controller: BrowseController) {
|
fun onCreate(controller: BrowseController) {
|
||||||
// Initialize adapter, scroll listener and recycler views
|
// Initialize adapter, scroll listener and recycler views
|
||||||
adapter = ExtensionAdapter(this)
|
extAdapter = ExtensionAdapter(this)
|
||||||
adapter?.stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY
|
extAdapter?.stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY
|
||||||
if (migAdapter == null) {
|
if (migAdapter == null) {
|
||||||
migAdapter = SourceAdapter(this)
|
migAdapter = SourceAdapter(this)
|
||||||
}
|
}
|
||||||
@ -163,7 +161,7 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onButtonClick(position: Int) {
|
override fun onButtonClick(position: Int) {
|
||||||
val extension = (migAdapter?.getItem(position) as? ExtensionItem)?.extension ?: return
|
val extension = (extAdapter?.getItem(position) as? ExtensionItem)?.extension ?: return
|
||||||
when (extension) {
|
when (extension) {
|
||||||
is Extension.Installed -> {
|
is Extension.Installed -> {
|
||||||
if (!extension.hasUpdate) {
|
if (!extension.hasUpdate) {
|
||||||
@ -185,7 +183,7 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||||||
when (binding.tabs.selectedTabPosition) {
|
when (binding.tabs.selectedTabPosition) {
|
||||||
0 -> {
|
0 -> {
|
||||||
val extension =
|
val extension =
|
||||||
(adapter?.getItem(position) as? ExtensionItem)?.extension ?: return false
|
(extAdapter?.getItem(position) as? ExtensionItem)?.extension ?: return false
|
||||||
if (extension is Extension.Installed) {
|
if (extension is Extension.Installed) {
|
||||||
openDetails(extension)
|
openDetails(extension)
|
||||||
} else if (extension is Extension.Untrusted) {
|
} else if (extension is Extension.Untrusted) {
|
||||||
@ -211,7 +209,7 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||||||
|
|
||||||
override fun onItemLongClick(position: Int) {
|
override fun onItemLongClick(position: Int) {
|
||||||
if (binding.tabs.selectedTabPosition == 0) {
|
if (binding.tabs.selectedTabPosition == 0) {
|
||||||
val extension = (adapter?.getItem(position) as? ExtensionItem)?.extension ?: return
|
val extension = (extAdapter?.getItem(position) as? ExtensionItem)?.extension ?: return
|
||||||
if (extension is Extension.Installed || extension is Extension.Untrusted) {
|
if (extension is Extension.Installed || extension is Extension.Untrusted) {
|
||||||
uninstallExtension(extension.pkgName)
|
uninstallExtension(extension.pkgName)
|
||||||
}
|
}
|
||||||
@ -269,13 +267,13 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||||||
|
|
||||||
fun drawExtensions() {
|
fun drawExtensions() {
|
||||||
if (controller.extQuery.isNotBlank()) {
|
if (controller.extQuery.isNotBlank()) {
|
||||||
adapter?.updateDataSet(
|
extAdapter?.updateDataSet(
|
||||||
extensions.filter {
|
extensions.filter {
|
||||||
it.extension.name.contains(controller.extQuery, ignoreCase = true)
|
it.extension.name.contains(controller.extQuery, ignoreCase = true)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
adapter?.updateDataSet(extensions)
|
extAdapter?.updateDataSet(extensions)
|
||||||
}
|
}
|
||||||
updateExtTitle()
|
updateExtTitle()
|
||||||
}
|
}
|
||||||
@ -289,7 +287,7 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun downloadUpdate(item: ExtensionItem) {
|
fun downloadUpdate(item: ExtensionItem) {
|
||||||
adapter?.updateItem(item, item.installStep)
|
extAdapter?.updateItem(item, item.installStep)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun trustSignature(signatureHash: String) {
|
override fun trustSignature(signatureHash: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user