package in.techware.carrefour.activity.merchandise;

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

import in.techware.carrefour.R;
import in.techware.carrefour.activity.FileTransferActivity;
import in.techware.carrefour.util.AppConstants;

public class ItemListActivity extends AppCompatActivity implements View.OnClickListener {

    Button mBuackButton;
    Button mModifyButton;
    EditText barcodeEditText;
    EditText qtyEditText;

    String selectedSubMenu;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_item_list2);
        if (getIntent() != null && getIntent().getStringExtra("submenu") != null){
            selectedSubMenu = getIntent().getStringExtra("submenu");
        }
        mBuackButton = findViewById(R.id.btn_back);
        mModifyButton = findViewById(R.id.btn_modify);
        barcodeEditText = findViewById(R.id.etxt_barcode);
        qtyEditText = findViewById(R.id.etxt_waste_quantity);
        mBuackButton.setOnClickListener(this);
        mModifyButton.setOnClickListener(this);

        handleKeyboard();
    }

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

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_back:
                finish();
                break;

            case R.id.btn_modify:
                Intent intent = new Intent(getApplicationContext(), FileTransferActivity.class);
                intent.putExtra("submenu", selectedSubMenu);
                startActivity(intent);
                break;
        }
    }
}
