PromptDialog.java
3.07 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
package com.cnlive.goldenline.ui.widget;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.cnlive.goldenline.R;
/**
* <br/> ****************************************************
* <br/> Project Name : goldenline-android3.0
* <br/> Create Date : 2017/3/18 0018
* <br/> Author : MaChao
* <br/> Msg :
* <br/> Remark :
* <br/> ****************************************************
*/
public class PromptDialog extends Dialog implements View.OnClickListener {
private Context mContext;
private ClickListener listener;
private TextView mVoteResult;
private TextView mVoteInfo;
private ImageButton mBtnRoger;
private LinearLayout mPromptLayout;
private boolean isVoteSuccess;
private String mVoteInfoStr;
public PromptDialog(Context context) {
super(context);
this.mContext = context;
}
public PromptDialog(Context context, int themeResId) {
super(context, themeResId);
this.mContext = context;
}
protected PromptDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
this.mContext = context;
}
public interface ClickListener {
void onOk();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_dialog_prompt);
initView();
if (isVoteSuccess){
voteSuccessView();
}else {
voteFailerView(mVoteInfoStr);
}
}
private void voteFailerView(String voteInfo) {
mPromptLayout.setBackgroundResource(R.mipmap.vote_failer);
mVoteResult.setText(mContext.getResources().getString(R.string.vote_failer));
mVoteInfo.setText(voteInfo);
}
private void voteSuccessView() {
mPromptLayout.setBackgroundResource(R.mipmap.vote_success);
mVoteResult.setText(mContext.getResources().getString(R.string.vote_success));
mVoteInfo.setText(mContext.getResources().getString(R.string.vote_success_info));
}
private void initView() {
mVoteResult = (TextView) findViewById(R.id.act_vote_result);
mVoteInfo = (TextView) findViewById(R.id.act_vote_info);
mBtnRoger = (ImageButton) findViewById(R.id.btn_roger);
mPromptLayout = (LinearLayout) findViewById(R.id.prompt_layput);
mBtnRoger.setOnClickListener(this);
}
public void setVoteStatus(boolean isVoteSuccess,String voteInfo) {
this.isVoteSuccess = isVoteSuccess;
this.mVoteInfoStr = voteInfo;
}
public void setClickListener(ClickListener listener) {
this.listener = listener;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_roger:
if (listener != null)
listener.onOk();
break;
}
dismiss();
}
}