BaseFindFragment.java 1.66 KB
package com.cnlive.goldenline.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.cnlive.goldenline.ui.base.BaseFragment;
import com.cnlive.goldenline.ui.model.EventPlayerListFullScreen;
import com.cnlive.goldenline.ui.model.EventPlayerListPageChange;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

/**
 * Created by gujun on 2017/3/22.
 */

public abstract class BaseFindFragment extends BaseFragment {

    @Override
    protected int getLayoutRes() {
        return 0;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }

    @Override
    public void onDestroy() {
        EventBus.getDefault().unregister(this);
        super.onDestroy();
    }

    protected void onPageChange() {
        //播放列表关闭播放的视频
        EventBus.getDefault().post(new EventPlayerListPageChange());
    }

    /**
     * 监听播放列表中视频的全屏切换
     *
     * @param event
     */
    @Subscribe
    public void onEventCallBack(EventPlayerListFullScreen event) {
        View[] views = getViews();
        if (views == null || views.length < 1) return;

        if (event.isPortrait()) {
            for (View view : views) {
                if (view != null)
                    view.setVisibility(View.VISIBLE);
            }
        } else {
            for (View view : views) {
                if (view != null)
                    view.setVisibility(View.GONE);
            }
        }
    }

    protected abstract View[] getViews();

}