mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 11:02:35 +01:00
Remove not required use of supplier
from code review
This commit is contained in:
parent
1228ce277f
commit
de4b5a8f0f
@ -65,7 +65,6 @@ import org.schabi.newpipe.util.external_communication.ShareUtils
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.function.Supplier
|
|
||||||
|
|
||||||
class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
private var _binding: FragmentSubscriptionBinding? = null
|
private var _binding: FragmentSubscriptionBinding? = null
|
||||||
@ -89,6 +88,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
|||||||
@State
|
@State
|
||||||
@JvmField
|
@JvmField
|
||||||
var itemsListState: Parcelable? = null
|
var itemsListState: Parcelable? = null
|
||||||
|
|
||||||
@State
|
@State
|
||||||
@JvmField
|
@JvmField
|
||||||
var feedGroupsListState: Parcelable? = null
|
var feedGroupsListState: Parcelable? = null
|
||||||
@ -143,7 +143,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
|||||||
// -- Import --
|
// -- Import --
|
||||||
val importSubMenu = menu.addSubMenu(R.string.import_from)
|
val importSubMenu = menu.addSubMenu(R.string.import_from)
|
||||||
|
|
||||||
addMenuItem(importSubMenu, R.string.previous_export) { onImportPreviousSelected() }
|
addMenuItemToSubmenu(importSubMenu, R.string.previous_export) { onImportPreviousSelected() }
|
||||||
.setIcon(R.drawable.ic_backup)
|
.setIcon(R.drawable.ic_backup)
|
||||||
|
|
||||||
val services = requireContext().resources.getStringArray(R.array.service_list)
|
val services = requireContext().resources.getStringArray(R.array.service_list)
|
||||||
@ -156,7 +156,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
|||||||
val supportedSources = subscriptionExtractor.supportedSources
|
val supportedSources = subscriptionExtractor.supportedSources
|
||||||
if (supportedSources.isEmpty()) continue
|
if (supportedSources.isEmpty()) continue
|
||||||
|
|
||||||
addMenuItem(importSubMenu, serviceName) {
|
addMenuItemToSubmenu(importSubMenu, serviceName) {
|
||||||
onImportFromServiceSelected(service.serviceId)
|
onImportFromServiceSelected(service.serviceId)
|
||||||
}
|
}
|
||||||
.setIcon(ServiceHelper.getIcon(service.serviceId))
|
.setIcon(ServiceHelper.getIcon(service.serviceId))
|
||||||
@ -171,38 +171,35 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
|||||||
// -- Export --
|
// -- Export --
|
||||||
val exportSubMenu = menu.addSubMenu(R.string.export_to)
|
val exportSubMenu = menu.addSubMenu(R.string.export_to)
|
||||||
|
|
||||||
addMenuItem(exportSubMenu, R.string.file) { onExportSelected() }
|
addMenuItemToSubmenu(exportSubMenu, R.string.file) { onExportSelected() }
|
||||||
.setIcon(R.drawable.ic_save)
|
.setIcon(R.drawable.ic_save)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addMenuItem(
|
private fun addMenuItemToSubmenu(
|
||||||
subMenu: SubMenu,
|
subMenu: SubMenu,
|
||||||
@StringRes title: Int,
|
@StringRes title: Int,
|
||||||
onClick: Runnable
|
onClick: Runnable
|
||||||
): MenuItem {
|
): MenuItem {
|
||||||
return addMenuItem({ subMenu.add(title) }, onClick)
|
return setClickListenerToMenuItem(subMenu.add(title), onClick)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addMenuItem(
|
private fun addMenuItemToSubmenu(
|
||||||
subMenu: SubMenu,
|
subMenu: SubMenu,
|
||||||
title: String,
|
title: String,
|
||||||
onClick: Runnable
|
onClick: Runnable
|
||||||
): MenuItem {
|
): MenuItem {
|
||||||
return addMenuItem({ subMenu.add(title) }, onClick)
|
return setClickListenerToMenuItem(subMenu.add(title), onClick)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addMenuItem(
|
private fun setClickListenerToMenuItem(
|
||||||
menuItemSupplier: Supplier<MenuItem>,
|
menuItem: MenuItem,
|
||||||
onClick: Runnable
|
onClick: Runnable
|
||||||
): MenuItem {
|
): MenuItem {
|
||||||
val item = menuItemSupplier.get()
|
menuItem.setOnMenuItemClickListener { _ ->
|
||||||
|
|
||||||
item.setOnMenuItemClickListener { _ ->
|
|
||||||
onClick.run()
|
onClick.run()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
return menuItem
|
||||||
return item
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onImportFromServiceSelected(serviceId: Int) {
|
private fun onImportFromServiceSelected(serviceId: Int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user