package kr.co.hanwha.hifive.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.view.View;
import android.widget.TextView;

import kr.co.hanwha.hifive.R;

public class HFPickerDialog extends Dialog {
    private HFPickerDialog.OnDialogCallback mCallback;

    public HFPickerDialog(@NonNull Context context) {
        super(context);
    }

    public HFPickerDialog(@NonNull Context context, @StyleRes int themeResId) {
        super(context, themeResId);
    }

    protected HFPickerDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public HFPickerDialog(@NonNull Context context, @Nullable HFPickerDialog.OnDialogCallback callback) {
        super(context, R.style.DialogFadeAnim);
        setCancelable(false);
        this.mCallback = callback;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.dialog_hf_picker);

        TextView textViewCancel = (TextView) findViewById(R.id.cancel_textView);
        TextView textViewConfirm = (TextView) findViewById(R.id.confirm_textView);

        textViewCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mCallback != null) mCallback.onCancel();
                HFPickerDialog.this.dismiss();
            }
        });

        textViewConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mCallback != null) mCallback.onConfirm();
                HFPickerDialog.this.dismiss();
            }
        });
    }

    /**************************************************
     * Callback
     **************************************************/
    public interface OnDialogCallback {
        void onCancel();

        void onConfirm();
    }
}
