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 conferenceId: Long = 0,
var guid: String = "", var guid: String = "",
var title: String = "", var title: String = "",
var subtitle: String? = "", var subtitle: String?,
var slug: String = "", var slug: String = "",
var link: String? = "", var link: String? = "",
var description: String? = "", var description: String?,
@SerializedName("original_language") @SerializedName("original_language")
var originalLanguage: String = "", var originalLanguage: String = "",
var persons: Array<String>?, var persons: Array<String>?,

View file

@ -89,8 +89,8 @@ data class Event(
constructor(event: EventDto, conferenceId: Long = 0) : this( constructor(event: EventDto, conferenceId: Long = 0) : this(
conferenceId = conferenceId, conferenceId = conferenceId,
guid = event.guid, guid = event.guid,
title = event.title, title = event.title.trim(),
subtitle = event.subtitle, subtitle = event.subtitle?.trim(),
slug = event.slug, slug = event.slug,
link = event.link, link = event.link,
description = event.description, 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.network.StreamingService
import de.nicidienase.chaosflix.common.mediadata.sync.Downloader import de.nicidienase.chaosflix.common.mediadata.sync.Downloader
import de.nicidienase.chaosflix.common.userdata.entities.download.OfflineEvent 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 de.nicidienase.chaosflix.common.util.ThreadHandler
import retrofit2.Response import retrofit2.Response
import java.io.IOException import java.io.IOException
@ -55,8 +57,15 @@ class BrowseViewModel(
fun getUpdateState() fun getUpdateState()
= downloader.updateConferencesAndGroups() = downloader.updateConferencesAndGroups()
fun updateEventsForConference(conference: Conference) fun updateEventsForConference(conference: Conference): LiveData<LiveEvent<Downloader.DownloaderState, List<Event>, String>> =
= downloader.updateEventsForConference(conference) 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 { fun getBookmarkedEvents(): LiveData<List<Event>> = updateAndGetEventsForGuids {
database database

View file

@ -21,7 +21,9 @@
<!--<color name="img_soft_opaque">#30FF0000</color>--> <!--<color name="img_soft_opaque">#30FF0000</color>-->
<!--<color name="img_full_opaque">#00000000</color>--> <!--<color name="img_full_opaque">#00000000</color>-->
<!--<color name="black_opaque">#AA000000</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="white">#FFFFFF</color>
<!--<color name="orange_transparent">#AAFADCA7</color>--> <!--<color name="orange_transparent">#AAFADCA7</color>-->
<!--<color name="orange">#FADCA7</color>--> <!--<color name="orange">#FADCA7</color>-->

View file

@ -1,7 +1,9 @@
package de.nicidienase.chaosflix.touch package de.nicidienase.chaosflix.touch
import android.databinding.BindingAdapter import android.databinding.BindingAdapter
import android.widget.AutoCompleteTextView
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
@ -13,3 +15,8 @@ fun loadImage(imageView: ImageView, url: String){
.apply(RequestOptions().fitCenter()) .apply(RequestOptions().fitCenter())
.into(imageView) .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_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:background="@color/black" android:background="@color/transparent_black_35"
tools:context="de.nicidienase.chaosflix.touch.playback.ExoPlayerFragment"> tools:context="de.nicidienase.chaosflix.touch.playback.ExoPlayerFragment">
<com.google.android.exoplayer2.ui.SimpleExoPlayerView <com.google.android.exoplayer2.ui.SimpleExoPlayerView

View file

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