Update event list item layout and include duration

This commit is contained in:
Felix 2019-04-26 18:07:16 +02:00
parent f42f2542ed
commit 55d7250df9
7 changed files with 92 additions and 59 deletions

View file

@ -9,10 +9,10 @@ data class EventDto(@SerializedName("conference_id")
var conferenceId: Long = 0,
var guid: String = "",
var title: String = "",
var subtitle: String? = "",
var subtitle: String?,
var slug: String = "",
var link: String? = "",
var description: String? = "",
var description: String?,
@SerializedName("original_language")
var originalLanguage: String = "",
var persons: Array<String>?,

View file

@ -89,8 +89,8 @@ data class Event(
constructor(event: EventDto, conferenceId: Long = 0) : this(
conferenceId = conferenceId,
guid = event.guid,
title = event.title,
subtitle = event.subtitle,
title = event.title.trim(),
subtitle = event.subtitle?.trim(),
slug = event.slug,
link = event.link,
description = event.description,

View file

@ -14,6 +14,8 @@ import de.nicidienase.chaosflix.common.mediadata.network.RecordingService
import de.nicidienase.chaosflix.common.mediadata.network.StreamingService
import de.nicidienase.chaosflix.common.mediadata.sync.Downloader
import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEvent
import de.nicidienase.chaosflix.common.util.LiveDataMerger
import de.nicidienase.chaosflix.common.util.LiveEvent
import de.nicidienase.chaosflix.common.util.ThreadHandler
import retrofit2.Response
import java.io.IOException
@ -55,8 +57,15 @@ class BrowseViewModel(
fun getUpdateState()
= downloader.updateConferencesAndGroups()
fun updateEventsForConference(conference: Conference)
= downloader.updateEventsForConference(conference)
fun updateEventsForConference(conference: Conference): LiveData<LiveEvent<Downloader.DownloaderState, List<Event>, String>> =
LiveDataMerger<
List<Event>,
LiveEvent<Downloader.DownloaderState, List<Event>, String>,
LiveEvent<Downloader.DownloaderState, List<Event>, String>>()
.merge(getEventsforConference(conference),
downloader.updateEventsForConference(conference)) { list: List<Event>?, liveEvent: LiveEvent<Downloader.DownloaderState, List<Event>, String>? ->
return@merge LiveEvent(liveEvent?.state ?: Downloader.DownloaderState.DONE, list ?: liveEvent?.data, liveEvent?.error)
}
fun getBookmarkedEvents(): LiveData<List<Event>> = updateAndGetEventsForGuids {
database

View file

@ -21,7 +21,9 @@
<!--<color name="img_soft_opaque">#30FF0000</color>-->
<!--<color name="img_full_opaque">#00000000</color>-->
<!--<color name="black_opaque">#AA000000</color>-->
<color name="black">#59000000</color>
<color name="transparent_black_35">#59000000</color>
<color name="transparent_black_70">#B3000000</color>
<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
<!--<color name="orange_transparent">#AAFADCA7</color>-->
<!--<color name="orange">#FADCA7</color>-->

View file

@ -1,7 +1,9 @@
package de.nicidienase.chaosflix.touch
import android.databinding.BindingAdapter
import android.widget.AutoCompleteTextView
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
@ -12,4 +14,9 @@ fun loadImage(imageView: ImageView, url: String){
.load(url)
.apply(RequestOptions().fitCenter())
.into(imageView)
}
@BindingAdapter("bind:time")
fun setDuration(textView: TextView, duration: Long){
textView.text = String.format("%d:%02d:%02d", duration/3600, (duration % 3600) / 60,duration % 60)
}

View file

@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/black"
android:background="@color/transparent_black_35"
tools:context="de.nicidienase.chaosflix.touch.playback.ExoPlayerFragment">
<com.google.android.exoplayer2.ui.SimpleExoPlayerView

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<variable
@ -8,7 +9,7 @@
type="de.nicidienase.chaosflix.common.mediadata.entities.recording.persistence.Event"/>
</data>
<LinearLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -17,75 +18,89 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:foreground="?android:attr/selectableItemBackground"
android:elevation="2dp">
android:elevation="2dp"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
imageUrl="@{event.thumbUrl}"
android:layout_width="@dimen/thumbnail_width"
android:layout_height="@dimen/thumbnail_height"
android:scaleType="fitCenter"/>
android:layout_width="0dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="center"
bind:layout_constraintEnd_toEndOf="parent"
bind:layout_constraintStart_toStartOf="parent"
bind:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/cast_album_art_placeholder"/>
<TextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<!--android:text="@{event.length}"-->
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@color/transparent_black_70"
android:padding="2dp"
android:textColor="@color/white"
bind:layout_constraintBottom_toBottomOf="@+id/imageView"
bind:layout_constraintEnd_toEndOf="@+id/imageView"
bind:time="@{event.length}"
tools:text="1:23:45"/>
</FrameLayout>
<LinearLayout
<TextView
android:id="@+id/title_text"
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical">
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="@{event.title}"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
bind:layout_constraintEnd_toEndOf="parent"
bind:layout_constraintHorizontal_bias="0.0"
bind:layout_constraintStart_toStartOf="parent"
bind:layout_constraintTop_toBottomOf="@+id/imageView"
tools:text="Title"/>
<TextView
android:id="@+id/title_text"
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:text="@{event.title}"
tools:text="Title"
android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
<TextView
android:id="@+id/subtitle_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@{event.subtitle}"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
bind:layout_constraintBottom_toBottomOf="parent"
bind:layout_constraintEnd_toStartOf="@+id/tag_text"
bind:layout_constraintHorizontal_bias="0.0"
bind:layout_constraintStart_toStartOf="@+id/title_text"
bind:layout_constraintTop_toBottomOf="@+id/title_text"
tools:text="Subtitle"/>
<TextView
android:id="@+id/subtitle_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@{event.subtitle}"
tools:text="Subtitle"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"/>
<TextView
android:id="@+id/tag_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:gravity="bottom|end"
android:text=""
bind:layout_constraintBottom_toBottomOf="parent"
bind:layout_constraintEnd_toEndOf="parent"
tools:text="Tag"/>
<TextView
android:id="@+id/tag_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom|right"
android:text=""
tools:text="Tag"/>
</LinearLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</FrameLayout>
</layout>