mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-26 22:20:24 +00:00
WIP
This commit is contained in:
parent
ada7d708aa
commit
e2b0887875
3 changed files with 38 additions and 23 deletions
|
@ -54,7 +54,7 @@ android {
|
|||
|
||||
dependencies {
|
||||
// implementation 'com.github.NiciDieNase:chaosflix-common:1.3.2'
|
||||
implementation 'de.nicidienase.chaosflix:common:2.0.1-SNAPSHOT'
|
||||
implementation 'de.nicidienase.chaosflix:common:2.0.0-SNAPSHOT'
|
||||
|
||||
implementation('com.mikepenz:aboutlibraries:6.1.1@aar') {
|
||||
transitive = true
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.arch.lifecycle.ViewModel
|
|||
import de.nicidienase.chaosflix.common.ChaosflixDatabase
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentEvent
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRecording
|
||||
import de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.PersistentRelatedEvent
|
||||
import de.nicidienase.chaosflix.common.mediadata.network.RecordingService
|
||||
import de.nicidienase.chaosflix.common.mediadata.sync.Downloader
|
||||
import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEvent
|
||||
|
@ -13,7 +14,6 @@ import de.nicidienase.chaosflix.common.userdata.entities.watchlist.WatchlistItem
|
|||
import de.nicidienase.chaosflix.common.util.ThreadHandler
|
||||
import de.nicidienase.chaosflix.touch.OfflineItemManager
|
||||
import java.io.File
|
||||
|
||||
class DetailsViewModel(
|
||||
val database: ChaosflixDatabase,
|
||||
recordingApi: RecordingService
|
||||
|
@ -88,7 +88,17 @@ class DetailsViewModel(
|
|||
return result
|
||||
}
|
||||
|
||||
fun getRelatedEvents(event: PersistentEvent): LiveData<List<PersistentEvent>>{
|
||||
val data = MutableLiveData<List<PersistentEvent>>()
|
||||
handler.runOnBackgroundThread {
|
||||
val guids = database.relatedEventDao().getRelatedEventsForEventSync(event.id).map { it.relatedEventGuid }
|
||||
data.postValue(database.eventDao().findEventsByGUIDsSync(guids))
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TAG = DetailsViewModel::class.simpleName
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ class EventDetailsFragment : Fragment() {
|
|||
|
||||
private var listener: OnEventDetailsFragmentInteractionListener? = null
|
||||
|
||||
private var eventId: Long = 0
|
||||
private var appBarExpanded: Boolean = false
|
||||
private lateinit var event: PersistentEvent
|
||||
private var watchlistItem: WatchlistItem? = null
|
||||
|
@ -102,26 +101,32 @@ class EventDetailsFragment : Fragment() {
|
|||
ViewModelFactory(requireContext()))
|
||||
.get(DetailsViewModel::class.java)
|
||||
|
||||
viewModel.setEvent(eventId)
|
||||
viewModel.setEvent(event)
|
||||
.observe(this, Observer {
|
||||
Log.d(TAG,"Loading Event ${event.title}, ${event.guid}")
|
||||
updateBookmark(event.guid)
|
||||
binding.thumbImage.transitionName = getString(R.string.thumbnail) + event.guid
|
||||
Picasso.with(context)
|
||||
.load(event.thumbUrl)
|
||||
.noFade()
|
||||
.into(binding.thumbImage, object : Callback {
|
||||
override fun onSuccess() {
|
||||
// startPostponedEnterTransition()
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
// startPostponedEnterTransition()
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
viewModel.getRelatedEvents(event).observe(this, Observer {
|
||||
|
||||
})
|
||||
|
||||
.observe(this, Observer { event: PersistentEvent? ->
|
||||
if (event != null) {
|
||||
Log.d(TAG,"Loading Event ${event.title}, ${event.guid}")
|
||||
this.event = event
|
||||
updateBookmark()
|
||||
binding.event = event
|
||||
binding.thumbImage.transitionName = getString(R.string.thumbnail) + event.guid
|
||||
Picasso.with(context)
|
||||
.load(event.thumbUrl)
|
||||
.noFade()
|
||||
.into(binding.thumbImage, object : Callback {
|
||||
override fun onSuccess() {
|
||||
// startPostponedEnterTransition()
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
// startPostponedEnterTransition()
|
||||
}
|
||||
})
|
||||
|
||||
val relatedGuids = event.related?.map { it.relatedEventGuid }
|
||||
// val relatedIds: LongArray = event.metadata?.related?.keys?.toLongArray() ?: longArrayOf()
|
||||
|
@ -134,8 +139,8 @@ class EventDetailsFragment : Fragment() {
|
|||
})
|
||||
}
|
||||
|
||||
private fun updateBookmark() {
|
||||
viewModel.getBookmarkForEvent(event.guid)
|
||||
private fun updateBookmark(guid: String) {
|
||||
viewModel.getBookmarkForEvent(guid)
|
||||
.observe(this, Observer { watchlistItem: WatchlistItem? ->
|
||||
this.watchlistItem = watchlistItem
|
||||
listener?.invalidateOptionsMenu()
|
||||
|
|
Loading…
Reference in a new issue