package com.genlot.ninglottery.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import com.genlot.ninglottery.R;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author ZhuYongKang
 * @description DialogActivity基类
 * @date 2019/8/21
 */
public abstract class BaseDialogActivity extends BaseActivity{

    public Fragment mCurrentFragment;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window win = this.getWindow();
        win.getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams lp = win.getAttributes();
        lp.width = 864;
        lp.height = 564;
        lp.gravity = Gravity.CENTER;//设置对话框置顶显示
        win.setAttributes(lp);
    }

    public void replaceFragment(Fragment targetFragment) {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.frame_layout, targetFragment)
                .commit();
        mCurrentFragment = targetFragment;
    }

    public void hideFragment() {
        if (mCurrentFragment != null) {
            getSupportFragmentManager().beginTransaction()
                    .hide(mCurrentFragment)
                    .commit();
        }
    }

    @OnClick(R.id.icon_close)
    public void close() {
        finish();
    }

    @BindView(R.id.icon_close)
    public Button btClose;
}


