mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Merge pull request #3639 from Bnyro/master
Fix various crashes caused by view bindings
This commit is contained in:
commit
d7a8d9be71
@ -118,14 +118,16 @@ class ChannelFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
binding.channelRefresh.isRefreshing = false
|
||||
_binding?.channelRefresh?.isRefreshing = false
|
||||
Log.e(TAG(), "IOException, you might not have internet connection")
|
||||
return@repeatOnLifecycle
|
||||
} catch (e: HttpException) {
|
||||
binding.channelRefresh.isRefreshing = false
|
||||
_binding?.channelRefresh?.isRefreshing = false
|
||||
Log.e(TAG(), "HttpException, unexpected response")
|
||||
return@repeatOnLifecycle
|
||||
}
|
||||
val binding = _binding ?: return@repeatOnLifecycle
|
||||
|
||||
// needed if the channel gets loaded by the ID
|
||||
channelId = response.id
|
||||
channelName = response.name
|
||||
@ -240,6 +242,7 @@ class ChannelFragment : Fragment() {
|
||||
} catch (e: Exception) {
|
||||
return@launch
|
||||
}
|
||||
val binding = _binding ?: return@launch
|
||||
|
||||
val adapter = SearchAdapter()
|
||||
binding.channelRecView.adapter = adapter
|
||||
@ -268,14 +271,16 @@ class ChannelFragment : Fragment() {
|
||||
RetrofitInstance.api.getChannelNextPage(channelId!!, nextPage!!)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
binding.channelRefresh.isRefreshing = false
|
||||
_binding?.channelRefresh?.isRefreshing = false
|
||||
Log.e(TAG(), "IOException, you might not have internet connection")
|
||||
return@repeatOnLifecycle
|
||||
} catch (e: HttpException) {
|
||||
binding.channelRefresh.isRefreshing = false
|
||||
_binding?.channelRefresh?.isRefreshing = false
|
||||
Log.e(TAG(), "HttpException, unexpected response," + e.response())
|
||||
return@repeatOnLifecycle
|
||||
}
|
||||
val binding = _binding ?: return@repeatOnLifecycle
|
||||
|
||||
nextPage = response.nextpage
|
||||
channelAdapter?.insertItems(response.relatedStreams)
|
||||
isLoading = false
|
||||
|
@ -125,7 +125,7 @@ class LibraryFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun fetchPlaylists() {
|
||||
binding.playlistRefresh.isRefreshing = true
|
||||
_binding?.playlistRefresh?.isRefreshing = true
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||
var playlists = try {
|
||||
|
@ -110,6 +110,10 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSource
|
||||
import com.google.android.exoplayer2.util.MimeTypes
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@ -118,10 +122,6 @@ import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
|
||||
class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
private var _binding: FragmentPlayerBinding? = null
|
||||
|
@ -121,6 +121,8 @@ class PlaylistFragment : Fragment() {
|
||||
Log.e(TAG(), e.toString())
|
||||
return@repeatOnLifecycle
|
||||
}
|
||||
val binding = _binding ?: return@repeatOnLifecycle
|
||||
|
||||
playlistFeed = response.relatedStreams.toMutableList()
|
||||
binding.playlistScrollview.visibility = View.VISIBLE
|
||||
nextPage = response.nextpage
|
||||
|
@ -104,6 +104,8 @@ class SearchResultFragment : Fragment() {
|
||||
Log.e(TAG(), "HttpException, unexpected response")
|
||||
return@repeatOnLifecycle
|
||||
}
|
||||
|
||||
val binding = _binding ?: return@repeatOnLifecycle
|
||||
searchAdapter = SearchAdapter()
|
||||
binding.searchRecycler.adapter = searchAdapter
|
||||
searchAdapter.submitList(response.items)
|
||||
|
Loading…
Reference in New Issue
Block a user