package hh.dejsem.hack;

import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

import java.util.GregorianCalendar;

import hh.lib.D;

public class HackDF extends DialogFragment {

	static HackDF instantiate(D d) {
		HackDF ndf = new HackDF();
		ndf.d = new D(ndf);
		ndf.d.setFragment(ndf);
		ndf.d.setAct(d.getAct());
		ndf.d.l("instantiate");
		return ndf;
	}

	D d;

	/*@Override
	public void onAttach(FragmentActivity c) {
		super.onAttach(c);
		if(d == null) {
			d = new D(this);
			d.setAct(c);
		}
		d.l(2, String.format("onAttach"));
	}*/

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		d.l(2, String.format("onCreateDialog"));
		final GregorianCalendar cal = new GregorianCalendar();
		final String s = String.format("● %d.%02d.%02d %02d:%02d:%02d.%03d UTC+%d",
				cal.get(cal.YEAR), cal.get(cal.MONTH) + 1, cal.get(cal.DAY_OF_MONTH),
				cal.get(cal.HOUR_OF_DAY), cal.get(cal.MINUTE), cal.get(cal.SECOND), cal.get(cal.MILLISECOND),
				((cal.get(cal.ZONE_OFFSET) + cal.get(cal.DST_OFFSET))/(3600*1000)));
		return new AlertDialog.Builder(this.getActivity())
				.setTitle("zkouška převracení")
				.setMessage(s)
				.create();
	}

	@Override
	public void onSaveInstanceState(Bundle b) {
		//		super.onSaveInstanceState(b);
		d.l(2, "onSaveInstanceState");
	}
}
