package com.inred.match;

import android.app.Dialog;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.Gravity;
import android.view.View;

import com.inred.library.utils.MatchButton;
import com.inred.library.utils.MatchTextView;
import com.inred.library.utils.util.MatchView;
import com.inred.matchview.R;

/**
 * <p>Title: MatchDialog.java</p>
 * @author inred
 * @version 1.0 创建时间：2015-1-4 下午4:21:28
 */
public class MatchDialog extends DialogFragment{
	
	
	 public MatchDialog() {
	    }

	    Dialog mDialog;
	    MatchTextView matchTextView;
	    MatchButton mMatchButton;

	    @Override
	    public Dialog onCreateDialog(Bundle savedInstanceState) {
	        if (mDialog == null) {
	            mDialog = new Dialog(getActivity(), R.style.cart_dialog);
	            mDialog.setContentView(R.layout.dialog_match);
	            mDialog.setCanceledOnTouchOutside(true);
	            mDialog.getWindow().setGravity(Gravity.CENTER);
	            View view = mDialog.getWindow().getDecorView();
	            matchTextView = (MatchTextView) view.findViewById(R.id.mTextView);
	            matchTextView.setInTime(0.2f);
	            matchTextView.setOutTime(0.2f);
	            matchTextView.setTextColor(Color.RED);
	            matchTextView.setMatchOutListener(new MatchView.MatchOutListener() {
	                @Override
	                public void onBegin() {

	                }

	                @Override
	                public void onProgressUpdate(float progress) {
	                }

	                @Override
	                public void onFinish() {
	                    MatchDialog.super.onStop();
	                }
	            });

	            mMatchButton = (MatchButton) view.findViewById(R.id.mButton);
	            mMatchButton.setInTime(0.2f);
	            mMatchButton.setOutTime(0.2f);
	            mMatchButton.setOnClickListener(new View.OnClickListener() {
	                @Override
	                public void onClick(View v) {
	                    mMatchButton.hide();
	                    matchTextView.hide();
	                }
	            });
	        }
	        return mDialog;
	    }
	
}
