/**
 * 导航栏初始化与控制 Helper
 * 从 EZPlayBackListActivity 拆分出来，负责竖屏/横屏 TitleBar 初始化、返回按钮、右上角按钮等逻辑
 */
package com.videogo.ui.playback.helper;

import android.graphics.Color;
import android.view.View;
import android.widget.Button;

import com.videogo.openapi.EzvizAPI;
import com.videogo.ui.playback.EZPlayBackListActivity;
import com.videogo.widget.TitleBar;

import ezviz.ezopensdk.R;

/**
 * 导航栏初始化与控制 Helper
 * 管理竖屏/横屏 TitleBar 的初始化、返回按钮、右上角录像类型按钮
 * <p>
 * 直接持有 Activity 引用，生命周期与 Activity 一致
 */
public class TitleBarHelper {

    private static final String TAG = "TitleBarHelper";

    private final EZPlayBackListActivity mActivity;// Activity 引用
    public Button rightButton;// 右上角录像类型按钮

    public TitleBarHelper(EZPlayBackListActivity activity) {
        this.mActivity = activity;
        initTitleBar();
    }

    /**
     * 导航栏初始化
     */
    private void initTitleBar() {
        // 竖屏TitleBar
        mActivity.mPortraitTitleBar = (TitleBar) mActivity.findViewById(R.id.title);
        // 横屏TitleBar
        mActivity.mLandscapeTitleBar = (TitleBar) mActivity.findViewById(R.id.pb_title_bar_landscape);
        mActivity.mLandscapeTitleBar.setStyle(Color.rgb(0xff, 0xff, 0xff), mActivity.getResources().getDrawable(R.color.dark_bg_70p),
                null/*getResources().getDrawable(R.drawable.message_back_selector)*/);
        if (mActivity.mCameraInfo != null) {
            mActivity.mLandscapeTitleBar.setTitle(mActivity.mCameraInfo.getCameraName());
        }
        mActivity.mLandscapeTitleBar.addBackButton(v -> mActivity.onBackPressed());
        // 竖屏返回按钮
        mActivity.mPortraitTitleBar.addBackButton(v -> {
            mActivity.onExitCurrentPageClick();
            mActivity.finish();
        });
        // 右上角录像类型按钮
        rightButton = mActivity.mPortraitTitleBar.addRightButton(R.drawable.common_title_extension, v -> {
            mActivity.mRecordQueryHelper.showTopRightMenu(rightButton);
        });
        rightButton.setVisibility(EzvizAPI.getInstance().isUsingGlobalSDK() ? View.VISIBLE : View.GONE);
    }

    // region --- 公开方法 ---

    // endregion
}
