mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
channel subs
This commit is contained in:
parent
5df2d0683f
commit
d575320ed3
@ -102,7 +102,7 @@ class ChannelFragment : Fragment() {
|
|||||||
val response = try {
|
val response = try {
|
||||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||||
RetrofitInstance.api.isSubscribed(channel_id!!,sharedPref?.getString("token","")!!)
|
RetrofitInstance.api.isSubscribed(channel_id!!,sharedPref?.getString("token","")!!)
|
||||||
}catch(e: IOException) {
|
} catch(e: IOException) {
|
||||||
println(e)
|
println(e)
|
||||||
Log.e(TAG, "IOException, you might not have internet connection")
|
Log.e(TAG, "IOException, you might not have internet connection")
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
@ -110,37 +110,20 @@ class ChannelFragment : Fragment() {
|
|||||||
Log.e(TAG, "HttpException, unexpected response")
|
Log.e(TAG, "HttpException, unexpected response")
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
}
|
}
|
||||||
val colorPrimary = TypedValue()
|
|
||||||
(context as Activity).theme.resolveAttribute(
|
|
||||||
android.R.attr.colorPrimary,
|
|
||||||
colorPrimary,
|
|
||||||
true)
|
|
||||||
|
|
||||||
val colorText = TypedValue()
|
|
||||||
(context as Activity).theme.resolveAttribute(
|
|
||||||
R.attr.colorOnSurface,
|
|
||||||
colorText,
|
|
||||||
true)
|
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (response.subscribed==true){
|
if (response.subscribed==true){
|
||||||
isSubscribed=true
|
isSubscribed=true
|
||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(colorText.data)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(response.subscribed!=null){
|
if(response.subscribed!=null){
|
||||||
button.setOnClickListener {
|
button.setOnClickListener {
|
||||||
if(isSubscribed){
|
if(isSubscribed){
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
button.text=getString(R.string.subscribe)
|
button.text=getString(R.string.subscribe)
|
||||||
button.setTextColor(colorPrimary.data)
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
subscribe()
|
subscribe()
|
||||||
button.text=getString(R.string.unsubscribe)
|
button.text=getString(R.string.unsubscribe)
|
||||||
button.setTextColor(colorText.data)
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -208,7 +191,7 @@ class ChannelFragment : Fragment() {
|
|||||||
refreshLayout?.isRefreshing = false;
|
refreshLayout?.isRefreshing = false;
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
view.findViewById<ScrollView>(R.id.channel_scrollView).visibility = View.VISIBLE
|
view.findViewById<ScrollView>(R.id.channel_scrollView).visibility = View.VISIBLE
|
||||||
view.findViewById<TextView>(R.id.channel_name).text = if (response.name?.length!! > 19) response.name.toString().substring(0,16) + "..." else response.name
|
view.findViewById<TextView>(R.id.channel_name).text = if (response.name?.length!! > 17) response.name.toString().substring(0,15) + "..." else response.name
|
||||||
val channelVerified = view.findViewById<ImageView>(R.id.channel_verified)
|
val channelVerified = view.findViewById<ImageView>(R.id.channel_verified)
|
||||||
if (response.verified) channelVerified.visibility = View.VISIBLE
|
if (response.verified) channelVerified.visibility = View.VISIBLE
|
||||||
view.findViewById<TextView>(R.id.channel_subs).text=resources.getString(R.string.subscribers, response.subscriberCount.formatShort())
|
view.findViewById<TextView>(R.id.channel_subs).text=resources.getString(R.string.subscribers, response.subscriberCount.formatShort())
|
||||||
|
@ -83,9 +83,12 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:text="@string/subscribe"
|
android:text="@string/subscribe"
|
||||||
android:textColor="?attr/colorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:drawableLeft="@drawable/ic_bell"
|
||||||
|
android:drawableTint="?android:attr/textColorPrimary"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
/>
|
/>
|
||||||
</Transition>
|
</Transition>
|
||||||
|
|
||||||
<ConstraintSet android:id="@+id/start">
|
<ConstraintSet>
|
||||||
<Constraint
|
<Constraint
|
||||||
android:id="@+id/player"
|
android:id="@+id/player"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user