package in.techware.carrefour.activity.info;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import in.techware.carrefour.dialogs.ConfirmationDialog;
import in.techware.carrefour.R;
import in.techware.carrefour.util.AppConstants;

public class LabelActivity extends AppCompatActivity  {

    ConfirmationDialog confirmationDialog;
    EditText storeEditText;
    EditText barcodeEditText;
    EditText numberEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_label);

        initViews();
        handleKeyboard();
    }

    private void initViews() {
        storeEditText = findViewById(R.id.etxt_store);
        barcodeEditText = findViewById(R.id.etxt_barcode);
        numberEditText = findViewById(R.id.etxt_number);

        confirmationDialog =new ConfirmationDialog(this);
        confirmationDialog.setConfirmationDialogActionListener(new ConfirmationDialog.ConfirmationDialogActionListener() {
            @Override
            public void onYesClicked() {
                finishAffinity();
            }

            @Override
            public void onNoClicked() {

            }
        });
    }

    private void handleKeyboard() {
        if (getSharedPreferences(AppConstants.PREF_FILE, 0).getBoolean(AppConstants.KEYBOARD_STATUS, false)){
            storeEditText.setFocusableInTouchMode(true);
            barcodeEditText.setFocusableInTouchMode(true);
            numberEditText.setFocusableInTouchMode(true);
        }
    }

    public void onMainPageClick(View v){
        Intent intent = new Intent(getApplicationContext(), ProductInfoActivity.class);
        startActivity(intent);
        finish();
    }

    public void onLabelPageClick(View v){
        Intent intent = new Intent(getApplicationContext(), LabelActivity.class);
        startActivity(intent);
        finish();
    }

    public void onOrderPageClick(View v){
        Intent intent = new Intent(getApplicationContext(), OrderInfoActivity.class);
        startActivity(intent);
        finish();
    }

    public void onWeekPageClick(View v){
        Intent intent = new Intent(getApplicationContext(), WeekMovementActivity.class);
        startActivity(intent);
        finish();
    }

    public void onExitClick(View v){
        confirmationDialog.show(R.string.message_do_you_really_want_to_exit);
    }

}
