// Path: app/src/main/java/com/tryouts/courierapplication/presenters/CurrentOrderPresenter.java
// public class CurrentOrderPresenter {
// 
//     private CurrentOrderFragment mView;
//     private CurrentOrderInteractor mInteractor;
// 
//     public CurrentOrderPresenter(CurrentOrderFragment fragment) {
//         this.mView = fragment;
//         this.mInteractor = new CurrentOrderInteractor(this);
//         setInteractorContext();
//     }
// 
//     /**
//      * Detaches this presenter from the view.
//      */
//     public void detachView() {
//         this.mView = null;
//     }
// 
//     /**
//      * Initial method.
//      * Informs the view to show progress dialog while loading the data.
//      * Sends request to interactor for data about current order, providing
//      * interactor with order's timestamp.
//      * Sends request to interactor to check whether user is a courier.
//      */
//     public void initialize() {
//         mView.showProgressDialog();
//         mInteractor.getOrderData(mView.getOrderTimeStamp());
//         mInteractor.checkWhetherLoggedUserIsCourier();
//     }
// 
//     /**
//      * Upon receiving order strings, sends it to view in order to display them to the user.
//      * @param from
//      * @param to
//      * @param distance
//      * @param phone
//      * @param date
//      * @param additionalOne
//      * @param additionalTwo
//      * @param additionalThree
//      */
//     public void onOrderStringsReceived(String from, String to, String distance, String phone,
//                                        String date, boolean additionalOne, boolean additionalTwo,
//                                        boolean additionalThree) {
//         mView.setViewsWithData(from, to, distance, phone, date, additionalOne,
//                 additionalTwo, additionalThree);
//         mView.hideProgressDialog();
//     }
// 
//     /**
//      * Informs view that it needs to inflate courier buttons
//      */
//     public void inflateCourierButtons() {
//         mView.onInflateCourierButtonsCall();
//     }
// 
//     /**
//      * Informs interactor that one of the (whichButton) courier buttons was pressed.
//      */
//     public void onCourierButtonClick(int whichButton) {
//         mInteractor.checkIfSureToChangeOrderStatus(mView.getFragmentContext(),
//                 mView.getOrderTimeStamp(), whichButton);
//     }
//     /**
//      * Receives a call when alertdialog is ready for the view.
//      * Informs the view to show alertdialog from the interactor.
//      */
//     public void onCreatedAlertDialog() {
//         mView.showDialog(mInteractor.getAlertDialog());
//     }
// 
//     /**
//      * Receives a call from the interactor when the order is either canceled or finished.
//      * Informs the view in order for order's timestamp removal from the sharedpreferences.
//      */
//     public void removeOrderFromSharedPreferences() {
//         mView.removeOrderFromSharedPreferences();
//     }
// 
//     /**
//      * Receives a call from the interactor when toast should be displayed.
//      * Specifies what kind of toast it should be with @param.
//      * @param whichType
//      */
//     public void sendToast(String whichType) {
//         mView.makeToast(whichType);
//     }
// 
//     public void hideProgressDialog() {
//         mView.hideProgressDialog();
//     }
// 
//     /**
//      * Sends context to interactor
//      */
//     private void setInteractorContext() {
//         mInteractor.setInteractorContext(mView.getContext());
//     }
// 
// 
// }


import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckedTextView;
import android.widget.TextView;
import android.widget.Toast;
import com.tryouts.courierapplication.presenters.CurrentOrderPresenter;
import com.tryouts.courierapplication.R;
    private CurrentOrderPresenter mPresenter;

    public CurrentOrderFragment() {
    }

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

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mSharedPreferences = this.getActivity().getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
        orderTimeStamp = mSharedPreferences.getString(PREFERENCES_TEXT_FIELD, PREFERENCES_EMPTY);

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

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        mDateTextView = (TextView) view.findViewById(R.id.progress_body_date);
        mFromTextView = (TextView) view.findViewById(R.id.progress_body_from_txt);
        mToTextView = (TextView) view.findViewById(R.id.progress_body_to_txt);
        mDistanceTextView = (TextView) view.findViewById(R.id.progress_body_distance);
        mPhoneTextView = (TextView) view.findViewById(R.id.progress_body_phone_txt);
        mFirstAdditionalServiceTextView = (CheckedTextView) view.findViewById(R.id.progress_check_1);
        mSecondAdditionalServiceTextView = (CheckedTextView) view.findViewById(R.id.progress_check_2);
        mThirdAdditionalServiceTextView = (CheckedTextView) view.findViewById(R.id.progress_check_3);

