package com.itti7.itimeu;

import android.support.v4.app.Fragment;
import android.app.Dialog;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by hyemin on 17. 7. 26.
 */

public class ListFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        return inflater.inflate(R.layout.fragment_list, container, false);
    }

    @Override
    public void onStart() {
        super.onStart();

        TextView textView = getView().findViewById(R.id.date_txt_view);
        textView.setText(getDate());

        //when user click add FloatingActionButton for add a item in the list.
        final FloatingActionButton addFab = getActivity().findViewById(R.id.add_fab_btn);
        addFab.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                showAddDialog();
            }
        });
    }

    /**
     * It is a function of today's date.
     * @return  Return the current month and day.
     */
    public String getDate(){
        String today = new SimpleDateFormat("MM.dd").format(new Date());
        return today;
    }


    /**
     * This function open the dialog window to add the item for TdDo list.
     */
    private void showAddDialog(){
        LayoutInflater dialog = LayoutInflater.from(getActivity());

        //assign Dialog
        final View dialogLayout = dialog.inflate(R.layout.add_dialog, null);
        final Dialog addDialog = new Dialog(getActivity());

        addDialog.setContentView(dialogLayout);
        addDialog.show();

        //assign Button
        Button mOkButton = dialogLayout.findViewById(R.id.add_ok_btn);
        Button mCancelButton = dialogLayout.findViewById(R.id.add_cancel_btn);

        //if you click OK button than
        mOkButton.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                Toast.makeText(getActivity(), "OK", Toast.LENGTH_SHORT).show();
            }
        });

        //if you click CANCEL button than
        mCancelButton.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                addDialog.cancel();
            }
        });
    }
}

@@ -917,87 +917,8 @@
 );%0A%0A
-        //when user click add FloatingActionButton for add a item in the list.%0A
     
@@ -999,24 +999,24 @@
 d_fab_btn);%0A
+
         addF
@@ -1437,99 +1437,8 @@
 %7D%0A%0A%0A
-    /**%0A     * This function open the dialog window to add the item for TdDo list.%0A     */%0A
     
@@ -1538,33 +1538,8 @@
 ());
-%0A%0A        //assign Dialog
 %0A   
@@ -1752,32 +1752,8 @@
 );%0A%0A
-        //assign Button%0A
     
@@ -1903,46 +1903,8 @@
 );%0A%0A
-        //if you click OK button than%0A
     
@@ -2160,50 +2160,8 @@
 );%0A%0A
-        //if you click CANCEL button than%0A
     

Revert "주석 추가"