Skip to content

Commit

Permalink
clean up ExtensionDetailsController
Browse files Browse the repository at this point in the history
  • Loading branch information
az4521 committed Mar 10, 2024
1 parent a9c66c0 commit f0c8dba
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
*/
private var adapter: ExtensionDetailsPrefsButtonAdapter? = null

private var sources: List<ConfigurableSource>? = null
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
binding = ExtensionDetailControllerBinding.inflate(inflater)
return binding.root
Expand Down Expand Up @@ -82,21 +83,21 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
binding.extensionDetailsRecycler.adapter = adapter
binding.extensionDetailsRecycler.setHasFixedSize(true)

sources = presenter.extension?.sources?.filterIsInstance<ConfigurableSource>()

adapter!!.updateDataSet(
presenter.extension?.sources?.filterIsInstance<ConfigurableSource>()
?.map { ExtensionDetailsPrefsButtonItem(it.toString()) }
sources?.map { ExtensionDetailsPrefsButtonItem(it.toString()) }
)
}

/*presenter.extension?.sources?.filterIsInstance<ConfigurableSource>()?.forEach { source ->
binding.extensionPrefs.visible()
binding.extensionPrefs.clicks()
.onEach { openPreferences(source.id) }
.launchIn(scope)
}*/
override fun onDestroyView(view: View) {
adapter = null
sources = null
super.onDestroyView(view)
}

override fun onItemClick(view: View?, position: Int): Boolean {
val id = presenter.extension?.sources?.filterIsInstance<ConfigurableSource>()?.get(position)?.id
val id = sources?.get(position)?.id
return if (id != null) {
openPreferences(id)
true
Expand Down

0 comments on commit f0c8dba

Please sign in to comment.