admin
2022-08-09 399ac289f80b7a40aa4210341db6b447cacdcf14
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
package com.tejia.lijin.app.ui.dialog;
 
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
 
import com.wpc.library.util.SystemCommon;
import com.wpc.library.util.common.StringUtils;
import com.wpc.library.widget.ResizableImageView;
import com.tejia.lijin.app.R;
import com.tejia.lijin.app.util.Constant;
 
/**
 * Created by weikou2015 on 2017/2/28.
 */
 
public class JumpTaoBaoDialog extends Dialog {
    public JumpTaoBaoDialog(Context context) {
        super(context);
        this.setCancelable(false);
    }
 
 
    public JumpTaoBaoDialog(Context context, int theme) {
        super(context, theme);
        this.setCancelable(false);
    }
 
    public static class Builder {
        private Context context;
        String message;
        int platform;
 
        public Builder(Context context) {
            this.context = context;
        }
 
        public Builder setMessage(String message) {
            this.message = message;
            return this;
        }
 
        public Builder setPlatform(int platform) {
            this.platform = platform;
            return this;
        }
 
        public JumpTaoBaoDialog create() {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            // instantiate the dialog with the custom Theme
            final JumpTaoBaoDialog dialog = new JumpTaoBaoDialog(context, R.style.Dialog);
            View layout = inflater.inflate(R.layout.item_jump_taobao, null);
            TextView tv_jump_platform_top = layout.findViewById(R.id.tv_platform_name);
 
            switch (platform) {
                case Constant.GOODS_TYPE_TB:
                    tv_jump_platform_top.setText("正在前往淘宝");
                    break;
                case Constant.GOODS_TYPE_JD:
                    tv_jump_platform_top.setText("正在前往京东");
                    break;
                case Constant.GOODS_TYPE_PDD:
                    tv_jump_platform_top.setText("正在前往拼多多");
                    break;
                case Constant.GOODS_TYPE_VIP:
                    tv_jump_platform_top.setText("正在前往唯品会");
                    break;
                case Constant.GOODS_TYPE_SUNING:
                    tv_jump_platform_top.setText("正在前往苏宁");
                    break;
            }
 
            ResizableImageView iv_waiting = layout.findViewById(R.id.iv_waiting);
            TextView tv_hint = layout.findViewById(R.id.tv_hint);
            AnimationDrawable animationDrawable = (AnimationDrawable) context.getResources().getDrawable(
                    R.drawable.anim_input_taobao);
            iv_waiting.setImageDrawable(animationDrawable);
            ((AnimationDrawable) (iv_waiting.getDrawable())).start();
//            if (!StringUtils.isEmpty(message))
//                tv_hint.setText(message);
            tv_hint.setText("");
 
            dialog.addContentView(layout, new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
            // set the confirm button
            dialog.setContentView(layout);
 
            android.view.WindowManager.LayoutParams params = dialog.getWindow()
                    .getAttributes();
            params.width = (int) ((SystemCommon.getScreenWidth(context) * 3) / 4);
            params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
            dialog.getWindow().setAttributes(params);
            dialog.setCanceledOnTouchOutside(false);
            return dialog;
        }
    }
}