layout_player_controller_vod_l.xml 14.8 KB
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <import type="android.databinding.ObservableField" />

        <import type="android.databinding.ObservableBoolean" />

        <import type="android.databinding.ObservableLong" />

        <import type="android.databinding.ObservableInt" />

        <import type="com.cnlive.gundam.video.utils.PlayerUtils" />

        <import type="android.view.View" />

        <import type="com.cnlive.gundam.video.utils.VideoRateUtil" />

        <import type="com.cnlive.gundam.video.view.PlayerControllerView" />

        <variable
            name="title"
            type="ObservableField&lt;String>" />

        <variable
            name="showController"
            type="ObservableBoolean" />

        <variable
            name="isPlay"
            type="ObservableBoolean" />

        <variable
            name="curProgress"
            type="ObservableLong" />

        <variable
            name="durProgress"
            type="ObservableLong" />

        <variable
            name="rateType"
            type="ObservableInt" />

        <variable
            name="hasRate"
            type="ObservableBoolean" />

        <variable
            name="showRateListLayout"
            type="ObservableBoolean" />

        <variable
            name="showRateToastLayout"
            type="ObservableBoolean" />

        <variable
            name="curSwitchRateType"
            type="ObservableInt" />

        <variable
            name="curSwitchRateStr"
            type="ObservableField&lt;String>" />

        <variable
            name="rateListStr"
            type="ObservableField&lt;String>" />

        <variable
            name="playerControllerView"
            type="PlayerControllerView" />

    </data>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/topLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#44000000"
            android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}">

            <ImageView
                android:id="@+id/back"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginLeft="10dp"
                android:onClick="@{playerControllerView.onClick}"
                android:src="@drawable/player_back" />

            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="50dp"
                android:gravity="center"
                android:text="@{title.get()}"
                android:textColor="@android:color/white" />

        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="vertical">

            <RelativeLayout
                android:id="@+id/switchVideoRateToastLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/bottomLayout"
                android:background="@drawable/player_rate_bg"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:visibility="@{showRateToastLayout.get() ? View.VISIBLE : View.GONE}">

                <TextView
                    android:id="@+id/toastPre"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:textColor="@android:color/white"
                    android:textSize="12sp"
                    android:text="@{curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_START ? @string/loading_rate_pre : (curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_FINISH ? @string/loaded_rate_pre : @string/loaded_rate_error_pre)}" />

                <TextView
                    android:id="@+id/toastText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@+id/toastPre"
                    android:textColor="@color/rate_sel"
                    android:textSize="12sp"
                    android:text="@{curSwitchRateStr.get()}" />

                <TextView
                    android:id="@+id/toastLast"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@+id/toastText"
                    android:textColor="@android:color/white"
                    android:textSize="12sp"
                    android:text="@{curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_START ? @string/loading_rate_last : (curSwitchRateType.get() == PlayerControllerView.SWITCH_RATE_FINISH ? @string/loaded_rate_last : @string/loaded_rate_error_last)}"  />

            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/bottomLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:background="#44000000"
                android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}">

                <SeekBar
                    android:id="@+id/progressBar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:max="@{(int)(durProgress.get() / 1000)}"
                    android:onSeekBarChangeListener="@{playerControllerView}"
                    android:progress="@{(int)(curProgress.get() / 1000)}" />

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/progressBar">

                    <ImageView
                        android:id="@+id/playBtn"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:layout_marginRight="5dp"
                        android:layout_marginLeft="10dp"
                        android:onClick="@{playerControllerView.onClick}"
                        android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" />

                    <TextView
                        android:id="@+id/curTime"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_toRightOf="@+id/playBtn"
                        android:text="@{PlayerUtils.stringForTime(curProgress.get() / 1000)}"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/lineTime"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_toRightOf="@+id/curTime"
                        android:text="/"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/durTime"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_toRightOf="@+id/lineTime"
                        android:text="@{PlayerUtils.stringForTime(durProgress.get() / 1000)}"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/rate"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_centerVertical="true"
                        android:layout_marginRight="10dp"
                        android:onClick="@{playerControllerView.onClick}"
                        android:text="@{VideoRateUtil.getRateText(rateType.get())}"
                        android:textColor="@android:color/white"
                        android:visibility="@{hasRate.get() ? View.VISIBLE : View.GONE}" />

                </RelativeLayout>

            </RelativeLayout>

        </LinearLayout>

        <RelativeLayout
            android:id="@+id/rateLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="@{showRateListLayout.get() ? View.VISIBLE : View.GONE}">

            <View
                android:id="@+id/rateOutClickView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_toLeftOf="@+id/rightLayout"
                android:onClick="@{playerControllerView.onClick}" />

            <LinearLayout
                android:id="@+id/rightLayout"
                android:layout_width="124dp"
                android:layout_height="match_parent"
                android:layout_alignParentRight="true"
                android:background="#4c000000"
                android:gravity="center_horizontal"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_L) ? View.VISIBLE : View.GONE}">

                    <TextView
                        android:id="@+id/rateL"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:button="@null"
                        android:gravity="center"
                        android:onClick="@{playerControllerView.onClick}"
                        android:paddingBottom="5dp"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:paddingTop="5dp"
                        android:text="流畅"
                        android:textColor="@{rateType == PlayerControllerView.RATE_L ? @color/rate_sel : @color/rate_nor}"
                        android:textSize="17sp" />
                </LinearLayout>


                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_M) ? View.VISIBLE : View.GONE}">

                    <TextView
                        android:id="@+id/rateM"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:button="@null"
                        android:gravity="center"
                        android:onClick="@{playerControllerView.onClick}"
                        android:paddingBottom="5dp"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:paddingTop="5dp"
                        android:text="标清"
                        android:textColor="@{rateType == PlayerControllerView.RATE_M ? @color/rate_sel : @color/rate_nor}"
                        android:textSize="17sp" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_H) ? View.VISIBLE : View.GONE}">

                    <TextView
                        android:id="@+id/rateH"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:button="@null"
                        android:gravity="center"
                        android:onClick="@{playerControllerView.onClick}"
                        android:paddingBottom="5dp"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:paddingTop="5dp"
                        android:text="高清"
                        android:textColor="@{rateType == PlayerControllerView.RATE_H ? @color/rate_sel : @color/rate_nor}"
                        android:textSize="17sp" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:visibility="@{VideoRateUtil.hasCurRate(rateListStr.get(),PlayerControllerView.RATE_HH) ? View.VISIBLE : View.GONE}">

                    <TextView
                        android:id="@+id/rateHH"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:button="@null"
                        android:gravity="center"
                        android:onClick="@{playerControllerView.onClick}"
                        android:paddingBottom="5dp"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:paddingTop="5dp"
                        android:text="超高清"
                        android:textColor="@{rateType == PlayerControllerView.RATE_HH ? @color/rate_sel : @color/rate_nor}"
                        android:textSize="17sp" />
                </LinearLayout>

            </LinearLayout>

        </RelativeLayout>

    </RelativeLayout>

</layout>