Settingボタン処理
1 parent bde1a47 commit 35f2fe3e37ecf377eeab92805b4abe9ebf7417cc
k-iwamoto authored on 1 Nov 2022
Showing 2 changed files
View
77
app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java
@SuppressLint("UseSwitchCompatOrMaterialCode")
Switch dTimer = findViewById(R.id.dTimer);
@SuppressLint("UseSwitchCompatOrMaterialCode")
Switch gTimer = findViewById(R.id.gTimer);
Switch switch4 = findViewById(R.id.switch4);
Switch switch5 = findViewById(R.id.switch5);
Switch switch6 = findViewById(R.id.switch6);
Switch switch7 = findViewById(R.id.switch7);
Switch switch8 = findViewById(R.id.switch8);
Switch switch9 = findViewById(R.id.switch9);
 
 
//OwnerRoom専用ボタン
Button randomButton = (Button) findViewById(R.id.random);
Button startButton = (Button) findViewById(R.id.start);
//設定ボタン
dTimer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
 
drawingTimer = isChecked;
if(drawingTimer == false){
switch4.setVisibility(View.GONE);
switch5.setVisibility(View.GONE);
switch6.setVisibility(View.GONE);
}else {
switch4.setVisibility(View.VISIBLE);
switch5.setVisibility(View.VISIBLE);
switch6.setVisibility(View.VISIBLE);
}
 
roomViewModel.changeSettings(roomId, drawingTimer, drawingTimes, gameTimer, gameTimes, gameFirstTimes);
}
});
 
switch4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch5.setChecked(false);
switch6.setChecked(false);
}
});
 
switch5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch4.setChecked(false);
switch6.setChecked(false);
}
});
 
switch6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch4.setChecked(false);
switch5.setChecked(false);
}
});
 
 
gTimer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
 
gameTimer = isChecked;
if(gameTimer == false){
switch7.setVisibility(View.GONE);
switch8.setVisibility(View.GONE);
switch9.setVisibility(View.GONE);
}else {
switch7.setVisibility(View.VISIBLE);
switch8.setVisibility(View.VISIBLE);
switch9.setVisibility(View.VISIBLE);
}
roomViewModel.changeSettings(roomId, drawingTimer, drawingTimes, gameTimer, gameTimes, gameFirstTimes);
}
});
 
switch7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch8.setChecked(false);
switch9.setChecked(false);
}
});
 
switch8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch7.setChecked(false);
switch9.setChecked(false);
}
});
 
switch9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch7.setChecked(false);
switch8.setChecked(false);
}
});
 
//ランダムボタン
View
22
app/src/main/res/layout/activity_owner_room.xml
<Switch
android:id="@+id/switch7"
android:layout_width="73dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:text="60s"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/beBlueMaster"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.762"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.697" />
 
<Switch
android:layout_height="25dp"
android:text="90s"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.011"
app:layout_constraintStart_toEndOf="@+id/switch4"
app:layout_constraintHorizontal_bias="0.871"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.697" />
 
<Switch
android:layout_height="22dp"
android:text="120s"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.066"
app:layout_constraintStart_toEndOf="@+id/switch5"
app:layout_constraintHorizontal_bias="0.989"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.697" />
 
<ImageButton
<Switch
android:id="@+id/switch4"
android:layout_width="73dp"
android:layout_height="25dp"
android:layout_marginStart="20dp"
android:text="20s"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/beRedSpy"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.759"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.45" />
 
<Switch