package jp.gihyo.mitoma.android.lesson2301sqlite;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButtonClick onClick = new ButtonClick();
        Button btReg = findViewById(R.id.btRegist);
        btReg.setOnClickListener(onClick);
        Button btEnq = findViewById(R.id.btEnquiry);
        btEnq.setOnClickListener(onClick);
        Button btUpd = findViewById(R.id.btUpdate);
        btUpd.setOnClickListener(onClick);
        Button btDel = findViewById(R.id.btDelete);
        btDel.setOnClickListener(onClick);
        /* *****テストデータ設定*************/
        FriendsProvDAO dao = new FriendsProvDAO(this);
        FriendsDTO dto;
        dto = new FriendsDTO(0,"佐藤太郎","090-1234-X000","特になし");
        dao.insert(dto);
        dto = new FriendsDTO(0,"鈴木陽介","090-2345-9Y76","特になし");
        dao.insert(dto);
        dto = new FriendsDTO(0,"高橋健一","070-1985-Z567","特になし");
        dao.insert(dto);
    }
    private class ButtonClick implements View.OnClickListener{
        public void onClick(View view){
            FriendsAction action = new FriendsAction(MainActivity.this);
            //view.setTag("AAAA");
            action.exec(view);
        }
    }
}