package com.naijab.nextzytimeline.ui.people.addform;

import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.DatePicker;
import android.widget.EditText;

import com.naijab.nextzytimeline.R;
import com.naijab.nextzytimeline.base.BaseMvpFragment;

import java.util.Calendar;
import java.util.Locale;

public class AddPeopleFragment extends BaseMvpFragment<AddPeopleFragmentInterface.Presenter>
        implements AddPeopleFragmentInterface.View {

    private EditText dateBirth;
    private EditText dateJob;
    private int mYear, mMonth, mDay;

    public AddPeopleFragment() {
        super();
    }

    public static AddPeopleFragment newInstance() {
        AddPeopleFragment fragment = new AddPeopleFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public AddPeopleFragmentInterface.Presenter createPresenter() {
        return AddPeopleFragmentPresenter.create();
    }

    @Override
    public int getLayoutView() {
        return R.layout.fragment_add_people;
    }

    @Override
    public void bindView(View view) {
        dateBirth = (EditText) view.findViewById(R.id.edt_birthday);
        dateJob = (EditText) view.findViewById(R.id.edt_startjob);
    }

    @Override
    public void setupInstance() {

    }

    @Override
    public void setupView() {
        dateBirth.setOnClickListener(showDatePicker);
        dateJob.setOnClickListener(showDatePicker);
    }

    @Override
    public void initialize() {

    }

    @Override
    public void restoreView(Bundle savedInstanceState) {

    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
    }


    private View.OnClickListener showDatePicker = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final View vv = v;

            final Calendar calendar = Calendar.getInstance();
            mYear = calendar.get(Calendar.YEAR);
            mMonth = calendar.get(Calendar.MONTH);
            mDay = calendar.get(Calendar.DAY_OF_MONTH);

            DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {

                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, month);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);

                    if (vv.getId() == R.id.edt_birthday) {
                        setDateBirth(mYear, mMonth, mDay);
                    }
                    if (vv.getId() == R.id.edt_startjob) {
                        setDateJob(mYear, mMonth, mDay);
                    }
                }
            }, mYear, mMonth, mDay);
            datePickerDialog.show();
        }
    };

    private void setDateBirth(int year,
                              int monthOfYear,
                              int dayOfMonth) {
        dateBirth.setText(dayOfMonth + "-" + monthOfYear + "-" + year);
    }

    private void setDateJob(int year,
                            int monthOfYear,
                            int dayOfMonth) {
        dateJob.setText(dayOfMonth + "-" + monthOfYear + "-" + year);
    }


}


@@ -110,16 +110,75 @@
 Bundle;%0A
+import android.support.design.widget.FloatingActionButton;%0A
 import a
@@ -195,16 +195,16 @@
 w.View;%0A
-
 import a
@@ -260,16 +260,49 @@
 ditText;
+%0Aimport android.widget.ImageView;
 %0A%0Aimport
@@ -417,33 +417,8 @@
 dar;
-%0Aimport java.util.Locale;
 %0A%0Apu
@@ -624,16 +624,83 @@
 ateJob;%0A
+    private ImageView photo;%0A    private FloatingActionButton fab;%0A
     priv
@@ -1433,16 +1433,144 @@
 rtjob);%0A
+        photo = (ImageView) view.findViewById(R.id.iv_photo);%0A        fab = (FloatingActionButton) view.findViewById(R.id.fab);%0A
     %7D%0A%0A 
@@ -1770,24 +1770,67 @@
 atePicker);%0A
+        fab.setOnClickListener(takePhoto);%0A
     %7D%0A%0A    @
@@ -3425,16 +3425,16 @@
   %7D%0A
-
     %7D;%0A%0A
     
@@ -3429,16 +3429,166 @@
     %7D;%0A%0A
+    private View.OnClickListener takePhoto = new View.OnClickListener() %7B%0A        @Override%0A        public void onClick(View v) %7B%0A%0A        %7D%0A    %7D;%0A%0A%0A
     priv

Add Fab onClick listener