Commit 0f6ce7a9 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais

Now playing now has its own line on TV

parent 023d6be9
{
"version": 1,
"layers": {
"vectorLayer": {
"id": "196",
"name": "vector",
"type": "vector",
"width": 6,
"height": 6,
"children": [
{
"id": "197",
"name": "11",
"type": "path",
"pathData": "M 1.455 3.969 L 2.514 3.969 L 2.514 6.35 L 1.455 6.35 Z",
"fillColor": "#ffffff",
"strokeWidth": 1
},
{
"id": "198",
"name": "21",
"type": "path",
"pathData": "M 2.778 2.117 L 3.836 2.117 L 3.836 6.35 L 2.778 6.35 Z",
"fillColor": "#ffffff",
"strokeWidth": 1
},
{
"id": "199",
"name": "31",
"type": "path",
"pathData": "M 4.101 4.233 L 5.159 4.233 L 5.159 6.35 L 4.101 6.35 Z",
"fillColor": "#ffffff",
"strokeWidth": 1
},
{
"id": "145413",
"name": "path",
"type": "path",
"pathData": "M 1.455 3.969 L 2.514 3.969 L 2.514 6.35 L 1.455 6.35 Z",
"fillColor": "#ffffff",
"strokeWidth": 1
},
{
"id": "145431",
"name": "path_1",
"type": "path",
"pathData": "M 2.778 2.117 L 3.836 2.117 L 3.836 6.35 L 2.778 6.35 Z",
"fillColor": "#ffffff",
"strokeWidth": 1
},
{
"id": "145449",
"name": "path_2",
"type": "path",
"pathData": "M 4.101 4.233 L 5.159 4.233 L 5.159 6.35 L 4.101 6.35 Z",
"fillColor": "#ffffff",
"strokeWidth": 1
}
]
},
"hiddenLayerIds": []
},
"timeline": {
"animation": {
"id": "200",
"name": "anim",
"duration": 1200,
"blocks": [
{
"id": "201",
"layerId": "197",
"propertyName": "pathData",
"startTime": 0,
"endTime": 293,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 1.455 3.969 L 2.514 3.969 L 2.514 6.35 L 1.455 6.35 Z",
"toValue": "M 1.455 0.265 L 2.514 0.265 L 2.514 6.35 L 1.455 6.35 Z"
},
{
"id": "202",
"layerId": "197",
"propertyName": "pathData",
"startTime": 293,
"endTime": 570,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 1.455 0.265 L 2.514 0.265 L 2.514 6.35 L 1.455 6.35 Z",
"toValue": "M 1.455 4.498 L 2.514 4.498 L 2.514 6.35 L 1.455 6.35 Z"
},
{
"id": "203",
"layerId": "197",
"propertyName": "pathData",
"startTime": 570,
"endTime": 732,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 1.455 4.498 L 2.514 4.498 L 2.514 6.35 L 1.455 6.35 Z",
"toValue": "M 1.455 0.794 L 2.514 0.794 L 2.514 6.35 L 1.455 6.35 Z"
},
{
"id": "204",
"layerId": "197",
"propertyName": "pathData",
"startTime": 732,
"endTime": 935,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 1.455 0.794 L 2.514 0.794 L 2.514 6.35 L 1.455 6.35 Z",
"toValue": "M 1.455 4.233 L 2.514 4.233 L 2.514 6.35 L 1.455 6.35 Z"
},
{
"id": "205",
"layerId": "198",
"propertyName": "pathData",
"startTime": 0,
"endTime": 228,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 2.778 2.117 L 3.836 2.117 L 3.836 6.35 L 2.778 6.35 Z",
"toValue": "M 2.778 4.498 L 3.836 4.498 L 3.836 6.35 L 2.778 6.35 Z"
},
{
"id": "206",
"layerId": "198",
"propertyName": "pathData",
"startTime": 228,
"endTime": 514,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 2.778 4.498 L 3.836 4.498 L 3.836 6.35 L 2.778 6.35 Z",
"toValue": "M 2.778 2.91 L 3.836 2.91 L 3.836 6.35 L 2.778 6.35 Z"
},
{
"id": "207",
"layerId": "198",
"propertyName": "pathData",
"startTime": 514,
"endTime": 791,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 2.778 2.91 L 3.836 2.91 L 3.836 6.35 L 2.778 6.35 Z",
"toValue": "M 2.778 6.085 L 3.836 6.085 L 3.836 6.35 L 2.778 6.35 Z"
},
{
"id": "208",
"layerId": "198",
"propertyName": "pathData",
"startTime": 791,
"endTime": 1050,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 2.778 6.085 L 3.836 6.085 L 3.836 6.35 L 2.778 6.35 Z",
"toValue": "M 2.778 0.529 L 3.836 0.529 L 3.836 6.35 L 2.778 6.35 Z"
},
{
"id": "209",
"layerId": "199",
"propertyName": "pathData",
"startTime": 0,
"endTime": 270,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 4.101 4.233 L 5.159 4.233 L 5.159 6.35 L 4.101 6.35 Z",
"toValue": "M 4.101 1.058 L 5.159 1.058 L 5.159 6.35 L 4.101 6.35 Z"
},
{
"id": "210",
"layerId": "199",
"propertyName": "pathData",
"startTime": 270,
"endTime": 589,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 4.101 1.058 L 5.159 1.058 L 5.159 6.35 L 4.101 6.35 Z",
"toValue": "M 4.101 6.085 L 5.159 6.085 L 5.159 6.35 L 4.101 6.35 Z"
},
{
"id": "211",
"layerId": "199",
"propertyName": "pathData",
"startTime": 589,
"endTime": 772,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 4.101 6.085 L 5.159 6.085 L 5.159 6.35 L 4.101 6.35 Z",
"toValue": "M 4.101 2.117 L 5.159 2.117 L 5.159 6.35 L 4.101 6.35 Z"
},
{
"id": "212",
"layerId": "199",
"propertyName": "pathData",
"startTime": 772,
"endTime": 972,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 4.101 2.117 L 5.159 2.117 L 5.159 6.35 L 4.101 6.35 Z",
"toValue": "M 4.101 3.969 L 5.159 3.969 L 5.159 6.35 L 4.101 6.35 Z"
},
{
"id": "69464",
"layerId": "197",
"propertyName": "pathData",
"startTime": 935,
"endTime": 1200,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 1.455 4.233 L 2.514 4.233 L 2.514 6.35 L 1.455 6.35 Z",
"toValue": "M 1.455 3.969 L 2.514 3.969 L 2.514 6.35 L 1.455 6.35 Z"
},
{
"id": "69466",
"layerId": "198",
"propertyName": "pathData",
"startTime": 1050,
"endTime": 1200,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 2.778 0.529 L 3.836 0.529 L 3.836 6.35 L 2.778 6.35 Z",
"toValue": "M 2.778 2.117 L 3.836 2.117 L 3.836 6.35 L 2.778 6.35 Z"
},
{
"id": "69468",
"layerId": "199",
"propertyName": "pathData",
"startTime": 972,
"endTime": 1200,
"interpolator": "FAST_OUT_SLOW_IN",
"type": "path",
"fromValue": "M 4.101 3.969 L 5.159 3.969 L 5.159 6.35 L 4.101 6.35 Z",
"toValue": "M 4.101 4.233 L 5.159 4.233 L 5.159 6.35 L 4.101 6.35 Z"
}
]
}
}
}
\ No newline at end of file
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="6"
android:viewportHeight="6">
<path
android:name="11"
android:pathData="M 1.455 3.969 L 2.514 3.969 L 2.514 6.35 L 1.455 6.35 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
<path
android:name="21"
android:pathData="M 2.778 2.117 L 3.836 2.117 L 3.836 6.35 L 2.778 6.35 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
<path
android:name="31"
android:pathData="M 4.101 4.233 L 5.159 4.233 L 5.159 6.35 L 4.101 6.35 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
<path
android:name="path"
android:pathData="M 1.455 3.969 L 2.514 3.969 L 2.514 6.35 L 1.455 6.35 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
<path
android:name="path_1"
android:pathData="M 2.778 2.117 L 3.836 2.117 L 3.836 6.35 L 2.778 6.35 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
<path
android:name="path_2"
android:pathData="M 4.101 4.233 L 5.159 4.233 L 5.159 6.35 L 4.101 6.35 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
</vector>
</aapt:attr>
<target android:name="11">
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:propertyName="pathData"
android:duration="293"
android:valueFrom="M 1.455 3.969 L 2.514 3.969 L 2.514 6.35 L 1.455 6.35 Z"
android:valueTo="M 1.455 0.265 L 2.514 0.265 L 2.514 6.35 L 1.455 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="293"
android:duration="277"
android:valueFrom="M 1.455 0.265 L 2.514 0.265 L 2.514 6.35 L 1.455 6.35 Z"
android:valueTo="M 1.455 4.498 L 2.514 4.498 L 2.514 6.35 L 1.455 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="570"
android:duration="162"
android:valueFrom="M 1.455 4.498 L 2.514 4.498 L 2.514 6.35 L 1.455 6.35 Z"
android:valueTo="M 1.455 0.794 L 2.514 0.794 L 2.514 6.35 L 1.455 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="732"
android:duration="203"
android:valueFrom="M 1.455 0.794 L 2.514 0.794 L 2.514 6.35 L 1.455 6.35 Z"
android:valueTo="M 1.455 4.233 L 2.514 4.233 L 2.514 6.35 L 1.455 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="935"
android:duration="265"
android:valueFrom="M 1.455 4.233 L 2.514 4.233 L 2.514 6.35 L 1.455 6.35 Z"
android:valueTo="M 1.455 3.969 L 2.514 3.969 L 2.514 6.35 L 1.455 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</set>
</aapt:attr>
</target>
<target android:name="21">
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:propertyName="pathData"
android:duration="228"
android:valueFrom="M 2.778 2.117 L 3.836 2.117 L 3.836 6.35 L 2.778 6.35 Z"
android:valueTo="M 2.778 4.498 L 3.836 4.498 L 3.836 6.35 L 2.778 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="228"
android:duration="286"
android:valueFrom="M 2.778 4.498 L 3.836 4.498 L 3.836 6.35 L 2.778 6.35 Z"
android:valueTo="M 2.778 2.91 L 3.836 2.91 L 3.836 6.35 L 2.778 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="514"
android:duration="277"
android:valueFrom="M 2.778 2.91 L 3.836 2.91 L 3.836 6.35 L 2.778 6.35 Z"
android:valueTo="M 2.778 6.085 L 3.836 6.085 L 3.836 6.35 L 2.778 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="791"
android:duration="259"
android:valueFrom="M 2.778 6.085 L 3.836 6.085 L 3.836 6.35 L 2.778 6.35 Z"
android:valueTo="M 2.778 0.529 L 3.836 0.529 L 3.836 6.35 L 2.778 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="1050"
android:duration="150"
android:valueFrom="M 2.778 0.529 L 3.836 0.529 L 3.836 6.35 L 2.778 6.35 Z"
android:valueTo="M 2.778 2.117 L 3.836 2.117 L 3.836 6.35 L 2.778 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</set>
</aapt:attr>
</target>
<target android:name="31">
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:propertyName="pathData"
android:duration="270"
android:valueFrom="M 4.101 4.233 L 5.159 4.233 L 5.159 6.35 L 4.101 6.35 Z"
android:valueTo="M 4.101 1.058 L 5.159 1.058 L 5.159 6.35 L 4.101 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="270"
android:duration="319"
android:valueFrom="M 4.101 1.058 L 5.159 1.058 L 5.159 6.35 L 4.101 6.35 Z"
android:valueTo="M 4.101 6.085 L 5.159 6.085 L 5.159 6.35 L 4.101 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="589"
android:duration="183"
android:valueFrom="M 4.101 6.085 L 5.159 6.085 L 5.159 6.35 L 4.101 6.35 Z"
android:valueTo="M 4.101 2.117 L 5.159 2.117 L 5.159 6.35 L 4.101 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="772"
android:duration="200"
android:valueFrom="M 4.101 2.117 L 5.159 2.117 L 5.159 6.35 L 4.101 6.35 Z"
android:valueTo="M 4.101 3.969 L 5.159 3.969 L 5.159 6.35 L 4.101 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<objectAnimator
android:propertyName="pathData"
android:startOffset="972"
android:duration="228"
android:valueFrom="M 4.101 3.969 L 5.159 3.969 L 5.159 6.35 L 4.101 6.35 Z"
android:valueTo="M 4.101 4.233 L 5.159 4.233 L 5.159 6.35 L 4.101 6.35 Z"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</set>
</aapt:attr>
</target>
</animated-vector>
\ No newline at end of file
......@@ -23,12 +23,13 @@
<target android:name="path_1">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="300"
android:valueFrom="M 6.879 9.879 C 6.316 10.441 6 11.205 6 12 C 6 12.795 6.316 13.559 6.879 14.121 C 7.441 14.684 8.205 15 9 15 L 27 15 C 27.795 15 28.559 14.684 29.121 14.121 C 29.684 13.559 30 12.795 30 12 C 30 11.205 29.684 10.441 29.121 9.879 C 28.559 9.316 27.795 9 27 9 L 9 9 C 8.205 9 7.441 9.316 6.879 9.879 M 6.879 21.879 C 6.316 22.441 6 23.205 6 24 C 6 24.795 6.316 25.559 6.879 26.121 C 7.441 26.684 8.205 27 9 27 L 27 27 C 27.795 27 28.559 26.684 29.121 26.121 C 29.684 25.559 30 24.795 30 24 C 30 23.205 29.684 22.441 29.121 21.879 C 28.559 21.316 27.795 21 27 21 L 9 21 C 8.205 21 7.441 21.316 6.879 21.879"
android:valueTo="M 6.66 3.001 C 6.66 3.001 6.66 3.001 6.66 3.001 C 5.869 3.049 5.251 3.705 5.251 4.498 C 5.251 8.922 5.251 13.347 5.251 17.771 L 18 17.907 C 22.249 17.952 26.499 17.998 30.748 18.043 C 30.763 17.531 30.521 17.012 30.021 16.712 C 27.521 15.212 25.021 13.712 22.521 12.212 C 20.021 10.712 17.521 9.212 15.021 7.712 L 7.522 3.212 C 7.262 3.057 6.962 2.983 6.66 3.001 M 5.251 24.634 C 5.251 26.922 5.251 29.209 5.251 31.497 C 5.25 32.663 6.521 33.385 7.522 32.786 C 9.397 31.661 11.271 30.536 13.146 29.411 L 18.771 26.035 C 20.646 24.91 22.521 23.785 24.396 22.66 C 26.271 21.534 28.146 20.409 30.021 19.284 C 30.491 19.001 30.734 18.525 30.748 18.043 C 26.499 17.998 22.249 17.952 18 17.907 L 5.251 17.771 C 5.251 20.059 5.251 22.346 5.251 24.634"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
android:propertyName="pathData"
android:duration="300"
android:repeatCount="0"
android:valueFrom="M 6.879 9.879 C 6.316 10.441 6 11.205 6 12 C 6 12.795 6.316 13.559 6.879 14.121 C 7.441 14.684 8.205 15 9 15 L 27 15 C 27.795 15 28.559 14.684 29.121 14.121 C 29.684 13.559 30 12.795 30 12 C 30 11.205 29.684 10.441 29.121 9.879 C 28.559 9.316 27.795 9 27 9 L 9 9 C 8.205 9 7.441 9.316 6.879 9.879 M 6.879 21.879 C 6.316 22.441 6 23.205 6 24 C 6 24.795 6.316 25.559 6.879 26.121 C 7.441 26.684 8.205 27 9 27 L 27 27 C 27.795 27 28.559 26.684 29.121 26.121 C 29.684 25.559 30 24.795 30 24 C 30 23.205 29.684 22.441 29.121 21.879 C 28.559 21.316 27.795 21 27 21 L 9 21 C 8.205 21 7.441 21.316 6.879 21.879"
android:valueTo="M 6.66 3.001 C 6.66 3.001 6.66 3.001 6.66 3.001 C 5.869 3.049 5.251 3.705 5.251 4.498 C 5.251 8.922 5.251 13.347 5.251 17.771 L 18 17.907 C 22.249 17.952 26.499 17.998 30.748 18.043 C 30.763 17.531 30.521 17.012 30.021 16.712 C 27.521 15.212 25.021 13.712 22.521 12.212 C 20.021 10.712 17.521 9.212 15.021 7.712 L 7.522 3.212 C 7.262 3.057 6.962 2.983 6.66 3.001 M 5.251 24.634 C 5.251 26.922 5.251 29.209 5.251 31.497 C 5.25 32.663 6.521 33.385 7.522 32.786 C 9.397 31.661 11.271 30.536 13.146 29.411 L 18.771 26.035 C 20.646 24.91 22.521 23.785 24.396 22.66 C 26.271 21.534 28.146 20.409 30.021 19.284 C 30.491 19.001 30.734 18.525 30.748 18.043 C 26.499 17.998 22.249 17.952 18 17.907 L 5.251 17.771 C 5.251 20.059 5.251 22.346 5.251 24.634"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in" />
</aapt:attr>
</target>
<target android:name="group">
......
......@@ -35,9 +35,12 @@ import android.widget.ImageView
import androidx.core.content.ContextCompat
import androidx.leanback.widget.ImageCardView
import androidx.leanback.widget.Presenter
import androidx.vectordrawable.graphics.drawable.Animatable2Compat
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.medialibrary.Tools
import org.videolan.medialibrary.media.DummyItem
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.MediaWrapper
import org.videolan.vlc.R
......@@ -153,6 +156,17 @@ class CardPresenter(private val context: Activity) : Presenter() {
holder.updateCardViewImage(sDefaultCardImage)
}
}
if (item is DummyItem && item.id == CATEGORY_NOW_PLAYING) {
val badge = AnimatedVectorDrawableCompat.create(context, R.drawable.anim_now_playing)!!
holder.cardView.badgeImage = badge
badge.registerAnimationCallback(object : Animatable2Compat.AnimationCallback() {
override fun onAnimationEnd(drawable: Drawable?) {
badge.start()
super.onAnimationEnd(drawable)
}
})
badge.start()
}
}
override fun onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any, payloads: List<Any>?) {
......
......@@ -56,14 +56,16 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
private var backgroundManager: BackgroundManager? = null
private lateinit var rowsAdapter: ArrayObjectAdapter
private lateinit var nowPlayingAdapter: ArrayObjectAdapter
private lateinit var videoAdapter: ArrayObjectAdapter
private lateinit var categoriesAdapter: ArrayObjectAdapter
private lateinit var historyAdapter: ArrayObjectAdapter
private lateinit var playlistAdapter: ArrayObjectAdapter
private lateinit var browserAdapter: ArrayObjectAdapter
private lateinit var otherAdapter: ArrayObjectAdapter
private lateinit var videoRow: ListRow
private lateinit var nowPlayingRow: ListRow
private lateinit var videoRow: ListRow
private lateinit var audioRow: ListRow
private lateinit var historyRow: ListRow
private lateinit var playlistRow: ListRow
......@@ -72,6 +74,7 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
private var displayHistory = false
private var displayPlaylist = false
private var displayNowPlaying = false
private var selectedItem: Any? = null
internal lateinit var model: MainTvModel
......@@ -98,6 +101,11 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
super.onViewCreated(view, savedInstanceState)
val ctx = requireActivity()
rowsAdapter = ArrayObjectAdapter(ListRowPresenter())
// Now Playing
nowPlayingAdapter = ArrayObjectAdapter(CardPresenter(ctx))
val nowPlayingHeader = HeaderItem(HEADER_CATEGORIES, getString(R.string.music_now_playing))
nowPlayingRow = ListRow(nowPlayingHeader, nowPlayingAdapter)
rowsAdapter.add(nowPlayingRow)
// Video
videoAdapter = ArrayObjectAdapter(CardPresenter(ctx))
val videoHeader = HeaderItem(0, getString(R.string.video))
......@@ -153,6 +161,10 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
model.videos.observe(this, Observer {
videoAdapter.setItems(it, diffCallback)
})
model.nowPlaying.observe(this, Observer {
displayNowPlaying = it.isNotEmpty()
nowPlayingAdapter.setItems(it, diffCallback)
})
model.history.observe(this, Observer {
displayHistory = it.isNotEmpty()
if (it.isNotEmpty()) {
......@@ -171,12 +183,12 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
private fun resetLines() {
val adapters = listOf(videoRow, audioRow, playlistRow, historyRow, browsersRow, miscRow).filter {
val adapters = listOf(nowPlayingRow, videoRow, audioRow, playlistRow, historyRow, browsersRow, miscRow).filter {
when {
!displayHistory && it == historyRow -> false
!displayPlaylist && it == playlistRow -> false
!displayNowPlaying && it == nowPlayingRow -> false
else -> true
......
......@@ -66,9 +66,10 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
private val browserFavRepository = BrowserFavRepository.getInstance(context)
private var updatedFavoritList: List<MediaWrapper> = listOf()
var showHistory = false
private set
private set
// LiveData
private val favorites: LiveData<List<BrowserFav>> = browserFavRepository.browserFavorites
val nowPlaying: LiveData<List<MediaLibraryItem>> = MutableLiveData()
val videos: LiveData<List<MediaLibraryItem>> = MutableLiveData()
val audioCategories: LiveData<List<MediaLibraryItem>> = MutableLiveData()
val browsers: LiveData<List<MediaLibraryItem>> = MutableLiveData()
......@@ -105,8 +106,9 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
}
fun refresh() = launch {
updateAudioCategories()
updateNowPlaying()
updateVideos()
updateAudioCategories()
historyActor.offer(Unit)
updateActor.offer(Unit)
updatePlaylists()
......@@ -136,6 +138,16 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
}
}
private fun updateNowPlaying() = launch {
val list = mutableListOf<MediaLibraryItem>()
PlaybackService.service.value?.run {
currentMediaWrapper?.let {
DummyItem(CATEGORY_NOW_PLAYING, it.title, it.artist).apply { setArtWork(coverArt) }
}
}?.let { list.add(0, it) }
(nowPlaying as MutableLiveData).value = list
}
private fun updatePlaylists() = launch {
context.getFromMl {
getPagedPlaylists(Medialibrary.SORT_INSERTIONDATE, true, NUM_ITEMS_PREVIEW, 0)
......@@ -154,11 +166,6 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
DummyItem(CATEGORY_GENRES, context.getString(R.string.genres), ""),
DummyItem(CATEGORY_SONGS, context.getString(R.string.tracks), "")
)
PlaybackService.service.value?.run {
currentMediaWrapper?.let {
DummyItem(CATEGORY_NOW_PLAYING, it.title, it.artist).apply { setArtWork(coverArt) }
}
}?.let { list.add(0, it) }
(audioCategories as MutableLiveData).value = list
}
......@@ -181,11 +188,17 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
delay(500L)
}
override fun onMedialibraryIdle() { refresh() }
override fun onMedialibraryIdle() {
refresh()
}
override fun onMedialibraryReady() { refresh() }
override fun onMedialibraryReady() {
refresh()
}
override fun onDeviceChange() { refresh() }
override fun onDeviceChange() {
refresh()
}
override fun onCleared() {
super.onCleared()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment