package com.zhaohaoting.framework.abs;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.TabLayout;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.zhaohaoting.framework.R;
import com.zhaohaoting.framework.abs.contract.BaseContract;
import com.zhaohaoting.framework.abs.presenter.AbsActivity;
import com.zhaohaoting.framework.utils.DensityUtil;


/**
 * author：Created by ZHT on 2017/11/1 11:15
 * email：526309416@qq.com
 * desc：activity基类
 */
public abstract class BaseTabActivity<PRESENTER extends BaseContract.BasePresenter> extends AbsActivity<PRESENTER> {
    protected AppBarLayout appBarLayout;
    protected Toolbar actionBar;
    protected TextView titleView;
    //    public View view;
    public FrameLayout flToolbar;
    public FrameLayout content;
    protected CoordinatorLayout coordinatorLayout;
    protected TabLayout tabLayout;
    protected View topLine;

    public Bundle getSavedInstanceState() {
        return savedInstanceState;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_base);
        actionBar = findViewById(R.id.toolbar);
        titleView = findViewById(R.id.title);
        tabLayout = findViewById(R.id.tabs);
        flToolbar = findViewById(R.id.fl_toolbar);
        flToolbar.setPadding(0, DensityUtil.getStatusBarHeight(this), 0, 0);
        content = findViewById(R.id.fl_content);
        coordinatorLayout = findViewById(R.id.coordinator_layout);
        topLine = findViewById(R.id.top_line);
        setSupportActionBar(actionBar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        actionBar.setTitle("");
        actionBar.setNavigationIcon(R.mipmap.back);
        actionBar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                closeActivity();
            }
        });
        titleView.setText(getTitle());
        appBarLayout = findViewById(R.id.appbar_layout);
        rootDataBinding = DataBindingUtil.inflate(LayoutInflater.from(this), getLayoutResId(), content, true);
        initialize();
    }
    public abstract int getLayoutResId();

    protected abstract void initialize();

}
