1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2026-04-18 21:01:23 +00:00

Stick info header when selecting subscriptions in the feed group dialog

- Avoid creating plural translation by using a different wording
This commit is contained in:
Mauricio Colli
2020-01-29 23:23:10 -03:00
parent 3f32573638
commit 2c783ff911
4 changed files with 55 additions and 65 deletions

View File

@@ -29,7 +29,6 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity
import org.schabi.newpipe.local.subscription.FeedGroupIcon
import org.schabi.newpipe.local.subscription.dialog.FeedGroupDialogViewModel.FeedDialogEvent
import org.schabi.newpipe.local.subscription.item.EmptyPlaceholderItem
import org.schabi.newpipe.local.subscription.item.HeaderTextSideItem
import org.schabi.newpipe.local.subscription.item.PickerIconItem
import org.schabi.newpipe.local.subscription.item.PickerSubscriptionItem
import org.schabi.newpipe.util.AnimationUtils.animateView
@@ -82,7 +81,7 @@ class FeedGroupDialog : DialogFragment() {
super.onSaveInstanceState(outState)
iconsListState = icon_selector.layoutManager?.onSaveInstanceState()
subscriptionsListState = subscriptions_selector.layoutManager?.onSaveInstanceState()
subscriptionsListState = subscriptions_selector_list.layoutManager?.onSaveInstanceState()
Icepick.saveInstanceState(this, outState)
}
@@ -185,9 +184,7 @@ class FeedGroupDialog : DialogFragment() {
val selectedCountText = getString(R.string.feed_group_dialog_selection_count, this.selectedSubscriptions.size)
selected_subscription_count_view.text = selectedCountText
val headerInfoItem = HeaderTextSideItem(getString(R.string.tab_subscriptions), selectedCountText)
groupAdapter.add(headerInfoItem)
subscriptions_selector_header_info.text = selectedCountText
Section().apply {
addAll(subscriptions.map {
@@ -199,16 +196,11 @@ class FeedGroupDialog : DialogFragment() {
groupAdapter.add(this)
}
subscriptions_selector.apply {
if (useGridLayout) {
layoutManager = GridLayoutManager(requireContext(), groupAdapter.spanCount, RecyclerView.VERTICAL, false).apply {
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int) =
if (position == 0) 4 else 1
}
}
subscriptions_selector_list.apply {
layoutManager = if (useGridLayout) {
GridLayoutManager(requireContext(), groupAdapter.spanCount, RecyclerView.VERTICAL, false)
} else {
layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)
LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)
}
adapter = groupAdapter
@@ -237,14 +229,13 @@ class FeedGroupDialog : DialogFragment() {
val updateSelectedCountText = getString(R.string.feed_group_dialog_selection_count, this.selectedSubscriptions.size)
selected_subscription_count_view.text = updateSelectedCountText
headerInfoItem.infoText = updateSelectedCountText
headerInfoItem.notifyChanged(HeaderTextSideItem.UPDATE_INFO)
subscriptions_selector_header_info.text = updateSelectedCountText
}
}
}
select_channel_button.setOnClickListener {
subscriptions_selector.scrollToPosition(0)
subscriptions_selector_list.scrollToPosition(0)
showSubscriptionsPicker()
}
}

View File

@@ -1,37 +0,0 @@
package org.schabi.newpipe.local.subscription.item
import android.view.View.OnClickListener
import com.xwray.groupie.kotlinandroidextensions.Item
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
import kotlinx.android.synthetic.main.header_with_text_item.*
import org.schabi.newpipe.R
class HeaderTextSideItem(
val title: String,
var infoText: String? = null,
private val onClickListener: (() -> Unit)? = null
) : Item() {
companion object {
const val UPDATE_INFO = 123
}
override fun getLayout(): Int = R.layout.header_with_text_item
override fun bind(viewHolder: GroupieViewHolder, position: Int, payloads: MutableList<Any>) {
if (payloads.contains(UPDATE_INFO)) {
viewHolder.header_info.text = infoText
return
}
super.bind(viewHolder, position, payloads)
}
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
viewHolder.header_title.text = title
viewHolder.header_info.text = infoText
val listener: OnClickListener? = if (onClickListener != null) OnClickListener { onClickListener.invoke() } else null
viewHolder.root.setOnClickListener(listener)
}
}