mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 07:13:00 +00:00 
			
		
		
		
	Bug: SubscriptionViewModel.kt did not map values for FeedGroupCardVerticalItem in line 26
This commit is contained in:
		| @@ -78,7 +78,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|     private val groupAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>() |     private val groupAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>() | ||||||
|     private val feedGroupsSection = Section() |     private val feedGroupsSection = Section() | ||||||
|     private var feedGroupsCarousel: FeedGroupCarouselItem? = null |     private var feedGroupsCarousel: FeedGroupCarouselItem? = null | ||||||
|     private var feedGroupsCarouselVertical: FeedGroupCarouselItem? = feedGroupsCarousel |  | ||||||
|     private lateinit var feedGroupsSortMenuItem: HeaderWithMenuItem |     private lateinit var feedGroupsSortMenuItem: HeaderWithMenuItem | ||||||
|     private val subscriptionsSection = Section() |     private val subscriptionsSection = Section() | ||||||
|  |  | ||||||
| @@ -125,7 +124,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|         super.onPause() |         super.onPause() | ||||||
|         itemsListState = binding.itemsList.layoutManager?.onSaveInstanceState() |         itemsListState = binding.itemsList.layoutManager?.onSaveInstanceState() | ||||||
|         feedGroupsListState = feedGroupsCarousel?.onSaveInstanceState() |         feedGroupsListState = feedGroupsCarousel?.onSaveInstanceState() | ||||||
|         feedGroupsListVerticalState = feedGroupsCarouselVertical?.onSaveInstanceState() |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onDestroy() { |     override fun onDestroy() { | ||||||
| @@ -275,6 +273,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter, RecyclerView.HORIZONTAL) |             feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter, RecyclerView.HORIZONTAL) | ||||||
|  |  | ||||||
|             feedGroupsSortMenuItem = HeaderWithMenuItem( |             feedGroupsSortMenuItem = HeaderWithMenuItem( | ||||||
|                 getString(R.string.feed_groups_header_title), |                 getString(R.string.feed_groups_header_title), | ||||||
|                 R.drawable.ic_list, |                 R.drawable.ic_list, | ||||||
| @@ -282,6 +281,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|                 listViewOnClickListener = ::changeLayout, |                 listViewOnClickListener = ::changeLayout, | ||||||
|                 menuItemOnClickListener = ::openReorderDialog |                 menuItemOnClickListener = ::openReorderDialog | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
|             add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel))) |             add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel))) | ||||||
|             groupAdapter.clear() |             groupAdapter.clear() | ||||||
|             groupAdapter.add(this) |             groupAdapter.add(this) | ||||||
| @@ -302,15 +302,16 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|  |  | ||||||
|     private fun changeLayout() { |     private fun changeLayout() { | ||||||
|         Section().apply { |         Section().apply { | ||||||
|             val carouselAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>() |             val carouselAdapter2 = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>() | ||||||
|  |  | ||||||
|             carouselAdapter.add(FeedGroupCardVerticalItem(-1, getString(R.string.all), FeedGroupIcon.RSS)) |             carouselAdapter2.add(FeedGroupCardVerticalItem(-1, getString(R.string.all), FeedGroupIcon.RSS)) | ||||||
|             carouselAdapter.add(feedGroupsSection) |             carouselAdapter2.add(feedGroupsSection) | ||||||
|             carouselAdapter.add(FeedGroupAddItem()) // change this button later |             carouselAdapter2.add(FeedGroupAddItem()) | ||||||
|             carouselAdapter.setOnItemClickListener { item, _ -> |  | ||||||
|  |             carouselAdapter2.setOnItemClickListener { item, _ -> | ||||||
|                 listenerFeedVerticalGroups.selected(item) |                 listenerFeedVerticalGroups.selected(item) | ||||||
|             } |             } | ||||||
|             carouselAdapter.setOnItemLongClickListener { item, _ -> |             carouselAdapter2.setOnItemLongClickListener { item, _ -> | ||||||
|                 if (item is FeedGroupCardVerticalItem) { |                 if (item is FeedGroupCardVerticalItem) { | ||||||
|                     if (item.groupId == FeedGroupEntity.GROUP_ALL_ID) { |                     if (item.groupId == FeedGroupEntity.GROUP_ALL_ID) { | ||||||
|                         return@setOnItemLongClickListener false |                         return@setOnItemLongClickListener false | ||||||
| @@ -319,8 +320,8 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|                 listenerFeedVerticalGroups.held(item) |                 listenerFeedVerticalGroups.held(item) | ||||||
|                 return@setOnItemLongClickListener true |                 return@setOnItemLongClickListener true | ||||||
|             } |             } | ||||||
|  |             feedGroupsCarousel = FeedGroupCarouselItem(requireContext(), carouselAdapter2, RecyclerView.VERTICAL) | ||||||
|  |  | ||||||
|             feedGroupsCarouselVertical = FeedGroupCarouselItem(requireContext(), carouselAdapter, RecyclerView.VERTICAL) |  | ||||||
|             feedGroupsSortMenuItem = HeaderWithMenuItem( |             feedGroupsSortMenuItem = HeaderWithMenuItem( | ||||||
|                 getString(R.string.feed_groups_header_title), |                 getString(R.string.feed_groups_header_title), | ||||||
|                 R.drawable.ic_apps, |                 R.drawable.ic_apps, | ||||||
| @@ -328,7 +329,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|                 listViewOnClickListener = ::setupInitialLayout, |                 listViewOnClickListener = ::setupInitialLayout, | ||||||
|                 menuItemOnClickListener = ::openReorderDialog |                 menuItemOnClickListener = ::openReorderDialog | ||||||
|             ) |             ) | ||||||
|             add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarouselVertical))) |             add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel))) | ||||||
|             groupAdapter.clear() |             groupAdapter.clear() | ||||||
|             groupAdapter.add(this) |             groupAdapter.add(this) | ||||||
|         } |         } | ||||||
| @@ -343,17 +344,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|                 listOf(subscriptionsSection) |                 listOf(subscriptionsSection) | ||||||
|             ) |             ) | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         // TODO: remove this |  | ||||||
|         groupAdapter.spanCount = if (shouldUseGridLayout(context)) getGridSpanCountChannels(context) else 1 |  | ||||||
|         binding.itemsList.layoutManager = GridLayoutManager(requireContext(), groupAdapter.spanCount).apply { |  | ||||||
|             spanSizeLookup = groupAdapter.spanSizeLookup |  | ||||||
|         } |  | ||||||
|         binding.itemsList.adapter = groupAdapter |  | ||||||
|  |  | ||||||
|         viewModel = ViewModelProvider(this).get(SubscriptionViewModel::class.java) |  | ||||||
|         viewModel.stateLiveData.observe(viewLifecycleOwner) { it?.let(this::handleResult) } |  | ||||||
|         viewModel.feedGroupsLiveData.observe(viewLifecycleOwner) { it?.let(this::handleFeedVerticalGroups) } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun initViews(rootView: View, savedInstanceState: Bundle?) { |     override fun initViews(rootView: View, savedInstanceState: Bundle?) { | ||||||
| @@ -366,6 +356,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|         } |         } | ||||||
|         binding.itemsList.adapter = groupAdapter |         binding.itemsList.adapter = groupAdapter | ||||||
|  |  | ||||||
|  |         //TODO: change viewModel or create another one | ||||||
|         viewModel = ViewModelProvider(this).get(SubscriptionViewModel::class.java) |         viewModel = ViewModelProvider(this).get(SubscriptionViewModel::class.java) | ||||||
|         viewModel.stateLiveData.observe(viewLifecycleOwner) { it?.let(this::handleResult) } |         viewModel.stateLiveData.observe(viewLifecycleOwner) { it?.let(this::handleResult) } | ||||||
|         viewModel.feedGroupsLiveData.observe(viewLifecycleOwner) { it?.let(this::handleFeedGroups) } |         viewModel.feedGroupsLiveData.observe(viewLifecycleOwner) { it?.let(this::handleFeedGroups) } | ||||||
| @@ -495,18 +486,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() { | |||||||
|         binding.itemsList.post { feedGroupsSortMenuItem.notifyChanged(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM) } |         binding.itemsList.post { feedGroupsSortMenuItem.notifyChanged(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM) } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun handleFeedVerticalGroups(groups: List<Group>) { |  | ||||||
|         feedGroupsSection.update(groups) |  | ||||||
|  |  | ||||||
|         if (feedGroupsListState != null) { |  | ||||||
|             feedGroupsCarouselVertical?.onRestoreInstanceState(feedGroupsListVerticalState) |  | ||||||
|             feedGroupsListVerticalState = null |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         feedGroupsSortMenuItem.showMenuItem = groups.size > 1 |  | ||||||
|         binding.itemsList.post { feedGroupsSortMenuItem.notifyChanged(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM) } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // ///////////////////////////////////////////////////////////////////////// |     // ///////////////////////////////////////////////////////////////////////// | ||||||
|     // Contract |     // Contract | ||||||
|     // ///////////////////////////////////////////////////////////////////////// |     // ///////////////////////////////////////////////////////////////////////// | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Samuel Wu
					Samuel Wu