Newer
Older
IrisClient / app / src / main / java / org / ntlab / irisclient / TestGameActivity.java
package org.ntlab.irisclient;

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

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class TestGameActivity extends AppCompatActivity {

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

        //上の表示を削除
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }

        //ownerとして参加
        Button ownerButton = findViewById(R.id.ownergame);
        ownerButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                ((Iris) getApplication()).setRid("gametest");
                ((Iris) getApplication()).setNickname("owner");
                Intent intent = new Intent(TestGameActivity.this, GameMemberActivity.class);
                startActivity(intent);
            }
        });

        //member1として参加
        Button mem1Button = findViewById(R.id.member1);
        mem1Button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                ((Iris) getApplication()).setRid("gametest");
                ((Iris) getApplication()).setNickname("member1");
                Intent intent = new Intent(TestGameActivity.this, GameMemberActivity.class);
                startActivity(intent);
            }
        });

        //member2として参加
        Button mem2Button = findViewById(R.id.member2);
        mem2Button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                ((Iris) getApplication()).setRid("gametest");
                ((Iris) getApplication()).setNickname("member2");
                Intent intent = new Intent(TestGameActivity.this, GameMemberActivity.class);
                startActivity(intent);
            }
        });

        //member3として参加
        Button mem3Button = findViewById(R.id.member3);
        mem3Button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                ((Iris) getApplication()).setRid("gametest");
                ((Iris) getApplication()).setNickname("member3");
                Intent intent = new Intent(TestGameActivity.this, GameMemberActivity.class);
                startActivity(intent);
            }
        });

        //backボタン
        Button backButton = findViewById(R.id.fromgame);
        backButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = new Intent(TestGameActivity.this, TestEnterActivity.class);
                startActivity(intent);
            }
        });

    }
}