CommandDialog.java
3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.wd.common.dialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.airbnb.lottie.LottieAnimationView;
import com.wd.common.constant.UrlConstants;
import com.wd.foundation.wdkit.utils.PDUtils;
import com.wd.common.utils.ProcessUtils;
import com.wd.fastcoding.base.R;
import com.wd.foundation.bean.custom.content.ContentBean;
import com.wd.foundation.wdkit.utils.AnimUtil;
/**
* @author ypf
* @version [V1.0.0, 2023/11/20]
* @description 口令弹窗
* @since V1.0.0
*/
public class CommandDialog extends Dialog {
private final String message;
public CommandDialog(Context context, String message) {
super(context, R.style.CenterDialogStyle);
this.message = message;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_command);
initOption();
initView();
}
private void initOption() {
// 弹窗位置
Window window = getWindow();
WindowManager.LayoutParams params = window.getAttributes();
// dialog显示位置
window.setGravity(Gravity.TOP);
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.MATCH_PARENT;
getWindow().setAttributes(params);
// 可以关闭弹窗
setCancelable(true);
setCanceledOnTouchOutside(true);
}
private void initView() {
ConstraintLayout clRoot = findViewById(R.id.clRoot);
// 金币动画
LottieAnimationView lavLogo = findViewById(R.id.lavLogo);
AnimUtil.showLocalLottieEffects(lavLogo,"coin_action.json", true);
// 标题
TextView tvContent = findViewById(R.id.tvContent);
ImageView ivClose = findViewById(R.id.ivClose);
if (message!=null) {
tvContent.setText(message);
}
// 按钮
TextView tvGo = findViewById(R.id.tvGo);
if (PDUtils.isLogin()){
tvGo.setText("去邀请");
}else {
tvGo.setText("去登录");
}
ConstraintLayout clBottom = findViewById(R.id.clBottom);
clRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
// 去邀请 去登录
clBottom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (PDUtils.isLogin()){
//邀请好友,跳转进入邀请好友主页
ProcessUtils.goToH5Page(new ContentBean(UrlConstants.getInviteFriendsUrl()));
dismiss();
}else {
dismiss();
ProcessUtils.toOneKeyLoginActivity();
}
}
});
ivClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
}