package org.deke.risk.riskahead.fragment;


import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.annotation.NonNull;

import com.google.firebase.crashlytics.FirebaseCrashlytics;

import org.deke.risk.riskahead.R;
import org.deke.risk.riskahead.ReportWFActivity;
import org.deke.risk.riskahead.helper.IncidentReport;

/**
 *
 * (C) Copyright 2016 RiskAhead (http://www.riskahead.net)
 * Developer & Contributor: Dennis Thießen (dennis.thiessen@riskahead.net)
 * Date of Release: 10.02.2016
 *
 */
public class ReportWF_Finish_Fragment extends BaseReportWFFragment {
    private final static String TAG = ReportWF_Finish_Fragment.class.getSimpleName();

    private SendReportListener mCallback;

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View viewFragment = inflater.inflate(R.layout.fragment_reportwf_finish, container, false);

        Button btnSendReport = viewFragment.findViewById(R.id.btn_reportwf_finish_send);
        btnSendReport.setOnClickListener(v -> mCallback.sendReport());

        return viewFragment;
    }

    @Override
    public IncidentReport getCurrentInput() {
        ReportWFActivity activity = (ReportWFActivity) getActivity();
        if(activity != null){
            return activity.getIncident();
        }else{
            FirebaseCrashlytics.getInstance().log("Could not get parent Activity");
            return null;
        }
    }

    public interface SendReportListener {
        void sendReport();
    }

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);

        try {
            mCallback = (SendReportListener) context;
        } catch (ClassCastException e) {
            throw new ClassCastException(context.toString()
                    + " must implement SendReportListener");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }


}
