package ch.pizzalink.android.fragment.createOrder;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ch.pizzalink.android.R;
import ch.pizzalink.android.activity.BaseActivity;
import ch.pizzalink.android.activity.CreateOrderActivity;
import ch.pizzalink.android.adapter.recycler.PaymentMethodsRecyclerAdapter;
import ch.pizzalink.android.api.ApiErrorUtils;
import ch.pizzalink.android.api.ApiService;
import ch.pizzalink.android.api.ResponseObject;
import ch.pizzalink.android.helper.DialogHelper;
import ch.pizzalink.android.helper.SessionHelper;
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
import ch.pizzalink.android.model.PaymentMethodModel;
import ch.pizzalink.android.model.PaymentMethodsResponseModel;
import ch.pizzalink.android.view.PizzalinkEditText;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by cimenmus on 28.10.2017.
 */

public class CreateOrderNoteFragment extends CreateOrderBaseFragment {

    @BindView(R.id.orderNotePizzalinkEditText) PizzalinkEditText orderNotePizzalinkEditText;

    public static final java.lang.String FRAGMENT_NAME = "createOrderNoteFragment";
    private CreateOrderActivity createOrderActivity;

    public CreateOrderNoteFragment() {}

    public static CreateOrderNoteFragment newInstance() {
        return new CreateOrderNoteFragment();
    }

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

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_create_order_note, container, false);
        ButterKnife.bind(this, view);
        initViews();
        return view;
    }

    @OnClick({R.id.previousTextView, R.id.nextTextView})
    protected void onClick(View view){
        switch (view.getId()){
            case R.id.previousTextView:
                createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
                break;
            case R.id.nextTextView:
                createOrderActivity.setOrderNote(orderNotePizzalinkEditText.getText());
                createOrderActivity.onNextClicked(FRAGMENT_NAME);
                break;
        }
    }

    private void initViews(){
        createOrderActivity = (CreateOrderActivity) getActivity();
        if(createOrderActivity.getOrderNote() != null){
            orderNotePizzalinkEditText.setText(createOrderActivity.getOrderNote());
        }
    }
}