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