mirror of
https://github.com/NiciDieNase/chaosflix
synced 2025-02-17 05:28:24 +00:00
formatting
This commit is contained in:
parent
08550608f7
commit
2c5c6c5111
10 changed files with 17 additions and 25 deletions
|
@ -30,14 +30,14 @@ import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
|
|||
import de.nicidienase.chaosflix.common.util.ConferenceUtil
|
||||
import de.nicidienase.chaosflix.common.util.LiveEvent
|
||||
import de.nicidienase.chaosflix.common.util.SingleLiveEvent
|
||||
import java.io.IOException
|
||||
import javax.net.ssl.SSLHandshakeException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import retrofit2.Response
|
||||
import java.io.IOException
|
||||
import javax.net.ssl.SSLHandshakeException
|
||||
|
||||
class MediaRepository(
|
||||
private val recordingApi: RecordingApi,
|
||||
|
@ -440,7 +440,7 @@ class MediaRepository(
|
|||
return@withContext if (eventsResponse.isSuccessful) {
|
||||
val total = eventsResponse.headers()["total"]?.toInt() ?: 0
|
||||
val links = parseLink(eventsResponse.headers()["link"])
|
||||
val events = eventsResponse.body()?.events?.map {databaseOperations.saveEvent(it) } ?: emptyList()
|
||||
val events = eventsResponse.body()?.events?.map { databaseOperations.saveEvent(it) } ?: emptyList()
|
||||
|
||||
SearchResponse(events, total, links)
|
||||
} else {
|
||||
|
|
|
@ -146,7 +146,7 @@ class BrowseViewModel(
|
|||
).build()
|
||||
}
|
||||
|
||||
fun clearCache() = viewModelScope.launch (Dispatchers.IO){
|
||||
fun clearCache() = viewModelScope.launch(Dispatchers.IO) {
|
||||
mediaRepository.deleteNonUserData()
|
||||
}
|
||||
|
||||
|
|
|
@ -18,17 +18,17 @@ import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEvent
|
|||
import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
|
||||
import de.nicidienase.chaosflix.common.util.LiveEvent
|
||||
import de.nicidienase.chaosflix.common.util.SingleLiveEvent
|
||||
import java.io.File
|
||||
import java.util.ArrayList
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.util.ArrayList
|
||||
|
||||
class DetailsViewModel(
|
||||
private val database: ChaosflixDatabase,
|
||||
private val offlineItemManager: OfflineItemManager,
|
||||
private val preferencesManager: ChaosflixPreferenceManager,
|
||||
private val mediaRepository: MediaRepository
|
||||
private val database: ChaosflixDatabase,
|
||||
private val offlineItemManager: OfflineItemManager,
|
||||
private val preferencesManager: ChaosflixPreferenceManager,
|
||||
private val mediaRepository: MediaRepository
|
||||
) : ViewModel() {
|
||||
|
||||
private var eventId = MutableLiveData<Long>(0)
|
||||
|
@ -58,7 +58,7 @@ class DetailsViewModel(
|
|||
}
|
||||
|
||||
private fun setEventId(eventId: Long?): LiveData<Event?> {
|
||||
if(eventId != null){
|
||||
if (eventId != null) {
|
||||
this.eventId.postValue(eventId)
|
||||
viewModelScope.launch {
|
||||
val findEventByIdSync = database.eventDao().findEventByIdSync(eventId)
|
||||
|
@ -143,7 +143,6 @@ class DetailsViewModel(
|
|||
state.postValue(LiveEvent(State.DisplayEvent, data = bundle))
|
||||
}
|
||||
|
||||
|
||||
fun playEvent(autoselect: Boolean = autoselectRecording) = viewModelScope.launch(Dispatchers.IO) {
|
||||
val offlineItem = getOfflineItem()
|
||||
when {
|
||||
|
@ -167,7 +166,7 @@ class DetailsViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun letUserSelectRecording() = withContext(Dispatchers.IO){
|
||||
private suspend fun letUserSelectRecording() = withContext(Dispatchers.IO) {
|
||||
// select quality then playEvent
|
||||
val recordingList = database.recordingDao().findRecordingByEventSync(eventId.value!!)
|
||||
.partition { it.mimeType.startsWith("audio") || it.mimeType.startsWith("video") }
|
||||
|
@ -303,4 +302,3 @@ class DetailsViewModel(
|
|||
const val PROGRESS = "progress"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ fun setDuration(textView: TextView, duration: Long) {
|
|||
|
||||
@BindingAdapter("progress")
|
||||
fun ProgressBar.eventProgress(event: Event?) {
|
||||
if(event != null){
|
||||
if (event != null) {
|
||||
val progress = event.progress
|
||||
if (progress > 0) {
|
||||
this.visibility = View.VISIBLE
|
||||
|
|
|
@ -61,7 +61,6 @@ class ConferencesTabBrowseFragment : Fragment(), SearchView.OnQueryTextListener
|
|||
binding.search.setOnClickListener {
|
||||
requireActivity().onSearchRequested()
|
||||
binding.search.hide()
|
||||
|
||||
}
|
||||
viewModel.getConferenceGroups().observe(viewLifecycleOwner, Observer<List<ConferenceGroup>> { conferenceGroups ->
|
||||
val fragmentPager = ConferenceGroupsFragmentPager(requireContext(), childFragmentManager)
|
||||
|
|
|
@ -10,15 +10,14 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event
|
||||
import de.nicidienase.chaosflix.touch.databinding.ItemEventCardviewBinding
|
||||
|
||||
open class EventRecyclerViewAdapter(val listener: (Event) -> Unit): ListAdapter<Event, EventRecyclerViewAdapter.ViewHolder>(EventDiffUtil) {
|
||||
object EventDiffUtil: DiffUtil.ItemCallback<Event>() {
|
||||
open class EventRecyclerViewAdapter(val listener: (Event) -> Unit) : ListAdapter<Event, EventRecyclerViewAdapter.ViewHolder>(EventDiffUtil) {
|
||||
object EventDiffUtil : DiffUtil.ItemCallback<Event>() {
|
||||
override fun areItemsTheSame(oldItem: Event, newItem: Event): Boolean = oldItem.guid == newItem.guid
|
||||
override fun areContentsTheSame(oldItem: Event, newItem: Event): Boolean = oldItem == newItem
|
||||
}
|
||||
|
||||
var showConferenceName: Boolean = false
|
||||
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return getItem(position).id
|
||||
}
|
||||
|
|
|
@ -119,8 +119,6 @@ class EventDetailsFragment : Fragment() {
|
|||
.load(event.thumbUrl)
|
||||
.apply(RequestOptions().fitCenter())
|
||||
.into(binding.thumbImage)
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
viewModel.getRelatedEvents().observe(viewLifecycleOwner, Observer {
|
||||
|
@ -139,7 +137,7 @@ class EventDetailsFragment : Fragment() {
|
|||
Log.d(TAG, "Update bookmark")
|
||||
val shouldInvalidate = this@EventDetailsFragment.watchlistItem == null || watchlistItem == null
|
||||
this@EventDetailsFragment.watchlistItem = watchlistItem
|
||||
if(shouldInvalidate){
|
||||
if (shouldInvalidate) {
|
||||
activity?.invalidateOptionsMenu()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -28,7 +28,6 @@ class PlayerActivity : AppCompatActivity() {
|
|||
val extras = intent.extras
|
||||
if (savedInstanceState == null && extras != null) {
|
||||
|
||||
|
||||
val ft = supportFragmentManager.beginTransaction()
|
||||
val playerFragment = ExoPlayerFragment.newInstance(args.playbackItem)
|
||||
ft.replace(R.id.fragment_container, playerFragment)
|
||||
|
|
|
@ -24,4 +24,3 @@ class SearchFragment : EventsListFragment() {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,4 +39,4 @@ class SearchResultAdapter(val listener: (Event) -> Unit) :
|
|||
}
|
||||
|
||||
inner class ViewHolder(val binding: ItemEventCardviewBinding) : androidx.recyclerview.widget.RecyclerView.ViewHolder(binding.root)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue