package com.kfzs.cfyl.media;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;


/**
 * Created by realicing on 2018/11/2.
 * realicing@sina.com
 */
public abstract class BaseContainerActivity extends BaseActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.media_common_container;
    }

    protected Fragment fragment;

    @Override
    public void initView() {

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        fragment = getSupportFragmentManager().findFragmentByTag("tag");
        if (fragment == null) {
            fragment = initFragment();
            transaction.add(R.id.media_frame_container, fragment, "tag");
            transaction.commitAllowingStateLoss();
        } else {
            transaction.replace(R.id.media_frame_container, fragment);
            transaction.commitAllowingStateLoss();
        }

    }

    protected abstract Fragment initFragment();
}