mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
subscribe button
This commit is contained in:
parent
3cd3d90062
commit
922853d2b6
@ -12,6 +12,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@ -57,8 +58,11 @@ class ChannelFragment : Fragment() {
|
|||||||
val recyclerView = view.findViewById<RecyclerView>(R.id.channel_recView)
|
val recyclerView = view.findViewById<RecyclerView>(R.id.channel_recView)
|
||||||
recyclerView.layoutManager = LinearLayoutManager(context)
|
recyclerView.layoutManager = LinearLayoutManager(context)
|
||||||
fetchChannel(view)
|
fetchChannel(view)
|
||||||
|
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||||
|
if(sharedPref?.getString("token","")!=""){
|
||||||
val subButton = view.findViewById<MaterialButton>(R.id.channel_subscribe)
|
val subButton = view.findViewById<MaterialButton>(R.id.channel_subscribe)
|
||||||
isSubscribed(subButton)
|
isSubscribed(subButton)
|
||||||
|
}
|
||||||
val scrollView = view.findViewById<ScrollView>(R.id.channel_scrollView)
|
val scrollView = view.findViewById<ScrollView>(R.id.channel_scrollView)
|
||||||
scrollView.viewTreeObserver
|
scrollView.viewTreeObserver
|
||||||
.addOnScrollChangedListener {
|
.addOnScrollChangedListener {
|
||||||
@ -97,6 +101,7 @@ class ChannelFragment : Fragment() {
|
|||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(R.attr.colorPrimaryDark)
|
button.setTextColor(R.attr.colorPrimaryDark)
|
||||||
}
|
}
|
||||||
|
if(response.subscribed!=null){
|
||||||
button.setOnClickListener {
|
button.setOnClickListener {
|
||||||
if(isSubscribed){
|
if(isSubscribed){
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
@ -108,7 +113,7 @@ class ChannelFragment : Fragment() {
|
|||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(R.attr.colorPrimaryDark)
|
button.setTextColor(R.attr.colorPrimaryDark)
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,11 +381,14 @@ class PlayerFragment : Fragment() {
|
|||||||
activity.findViewById<MotionLayout>(R.id.mainMotionLayout).transitionToEnd()
|
activity.findViewById<MotionLayout>(R.id.mainMotionLayout).transitionToEnd()
|
||||||
view.findViewById<MotionLayout>(R.id.playerMotionLayout).transitionToEnd()
|
view.findViewById<MotionLayout>(R.id.playerMotionLayout).transitionToEnd()
|
||||||
}
|
}
|
||||||
|
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||||
|
if(sharedPref?.getString("token","")!=""){
|
||||||
val channelId = response.uploaderUrl?.replace("/channel/","")
|
val channelId = response.uploaderUrl?.replace("/channel/","")
|
||||||
val subButton = view.findViewById<MaterialButton>(R.id.player_subscribe)
|
val subButton = view.findViewById<MaterialButton>(R.id.player_subscribe)
|
||||||
isSubscribed(subButton, channelId!!)
|
isSubscribed(subButton, channelId!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
run()
|
run()
|
||||||
@ -413,6 +416,7 @@ class PlayerFragment : Fragment() {
|
|||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(R.attr.colorPrimaryDark)
|
button.setTextColor(R.attr.colorPrimaryDark)
|
||||||
}
|
}
|
||||||
|
if(response.subscribed!=null){
|
||||||
button.setOnClickListener {
|
button.setOnClickListener {
|
||||||
if(isSubscribed){
|
if(isSubscribed){
|
||||||
unsubscribe(channel_id)
|
unsubscribe(channel_id)
|
||||||
@ -424,7 +428,7 @@ class PlayerFragment : Fragment() {
|
|||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(R.attr.colorPrimaryDark)
|
button.setTextColor(R.attr.colorPrimaryDark)
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:background="@android:color/transparent"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:text="@string/subscribe"
|
android:text="@string/subscribe"
|
||||||
android:textColor="@color/colorPrimary" />
|
android:textColor="@color/colorPrimary" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user