package in.techware.carrefour.activity.info;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.HapticFeedbackConstants;
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 WeekMovementActivity extends AppCompatActivity  {

    ConfirmationDialog confirmationDialog;
    EditText itemCodeEditText;
    EditText barCodeEditText;
    EditText sellingStockEditText;

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

        initViews();
        handleKeyboard();
    }

    private void initViews() {
        itemCodeEditText = findViewById(R.id.etxt_item_code);
        barCodeEditText = findViewById(R.id.etxt_barcode);
        sellingStockEditText = findViewById(R.id.etxt_selling_stock);

        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)){
            itemCodeEditText.setFocusableInTouchMode(true);
            barCodeEditText.setFocusableInTouchMode(true);
            sellingStockEditText.setFocusableInTouchMode(true);
        }
    }

    public void onMainPageClick(View view){
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
        //mVibrator.vibrate(25);

        Intent intent = new Intent(getApplicationContext(), ProductInfoActivity.class);
        startActivity(intent);
        finish();
    }

    public void onLabelPageClick(View view){
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
        //mVibrator.vibrate(25);

        Intent intent = new Intent(getApplicationContext(), LabelActivity.class);
        startActivity(intent);
        finish();
    }

    public void onOrderPageClick(View view){
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
        //mVibrator.vibrate(25);

        Intent intent = new Intent(getApplicationContext(), OrderInfoActivity.class);
        startActivity(intent);
        finish();
    }

    public void onWeekPageClick(View view){
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
        //mVibrator.vibrate(25);

        Intent intent = new Intent(getApplicationContext(), WeekMovementActivity.class);
        startActivity(intent);
        finish();
    }

    public void onExitClick(View view){
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
        //mVibrator.vibrate(25);

        confirmationDialog.show(R.string.message_do_you_really_want_to_exit);
    }

}
