layout_player_controller_live_l.xml 12.7 KB
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>

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

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

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

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

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

        <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="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="40dp"
                android:background="#44000000"
                android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}">

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

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_alignParentRight="true">

                    <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>