5
import android.view.Display;
|
|
|
6
|
import android.view.LayoutInflater;
|
|
|
7
|
import android.view.View;
|
|
|
8
|
import android.view.WindowManager;
|
|
|
9
|
import android.widget.FrameLayout;
|
|
|
10
|
import android.widget.LinearLayout;
|
|
|
11
|
import android.widget.RelativeLayout;
|
|
|
12
|
import android.widget.TextView;
|
|
|
13
|
|
|
|
14
|
import com.google.zxing.client.android.R;
|
|
|
15
|
|
|
|
16
|
public class SettleAccountsDialog{
|
|
|
17
|
private Context context;
|
|
|
18
|
private Dialog dialog;
|
|
|
19
|
private Display display;
|
|
|
20
|
private TextView content;
|
|
|
21
|
private TextView cancel;
|
|
|
22
|
private TextView open;
|
|
|
23
|
|
|
|
24
|
public SettleAccountsDialog(Context context) {
|
|
|
25
|
this.context = context;
|
|
|
26
|
WindowManager windowManager = (WindowManager) context
|
|
|
27
|
.getSystemService(Context.WINDOW_SERVICE);
|
|
|
28
|
display = windowManager.getDefaultDisplay();
|
|
|
29
|
}
|
|
|
30
|
public SettleAccountsDialog builder() {
|
|
|
31
|
// 获取Dialog布局
|
|
|
32
|
View view = LayoutInflater.from(context).inflate(
|
|
|
33
|
R.layout.dialog_settle_accounts, null);
|
|
|
34
|
LinearLayout bgNotLogin = view.findViewById(R.id.bgSettleDialog);
|
|
|
35
|
content = view.findViewById(R.id.content);
|
|
|
36
|
cancel = view.findViewById(R.id.cancel);
|
|
|
37
|
open = view.findViewById(R.id.open);
|
|
|
38
|
|
|
|
39
|
// 定义Dialog布局和参数
|
|
|
40
|
dialog = new Dialog(context, R.style.AlertDialogStyle);
|
|
|
41
|
dialog.setContentView(view);
|
|
|
42
|
|
|
|
43
|
// 调整dialog背景大小
|
|
|
44
|
bgNotLogin.setLayoutParams(new FrameLayout.LayoutParams(
|
|
|
45
|
dip2px(context, 268),
|
|
|
46
|
dip2px(context, 124)
|
|
|
47
|
));
|
|
|
48
|
|
|
|
49
|
return this;
|
|
|
50
|
}
|
|
|
51
|
|
|
|
52
|
public SettleAccountsDialog setContentText(String str){
|
|
|
53
|
content.setText(str);
|
|
|
54
|
return this;
|
|
|
55
|
}
|
|
|
56
|
public SettleAccountsDialog setCancelText(String str){
|
|
|
57
|
cancel.setText(str);
|
|
|
58
|
return this;
|
|
|
59
|
}
|
|
|
60
|
public SettleAccountsDialog setOpenText(String str){
|
|
|
61
|
open.setText(str);
|
|
|
62
|
return this;
|
|
|
63
|
}
|
|
|
64
|
|
|
|
65
|
public SettleAccountsDialog setCancelable(boolean cancel) {
|
|
|
66
|
dialog.setCancelable(cancel);
|
|
|
67
|
dialog.setCanceledOnTouchOutside(cancel);
|
|
|
68
|
return this;
|
|
|
69
|
}
|
|
|
70
|
|
|
|
71
|
public SettleAccountsDialog setOpenOnClick(final View.OnClickListener listener){
|
|
|
72
|
if (open!=null){
|
|
|
73
|
open.setOnClickListener(new View.OnClickListener() {
|
|
|
74
|
@Override
|
|
|
75
|
public void onClick(View v) {
|
|
|
76
|
listener.onClick(v);
|
|
|
77
|
dialog.dismiss();
|
|
|
78
|
}
|
|
|
79
|
});
|
|
|
80
|
}
|
|
|
81
|
return this;
|
|
|
82
|
}
|
|
|
83
|
|
|
|
84
|
public SettleAccountsDialog setCancleOnClick(final View.OnClickListener listener){
|
|
|
85
|
if (cancel!=null){
|
|
|
86
|
cancel.setOnClickListener(new View.OnClickListener() {
|
|
|
87
|
@Override
|
|
|
88
|
public void onClick(View v) {
|
|
|
89
|
listener.onClick(v);
|
|
|
90
|
dialog.dismiss();
|
|
|
91
|
}
|
|
|
92
|
});
|
|
|
93
|
}
|
|
|
94
|
|
|
|
95
|
return this;
|
|
|
96
|
}
|
|
|
97
|
|
|
|
98
|
public void show() {
|
|
|
99
|
dialog.show();
|
|
|
100
|
}
|
|
|
101
|
/**
|
|
|
102
|
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
|
|
|
103
|
*/
|
|
|
104
|
public static int dip2px(Context context, float dpValue) {
|
|
|
105
|
final float scale = context.getResources().getDisplayMetrics().density;
|
|
|
106
|
return (int) (dpValue * scale + 0.5f);
|
|
|
107
|
}
|
|
|
108
|
}
|
|
|
@ -0,0 +1,6 @@
|
|
|
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
2
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
|
|
3
|
|
|
|
4
|
<solid android:color="#3EC34C"/>
|
|
|
5
|
<corners android:radius="16dp"/>
|
|
|
6
|
</shape>
|
|
|
@ -0,0 +1,6 @@
|
|
|
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
2
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
|
|
3
|
|
|
|
4
|
<solid android:color="#ECECEC"/>
|
|
|
5
|
<corners android:radius="16dp"/>
|
|
|
6
|
</shape>
|
|
|
@ -0,0 +1,6 @@
|
|
|
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
2
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
|
|
3
|
|
|
|
4
|
<solid android:color="#FFFFFF"/>
|
|
|
5
|
<corners android:radius="16dp"/>
|
|
|
6
|
</shape>
|
|
|
@ -310,6 +310,7 @@
|
|
310
|
310
|
android:visibility="gone"/>
|
|
311
|
311
|
|
|
312
|
312
|
<RelativeLayout
|
|
|
313
|
tools:visibility="visible"
|
|
313
|
314
|
android:id="@+id/rl_costWay"
|
|
314
|
315
|
android:layout_width="240dp"
|
|
315
|
316
|
android:layout_height="32dp"
|
|
|
@ -0,0 +1,60 @@
|
|
|
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
2
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
|
3
|
xmlns:tools="http://schemas.android.com/tools"
|
|
|
4
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
|
5
|
android:orientation="vertical"
|
|
|
6
|
tools:background="#f1f1"
|
|
|
7
|
android:id="@+id/bgSettleDialog"
|
|
|
8
|
android:layout_width="match_parent"
|
|
|
9
|
android:layout_height="match_parent">
|
|
|
10
|
|
|
|
11
|
<RelativeLayout
|
|
|
12
|
android:id="@+id/bg_"
|
|
|
13
|
android:background="@drawable/bg_while_radius16"
|
|
|
14
|
android:layout_gravity="center"
|
|
|
15
|
android:layout_width="268dp"
|
|
|
16
|
android:layout_height="124dp">
|
|
|
17
|
<TextView
|
|
|
18
|
android:id="@+id/content"
|
|
|
19
|
android:layout_alignParentStart="true"
|
|
|
20
|
android:layout_alignParentEnd="true"
|
|
|
21
|
android:layout_alignParentTop="true"
|
|
|
22
|
android:layout_marginStart="15dp"
|
|
|
23
|
android:layout_marginEnd="15sp"
|
|
|
24
|
android:layout_marginTop="16dp"
|
|
|
25
|
android:layout_width="wrap_content"
|
|
|
26
|
android:layout_height="wrap_content"
|
|
|
27
|
android:text="您有一笔未结算的订单,请先结算后
|
|
|
28
|
开启其他订单"
|
|
|
29
|
android:textColor="#ff0e0e0e"
|
|
|
30
|
android:textSize="14sp"
|
|
|
31
|
/>
|
|
|
32
|
<LinearLayout
|
|
|
33
|
android:layout_marginBottom="16dp"
|
|
|
34
|
android:layout_alignParentBottom="true"
|
|
|
35
|
android:gravity="center"
|
|
|
36
|
android:layout_width="match_parent"
|
|
|
37
|
android:layout_height="wrap_content">
|
|
|
38
|
<TextView
|
|
|
39
|
android:textColor="#000000"
|
|
|
40
|
android:layout_marginEnd="16dp"
|
|
|
41
|
android:id="@+id/cancel"
|
|
|
42
|
android:layout_width="110dp"
|
|
|
43
|
android:layout_height="40dp"
|
|
|
44
|
android:background="@drawable/bg_ececec_radius20"
|
|
|
45
|
android:gravity="center"
|
|
|
46
|
android:text="取消"
|
|
|
47
|
android:textSize="17sp" />
|
|
|
48
|
<TextView
|
|
|
49
|
android:textColor="#FFFFFF"
|
|
|
50
|
android:id="@+id/open"
|
|
|
51
|
android:layout_width="110dp"
|
|
|
52
|
android:layout_height="40dp"
|
|
|
53
|
android:background="@drawable/bg_3ec34c_radius20"
|
|
|
54
|
android:gravity="center"
|
|
|
55
|
android:text="去结算"
|
|
|
56
|
android:textSize="17sp" />
|
|
|
57
|
</LinearLayout>
|
|
|
58
|
</RelativeLayout>
|
|
|
59
|
|
|
|
60
|
</LinearLayout>
|