mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
fix crash when opening /user/ link
This commit is contained in:
parent
f8dabbda4e
commit
32b5ae7094
@ -325,7 +325,7 @@ class MainActivity : BaseActivity() {
|
|||||||
intent?.getStringExtra(IntentData.channelName) != null -> navController.navigate(
|
intent?.getStringExtra(IntentData.channelName) != null -> navController.navigate(
|
||||||
R.id.channelFragment,
|
R.id.channelFragment,
|
||||||
bundleOf(
|
bundleOf(
|
||||||
IntentData.channelId to intent?.getStringExtra(IntentData.channelName)
|
IntentData.channelName to intent?.getStringExtra(IntentData.channelName)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
intent?.getStringExtra(IntentData.playlistId) != null -> navController.navigate(
|
intent?.getStringExtra(IntentData.playlistId) != null -> navController.navigate(
|
||||||
|
@ -39,6 +39,7 @@ class ChannelFragment : BaseFragment() {
|
|||||||
channelName = it.getString(IntentData.channelName)
|
channelName = it.getString(IntentData.channelName)
|
||||||
?.replace("/c/", "")
|
?.replace("/c/", "")
|
||||||
?.replace("/user/", "")
|
?.replace("/user/", "")
|
||||||
|
Log.e(TAG(), channelName.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +61,6 @@ class ChannelFragment : BaseFragment() {
|
|||||||
val refreshChannel = {
|
val refreshChannel = {
|
||||||
binding.channelRefresh.isRefreshing = true
|
binding.channelRefresh.isRefreshing = true
|
||||||
fetchChannel()
|
fetchChannel()
|
||||||
isSubscribed()
|
|
||||||
}
|
}
|
||||||
refreshChannel()
|
refreshChannel()
|
||||||
binding.channelRefresh.setOnRefreshListener {
|
binding.channelRefresh.setOnRefreshListener {
|
||||||
@ -82,31 +82,6 @@ class ChannelFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isSubscribed() {
|
|
||||||
lifecycleScope.launchWhenCreated {
|
|
||||||
isSubscribed = SubscriptionHelper.isSubscribed(channelId!!)
|
|
||||||
if (isSubscribed == null) return@launchWhenCreated
|
|
||||||
|
|
||||||
runOnUiThread {
|
|
||||||
if (isSubscribed == true) {
|
|
||||||
binding.channelSubscribe.text = getString(R.string.unsubscribe)
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.channelSubscribe.setOnClickListener {
|
|
||||||
binding.channelSubscribe.text = if (isSubscribed == true) {
|
|
||||||
SubscriptionHelper.unsubscribe(channelId!!)
|
|
||||||
isSubscribed = false
|
|
||||||
getString(R.string.subscribe)
|
|
||||||
} else {
|
|
||||||
SubscriptionHelper.subscribe(channelId!!)
|
|
||||||
isSubscribed = true
|
|
||||||
getString(R.string.unsubscribe)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun fetchChannel() {
|
private fun fetchChannel() {
|
||||||
fun run() {
|
fun run() {
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
@ -126,9 +101,35 @@ class ChannelFragment : BaseFragment() {
|
|||||||
Log.e(TAG(), "HttpException, unexpected response")
|
Log.e(TAG(), "HttpException, unexpected response")
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
}
|
}
|
||||||
|
// needed if the channel gets loaded by the ID
|
||||||
|
channelId = response.id
|
||||||
|
|
||||||
|
// fetch and update the subscription status
|
||||||
|
isSubscribed = SubscriptionHelper.isSubscribed(channelId!!)
|
||||||
|
if (isSubscribed == null) return@launchWhenCreated
|
||||||
|
|
||||||
|
runOnUiThread {
|
||||||
|
if (isSubscribed == true) {
|
||||||
|
binding.channelSubscribe.text = getString(R.string.unsubscribe)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.channelSubscribe.setOnClickListener {
|
||||||
|
binding.channelSubscribe.text = if (isSubscribed == true) {
|
||||||
|
SubscriptionHelper.unsubscribe(channelId!!)
|
||||||
|
isSubscribed = false
|
||||||
|
getString(R.string.subscribe)
|
||||||
|
} else {
|
||||||
|
SubscriptionHelper.subscribe(channelId!!)
|
||||||
|
isSubscribed = true
|
||||||
|
getString(R.string.unsubscribe)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nextPage = response.nextpage
|
nextPage = response.nextpage
|
||||||
isLoading = false
|
isLoading = false
|
||||||
binding.channelRefresh.isRefreshing = false
|
binding.channelRefresh.isRefreshing = false
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
binding.channelScrollView.visibility = View.VISIBLE
|
binding.channelScrollView.visibility = View.VISIBLE
|
||||||
binding.channelName.text = response.name
|
binding.channelName.text = response.name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user