package com.fusi24.rfid;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

import androidx.appcompat.app.AppCompatActivity;

import com.fusi24.rfid.data.model.DataCommon;
import com.fusi24.rfid.ui.ScanActivity;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.btn_scan)
    Button btnScan;
    @BindView(R.id.spinner_site)
    Spinner spinnerSite;
    @BindView(R.id.spinner_permit)
    Spinner spinnerPermit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        setDataSite();
        setDataPermit();

        initEvent();
    }

    private void initEvent(){
        btnScan.setOnClickListener(v -> {
            Intent intent = new Intent(this, ScanActivity.class);
            startActivity(intent);
        });
    }

    private void setDataSite(){
        ArrayList<DataCommon> siteList = new ArrayList<>();

        siteList.add(new DataCommon(111, "HO"));
        siteList.add(new DataCommon(112, "BMO 1"));
        siteList.add(new DataCommon(113, "BMO 2"));
        siteList.add(new DataCommon(114, "LMO"));
        siteList.add(new DataCommon(115, "SMO"));
        siteList.add(new DataCommon(116, "MARINE"));
        siteList.add(new DataCommon(117, "EKSPLORASI"));
        siteList.add(new DataCommon(118, "JAKARTA"));

        ArrayAdapter<DataCommon> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, siteList);
        spinnerSite.setAdapter(adapter);
    }

    private void setDataPermit(){
        ArrayList<DataCommon> permitList = new ArrayList<>();

        permitList.add(new DataCommon(1, "ID CARD"));
        permitList.add(new DataCommon(2, "VISITOR"));
        permitList.add(new DataCommon(3, "MAGANG"));

        ArrayAdapter<DataCommon> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, permitList);
        spinnerPermit.setAdapter(adapter);
    }

}
