ViewDetailsDialog.java
3.68 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.wd.common.dialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.wd.foundation.wdkit.viewclick.BaseClickListener;
import com.wd.fastcoding.base.R;
import com.wd.foundation.bean.utils.TimeUtil;
/**
* 详情对话框
*
* @author lvjinhui
*/
public class ViewDetailsDialog extends Dialog {
// 作者
private final String authorName;
// 标题
private final String newsTitle;
// 描述
private final String newIntroduction;
/**
* 时间
*/
private String time;
public ViewDetailsDialog(@NonNull Context context, String authorName, String newsTitle,
String newIntroduction, String time) {
super(context, R.style.DialogBackgroundNull);
this.authorName = authorName;
this.newsTitle = newsTitle;
this.newIntroduction = newIntroduction;
this.time = time;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_short_video_describe);
initOption();
initView();
}
private void initOption() {
Window window = getWindow();
if (window != null) {
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
window.setDimAmount(0);
window.setBackgroundDrawableResource(android.R.color.transparent);
}
}
private void initView() {
TextView tv_author = findViewById(R.id.tv_author);
TextView tv_title = findViewById(R.id.tv_title);
TextView tv_description = findViewById(R.id.tv_description);
TextView timeTv = findViewById(R.id.tv_time);
ImageView iv_close = findViewById(R.id.iv_close);
ConstraintLayout clEmptyArea = findViewById(R.id.clEmptyArea);
if (!TextUtils.isEmpty(authorName)) {
if (tv_author != null) {
tv_author.setText(authorName);
}
}
if (!TextUtils.isEmpty(newsTitle)) {
if (tv_title != null) {
tv_title.setText(newsTitle);
}
}
if (!TextUtils.isEmpty(newIntroduction)) {
if (tv_description != null) {
tv_description.setVisibility(View.VISIBLE);
tv_description.setText(newIntroduction);
}
}else {
if (tv_description != null) {
tv_description.setVisibility(View.GONE);
}
}
//设置时间
if (TextUtils.isEmpty(time)) {
timeTv.setVisibility(View.GONE);
}else {
timeTv.setVisibility(View.VISIBLE);
//不需要走统一规则,目前接口返回的就是具体时间格式
//yyyy-MM-dd HH:mm:ss ----> yyyy-MM-dd HH:mm
time = TimeUtil.transFormTime3(time);
timeTv.setText(time);
}
if (iv_close != null) {
iv_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
if (clEmptyArea != null){
clEmptyArea.setOnClickListener(new BaseClickListener() {
@Override
protected void onNoDoubleClick(View v) {
dismiss();
}
});
}
}
}