87 lines
2.8 KiB
Java
87 lines
2.8 KiB
Java
package com.xscm.modulemain.dialog;
|
|
|
|
import android.app.Dialog;
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.view.Gravity;
|
|
import android.view.Window;
|
|
import android.widget.CompoundButton;
|
|
import android.widget.Switch;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import com.xscm.modulemain.R;
|
|
|
|
/**
|
|
*@author qx
|
|
*@data 2025/7/3
|
|
*@description: 直播对战设置
|
|
*/
|
|
public class LiveBattleSettingsDialog extends Dialog {
|
|
|
|
private Switch switchFriendInvitation;
|
|
private Switch switchRecommendInvitation;
|
|
private OnSettingsChangeListener listener;
|
|
private int is_pk;
|
|
|
|
public LiveBattleSettingsDialog(@NonNull Context context,int is_pk, OnSettingsChangeListener listener) {
|
|
super(context);
|
|
this.listener = listener;
|
|
this.is_pk = is_pk;
|
|
}
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏标题栏
|
|
setContentView(R.layout.dialog_live_battle_settings);
|
|
|
|
// 初始化视图
|
|
switchFriendInvitation = findViewById(R.id.switch_friend_invitation);
|
|
switchRecommendInvitation = findViewById(R.id.switch_recommend_invitation);
|
|
|
|
// 设置初始状态(根据需要)
|
|
switchFriendInvitation.setChecked(false);
|
|
switchRecommendInvitation.setChecked(false);
|
|
|
|
if (is_pk==2){
|
|
switchFriendInvitation.setChecked(true);
|
|
}else {
|
|
switchFriendInvitation.setChecked(false);
|
|
}
|
|
// 添加开关监听器
|
|
switchFriendInvitation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
@Override
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
if (listener != null) {
|
|
listener.onFriendInvitationChanged(isChecked);
|
|
}
|
|
}
|
|
});
|
|
|
|
switchRecommendInvitation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
@Override
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
if (listener != null) {
|
|
listener.onRecommendInvitationChanged(isChecked);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
public void show() {
|
|
Window window = getWindow();
|
|
if (window != null) {
|
|
window.setGravity(Gravity.CENTER); // 居中显示
|
|
window.setBackgroundDrawableResource(com.xscm.moduleutil.R.drawable.bg_r16_fff); // 透明背景
|
|
}
|
|
super.show();
|
|
}
|
|
|
|
public interface OnSettingsChangeListener {
|
|
void onFriendInvitationChanged(boolean isChecked);
|
|
void onRecommendInvitationChanged(boolean isChecked);
|
|
}
|
|
}
|