mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
hide when not subscribed
This commit is contained in:
parent
861e319aeb
commit
d18e0dfc1f
@ -1,6 +1,7 @@
|
||||
package com.github.libretube.ui.adapters
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.R
|
||||
@ -30,7 +31,7 @@ class SubscriptionChannelAdapter(
|
||||
|
||||
override fun onBindViewHolder(holder: SubscriptionChannelViewHolder, position: Int) {
|
||||
val subscription = subscriptions[position]
|
||||
var subscribed = true
|
||||
var isSubscribed = true
|
||||
|
||||
holder.binding.apply {
|
||||
subscriptionChannelName.text = subscription.name
|
||||
@ -43,15 +44,17 @@ class SubscriptionChannelAdapter(
|
||||
}
|
||||
subscriptionSubscribe.setOnClickListener {
|
||||
val channelId = subscription.url!!.toID()
|
||||
if (subscribed) {
|
||||
if (isSubscribed) {
|
||||
SubscriptionHelper.handleUnsubscribe(root.context, channelId, subscription.name ?: "") {
|
||||
subscriptionSubscribe.text = root.context.getString(R.string.subscribe)
|
||||
subscribed = false
|
||||
notificationBell.visibility = View.GONE
|
||||
isSubscribed = false
|
||||
}
|
||||
} else {
|
||||
SubscriptionHelper.subscribe(channelId)
|
||||
subscriptionSubscribe.text = root.context.getString(R.string.unsubscribe)
|
||||
subscribed = true
|
||||
notificationBell.visibility = View.VISIBLE
|
||||
isSubscribed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,17 +130,20 @@ class ChannelFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
channelId?.let { binding.notificationBell.setupNotificationBell(it) }
|
||||
if (isSubscribed == false) binding.notificationBell.visibility = View.GONE
|
||||
|
||||
binding.channelSubscribe.setOnClickListener {
|
||||
if (isSubscribed == true) {
|
||||
SubscriptionHelper.handleUnsubscribe(requireContext(), channelId!!, channelName) {
|
||||
isSubscribed = false
|
||||
binding.channelSubscribe.text = getString(R.string.subscribe)
|
||||
binding.notificationBell.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
SubscriptionHelper.subscribe(channelId!!)
|
||||
isSubscribed = true
|
||||
binding.channelSubscribe.text = getString(R.string.unsubscribe)
|
||||
binding.notificationBell.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,14 +63,15 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:maxLines="1"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/ElevatedIconButton"
|
||||
android:id="@+id/channel_share"
|
||||
style="@style/ElevatedIconButton"
|
||||
app:icon="@drawable/ic_share"
|
||||
tools:targetApi="m" />
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user