<commit_before>package com.stan.library;

import android.app.DialogFragment;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

/**
 * Created by uu on 2017/9/29.
 */

public abstract class AbstractDialogFragment extends DialogFragment{
    public static final String TAG = "AbstractDialogFragment";
    /**
     * width/height 宽、高 单位dp
     */
    private int width = ViewGroup.LayoutParams.WRAP_CONTENT;
    private int height = ViewGroup.LayoutParams.WRAP_CONTENT;

    /**
     * fWidth/fHeight 百分比宽高
     */
    private float fWidth,fHeight;

    /**
     * style 动画 id
     */
    private int animationId;

    /**
     * FEATURE_NO_TITLE
     */
    private boolean noTitle;

    /**
     * 根view
     */
    protected View rootView;
    /**
     * cancel、confirm 点击事件监听
     */
    protected View.OnClickListener cancelListener,confirmListener;

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("width",width);
        outState.putInt("height",height);
        outState.putFloat("fWidth",fWidth);
        outState.putFloat("fHeight",fHeight);
        outState.putInt("animationId",animationId);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getSaveState(savedInstanceState);
        initWindow();
        rootView = inflater.inflate(setLayoutId(),container);
        initView(rootView);
        return rootView;
    }

    private void getSaveState(Bundle savedInstanceState) {
        if (savedInstanceState != null) {
            this.width = savedInstanceState.getInt("width");
            this.height = savedInstanceState.getInt("height");
            this.fWidth = savedInstanceState.getFloat("fWidth");
            this.fHeight = savedInstanceState.getFloat("fHeight");
            this.animationId = savedInstanceState.getInt("animationId");
        }
    }

    /**
     * 初始化 Windows
     */
    private void initWindow() {
        if (noTitle)
            getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);<commit_msg>Add feature attachToRoot<commit_after>package com.stan.library;

import android.app.DialogFragment;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

/**
 * Created by uu on 2017/9/29.
 */

public abstract class AbstractDialogFragment extends DialogFragment{
    public static final String TAG = "AbstractDialogFragment";
    /**
     * width/height 宽、高 单位dp
     */
    private int width = ViewGroup.LayoutParams.WRAP_CONTENT;
    private int height = ViewGroup.LayoutParams.WRAP_CONTENT;

    /**
     * fWidth/fHeight 百分比宽高
     */
    private float fWidth,fHeight;

    /**
     * style 动画 id
     */
    private int animationId;

    /**
     * FEATURE_NO_TITLE
     */
    private boolean noTitle;

    /**
     * 根view
     */
    protected View rootView;
    /**
     * cancel、confirm 点击事件监听
     */
    protected View.OnClickListener cancelListener,confirmListener;

    protected boolean attachToRoot = false;

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("width",width);
        outState.putInt("height",height);
        outState.putFloat("fWidth",fWidth);
        outState.putFloat("fHeight",fHeight);
        outState.putInt("animationId",animationId);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getSaveState(savedInstanceState);
        initWindow();
        rootView = inflater.inflate(setLayoutId(),container,attachToRoot);
        initView(rootView);
        return rootView;
    }

    private void getSaveState(Bundle savedInstanceState) {
        if (savedInstanceState != null) {
            this.width = savedInstanceState.getInt("width");
            this.height = savedInstanceState.getInt("height");
            this.fWidth = savedInstanceState.getFloat("fWidth");
            this.fHeight = savedInstanceState.getFloat("fHeight");
            this.animationId = savedInstanceState.getInt("animationId");
        }
    }

    /**
     * 初始化 Windows
     */
    private void initWindow() {
        if (noTitle)
            getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
{'fraction_non_alphanumeric': 0.10247046186895811, 'fraction_numerical': 0.0030075187969924814, 'mean_word_length': 2.902766135792121, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2561218', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1294, 'n_words': 249}