// Path: app/src/main/java/com/tryouts/courierapplication/presenters/CurrentOrderPresenter.java
// public class CurrentOrderPresenter {
// 
//     private CurrentOrderFragment mView;
//     private CurrentOrderInteractor mInteractor;
// 
//     public CurrentOrderPresenter(CurrentOrderFragment fragment) {
//         this.mView = fragment;
//         this.mInteractor = new CurrentOrderInteractor(this);
//         setInteractorContext();
//     }
// 
//     /**
//      * Detaches this presenter from the view.
//      */
//     public void detachView() {
//         this.mView = null;
//     }
// 
//     /**
//      * Initial method.
//      * Informs the view to show progress dialog while loading the data.
//      * Sends request to interactor for data about current order, providing
//      * interactor with order's timestamp.
//      * Sends request to interactor to check whether user is a courier.
//      */
//     public void initialize() {
//         mView.showProgressDialog();
//         mInteractor.getOrderData(mView.getOrderTimeStamp());
//         mInteractor.checkWhetherLoggedUserIsCourier();
//     }
// 
//     /**
//      * Upon receiving order strings, sends it to view in order to display them to the user.
//      * @param from
//      * @param to
//      * @param distance
//      * @param phone
//      * @param date
//      * @param additionalOne
//      * @param additionalTwo
//      * @param additionalThree
//      */
//     public void onOrderStringsReceived(String from, String to, String distance, String phone,
//                                        String date, boolean additionalOne, boolean additionalTwo,
//                                        boolean additionalThree) {
//         mView.setViewsWithData(from, to, distance, phone, date, additionalOne,
//                 additionalTwo, additionalThree);
//         mView.hideProgressDialog();
//     }
// 
//     /**
//      * Informs view that it needs to inflate courier buttons
//      */
//     public void inflateCourierButtons() {
//         mView.onInflateCourierButtonsCall();
//     }
// 
//     /**
//      * Informs interactor that one of the (whichButton) courier buttons was pressed.
//      */
//     public void onCourierButtonClick(int whichButton) {
//         mInteractor.checkIfSureToChangeOrderStatus(mView.getFragmentContext(),
//                 mView.getOrderTimeStamp(), whichButton);
//     }
//     /**
//      * Receives a call when alertdialog is ready for the view.
//      * Informs the view to show alertdialog from the interactor.
//      */
//     public void onCreatedAlertDialog() {
//         mView.showDialog(mInteractor.getAlertDialog());
//     }
// 
//     /**
//      * Receives a call from the interactor when the order is either canceled or finished.
//      * Informs the view in order for order's timestamp removal from the sharedpreferences.
//      */
//     public void removeOrderFromSharedPreferences() {
//         mView.removeOrderFromSharedPreferences();
//     }
// 
//     /**
//      * Receives a call from the interactor when toast should be displayed.
//      * Specifies what kind of toast it should be with @param.
//      * @param whichType
//      */
//     public void sendToast(String whichType) {
//         mView.makeToast(whichType);
//     }
// 
//     public void hideProgressDialog() {
//         mView.hideProgressDialog();
//     }
// 
//     /**
//      * Sends context to interactor
//      */
//     private void setInteractorContext() {
//         mInteractor.setInteractorContext(mView.getContext());
//     }
// 
// 
// }


// Path: app/src/main/java/com/tryouts/courierapplication/fragments/CurrentOrderFragment.java
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckedTextView;
import android.widget.TextView;
import android.widget.Toast;
import com.tryouts.courierapplication.presenters.CurrentOrderPresenter;
import com.tryouts.courierapplication.R;

    private CurrentOrderPresenter mPresenter;

    public CurrentOrderFragment() {
    }

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

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mSharedPreferences = this.getActivity().getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
        orderTimeStamp = mSharedPreferences.getString(PREFERENCES_TEXT_FIELD, PREFERENCES_EMPTY);

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

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        mDateTextView = (TextView) view.findViewById(R.id.progress_body_date);
        mFromTextView = (TextView) view.findViewById(R.id.progress_body_from_txt);
        mToTextView = (TextView) view.findViewById(R.id.progress_body_to_txt);
        mDistanceTextView = (TextView) view.findViewById(R.id.progress_body_distance);
        mPhoneTextView = (TextView) view.findViewById(R.id.progress_body_phone_txt);
        mFirstAdditionalServiceTextView = (CheckedTextView) view.findViewById(R.id.progress_check_1);
        mSecondAdditionalServiceTextView = (CheckedTextView) view.findViewById(R.id.progress_check_2);
        mThirdAdditionalServiceTextView = (CheckedTextView) view.findViewById(R.id.progress_check_3);

        mPresenter = new CurrentOrderPresenter(this);