Pārlūkot izejas kodu

电价详情开发

huyuguo 4 gadi atpakaļ
vecāks
revīzija
d820aac519

+ 3 - 1
app/src/main/java/com/electric/chargingpile/activity/MainMapActivity.java

5229
        final String poi_wei = JsonUtils.getKeyResult(info, "poi_wei");
5229
        final String poi_wei = JsonUtils.getKeyResult(info, "poi_wei");
5230
        final String fenshi_is = JsonUtils.getKeyResult(info, "fenshi_is");
5230
        final String fenshi_is = JsonUtils.getKeyResult(info, "fenshi_is");
5231
5231
5232
        TextView fenshi_info_textview = findViewById(R.id.fenshi_info_textview);
5232
        if ("1".equals(fenshi_is)) {
5233
        if ("1".equals(fenshi_is)) {
5233
            final String fenshi_info = JsonUtils.getKeyResult(info, "fenshi_info");
5234
            final String fenshi_info = JsonUtils.getKeyResult(info, "fenshi_info");
5234
            ArrayList<PileData.FenshiInfoBean> fenshiList = (ArrayList<PileData.FenshiInfoBean>) JsonUtils.parseToObjectList(fenshi_info, PileData.FenshiInfoBean.class);
5235
            ArrayList<PileData.FenshiInfoBean> fenshiList = (ArrayList<PileData.FenshiInfoBean>) JsonUtils.parseToObjectList(fenshi_info, PileData.FenshiInfoBean.class);
5237
            int minutes = calendar.get(Calendar.MINUTE);
5238
            int minutes = calendar.get(Calendar.MINUTE);
5238
            int totalMinutes = hours * 60 + minutes;
5239
            int totalMinutes = hours * 60 + minutes;
5239
5240
5240
            TextView fenshi_info_textview = findViewById(R.id.fenshi_info_textview);
5241
            for (PileData.FenshiInfoBean bean : fenshiList) {
5241
            for (PileData.FenshiInfoBean bean : fenshiList) {
5242
                if (bean.getStartTotalMinutes() > totalMinutes) {
5242
                if (bean.getStartTotalMinutes() > totalMinutes) {
5243
                    Double service_free = Double.valueOf(bean.getService_free());
5243
                    Double service_free = Double.valueOf(bean.getService_free());
5246
                    break;
5246
                    break;
5247
                }
5247
                }
5248
            }
5248
            }
5249
        } else {
5250
            fenshi_info_textview.setText("");
5249
        }
5251
        }
5250
5252
5251
        // remind 0 正常 2 休息中 other 故障
5253
        // remind 0 正常 2 休息中 other 故障

+ 41 - 18
app/src/main/java/com/electric/chargingpile/activity/PriceDetailsActivity.java

8
import android.widget.TextView;
8
import android.widget.TextView;
9
9
10
import com.electric.chargingpile.R;
10
import com.electric.chargingpile.R;
11
import com.electric.chargingpile.data.PileData;
11
import com.electric.chargingpile.fragment.DetailsFragment;
12
import com.electric.chargingpile.fragment.DetailsFragment;
12
import com.electric.chargingpile.util.BarColorUtil;
13
import com.electric.chargingpile.util.BarColorUtil;
14
import com.electric.chargingpile.util.JsonUtils;
13
15
14
import org.json.JSONException;
16
import org.json.JSONException;
17
import org.json.JSONObject;
15
18
16
import java.math.BigDecimal;
19
import java.math.BigDecimal;
20
import java.util.ArrayList;
21
import java.util.Arrays;
17
22
18
public class PriceDetailsActivity extends Activity implements View.OnClickListener {
23
public class PriceDetailsActivity extends Activity implements View.OnClickListener {
19
    private LinearLayout ll_details;
24
    private LinearLayout ll_details;
43
    }
48
    }
44
49
45
    private void addView() throws JSONException {
50
    private void addView() throws JSONException {
46
        for (int i = 0; i < DetailsFragment.datas.size(); i++) {
51
        ArrayList<PileData.FenshiInfoBean> beans = new ArrayList<PileData.FenshiInfoBean>();
52
53
        int index = 0;
54
        for (JSONObject obj : DetailsFragment.datas) {
55
            PileData.FenshiInfoBean bean = JsonUtils.parseToObjectBean(obj.toString(), PileData.FenshiInfoBean.class);
56
            bean.index = index;
57
            beans.add(bean);
58
            index++;
59
        }
60
61
        Arrays.sort(beans, (o1, o2) -> {
62
            PileData.FenshiInfoBean b1 = (PileData.FenshiInfoBean) o1;
63
            PileData.FenshiInfoBean b2 = (PileData.FenshiInfoBean) o2;
64
            if (b1.getTotalPrice() > b2.getTotalPrice()) {
65
                return 1;
66
            } else if (b1.getTotalPrice() < b2.getTotalPrice()) {
67
                return -1;
68
            } else {
69
                return 0;
70
            }
71
        });
72
73
        int i = 0;
74
        for (PileData.FenshiInfoBean bean : beans) {
47
            View itemView = getLayoutInflater().inflate(R.layout.item_details_list, null);
75
            View itemView = getLayoutInflater().inflate(R.layout.item_details_list, null);
48
            TextView item_time = (TextView) itemView.findViewById(R.id.tv_time);
49
            TextView item_shiji = (TextView) itemView.findViewById(R.id.tv_shiji);
50
            TextView item_fuwul = (TextView) itemView.findViewById(R.id.tv_fuwu);
51
            TextView item_danjia = (TextView) itemView.findViewById(R.id.tv_danjia);
52
            String start = DetailsFragment.datas.get(i).getString("start");
53
            String end = DetailsFragment.datas.get(i).getString("end");
54
            String service_free = DetailsFragment.datas.get(i).getString("service_free");
55
            String charge_free = DetailsFragment.datas.get(i).getString("charge_free");
56
57
            item_time.setText(start + "-" + end);
58
59
            item_fuwul.setText(service_free);
60
            item_danjia.setText(charge_free);
61
            double c = Double.parseDouble(charge_free) + Double.parseDouble(service_free);
62
            BigDecimal bd = new BigDecimal(c);
63
            double d = bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
64
            item_shiji.setText(d + "");
76
            TextView time = (TextView) itemView.findViewById(R.id.time);
77
            TextView total_price = (TextView) itemView.findViewById(R.id.total_price);
78
            TextView price = (TextView) itemView.findViewById(R.id.price);
79
80
            time.setText(bean.getStart() + "-" + bean.getEnd());
65
81
82
            price.setText("电费:" + bean.getCharge_free() + "元/度  服务费:" + bean.getService_free() + "元/度");
83
84
            double c = Double.parseDouble(bean.getCharge_free()) + Double.parseDouble(bean.getService_free());
85
            BigDecimal bd = new BigDecimal(c);
86
            double d = bd.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
87
            total_price.setText(d + "");
66
88
67
            ll_details.addView(itemView, i);
89
            ll_details.addView(itemView, i);
90
            i++;
68
        }
91
        }
69
    }
92
    }
70
93

+ 4 - 1
app/src/main/java/com/electric/chargingpile/data/PileData.java

213
         * service_free : 0.8
213
         * service_free : 0.8
214
         * charge_free : 1.39
214
         * charge_free : 1.39
215
         */
215
         */
216
216
        public int index;
217
        private String start;
217
        private String start;
218
        private String end;
218
        private String end;
219
        private String service_free;
219
        private String service_free;
251
            this.charge_free = charge_free;
251
            this.charge_free = charge_free;
252
        }
252
        }
253
253
254
        public double getTotalPrice() {
255
            return Double.parseDouble(getCharge_free()) + Double.parseDouble(getService_free());
256
        }
254
        public int getStartTotalMinutes() {
257
        public int getStartTotalMinutes() {
255
            String[] times = start.split(":");
258
            String[] times = start.split(":");
256
            if (times.length == 2) {
259
            if (times.length == 2) {

BIN
app/src/main/res/drawable-hdpi/price_feng.png


BIN
app/src/main/res/drawable-hdpi/price_gu.png


BIN
app/src/main/res/drawable-hdpi/price_ping.png


BIN
app/src/main/res/drawable-mdpi/price_feng.png


BIN
app/src/main/res/drawable-mdpi/price_gu.png


BIN
app/src/main/res/drawable-mdpi/price_ping.png


BIN
app/src/main/res/drawable-xhdpi/price_feng.png


BIN
app/src/main/res/drawable-xhdpi/price_gu.png


BIN
app/src/main/res/drawable-xhdpi/price_ping.png


BIN
app/src/main/res/drawable-xxhdpi/price_feng.png


BIN
app/src/main/res/drawable-xxhdpi/price_gu.png


BIN
app/src/main/res/drawable-xxhdpi/price_ping.png


BIN
app/src/main/res/drawable-xxxhdpi/price_feng.png


BIN
app/src/main/res/drawable-xxxhdpi/price_gu.png


BIN
app/src/main/res/drawable-xxxhdpi/price_ping.png


+ 9 - 156
app/src/main/res/layout/activity_price_details.xml

11
        android:id="@+id/rl_title"
11
        android:id="@+id/rl_title"
12
        android:layout_width="match_parent"
12
        android:layout_width="match_parent"
13
        android:layout_height="44dp"
13
        android:layout_height="44dp"
14
        android:layout_alignParentLeft="true"
15
        android:layout_alignParentStart="true"
14
        android:layout_alignParentStart="true"
15
        android:layout_alignParentLeft="true"
16
        android:layout_alignParentTop="true"
16
        android:layout_alignParentTop="true"
17
        android:background="@color/white">
17
        android:background="@color/white">
18
18
38
        <View
38
        <View
39
            android:layout_width="match_parent"
39
            android:layout_width="match_parent"
40
            android:layout_height="0.5dp"
40
            android:layout_height="0.5dp"
41
            android:background="@color/ui_6d"
42
            android:layout_alignParentBottom="true"/>
41
            android:layout_alignParentBottom="true"
42
            android:background="@color/ui_6d" />
43
43
44
    </RelativeLayout>
44
    </RelativeLayout>
45
45
51
        <LinearLayout
51
        <LinearLayout
52
            android:layout_width="match_parent"
52
            android:layout_width="match_parent"
53
            android:layout_height="match_parent"
53
            android:layout_height="match_parent"
54
55
            android:orientation="vertical">
54
            android:orientation="vertical">
56
55
57
            <View
58
                android:layout_width="match_parent"
59
                android:layout_height="0.5dp"
60
                android:background="@color/ui_6d"
61
                android:layout_marginTop="15dp"
62
                android:layout_marginLeft="15dp"
63
                android:layout_marginRight="15dp" />
64
65
            <LinearLayout
66
                android:layout_width="match_parent"
67
                android:layout_height="58dp"
68
                android:layout_marginLeft="15dp"
69
                android:layout_marginRight="15dp"
70
                android:orientation="horizontal">
71
72
                <RelativeLayout
73
                    android:layout_width="0dp"
74
                    android:layout_height="match_parent"
75
                    android:layout_weight="1.5">
76
77
                    <TextView
78
                        android:layout_width="wrap_content"
79
                        android:layout_height="wrap_content"
80
                        android:textSize="14sp"
81
                        android:textColor="@color/ui_62"
82
                        android:text="时段"
83
                        android:layout_centerInParent="true" />
84
85
                </RelativeLayout>
86
87
                <RelativeLayout
88
                    android:layout_width="0dp"
89
                    android:layout_height="match_parent"
90
                    android:layout_weight="1">
91
92
                    <LinearLayout
93
                        android:layout_width="wrap_content"
94
                        android:layout_height="wrap_content"
95
                        android:layout_centerInParent="true"
96
                        android:gravity="center"
97
                        android:orientation="vertical">
98
99
                        <TextView
100
                            android:layout_width="wrap_content"
101
                            android:layout_height="wrap_content"
102
                            android:textSize="14sp"
103
                            android:textColor="@color/ui_62"
104
                            android:gravity="center_horizontal"
105
                            android:text="充电单价" />
106
107
                        <TextView
108
                            android:layout_width="wrap_content"
109
                            android:layout_height="wrap_content"
110
                            android:textSize="11sp"
111
                            android:textColor="@color/ui_62"
112
                            android:gravity="center_horizontal"
113
                            android:text="(元/度)" />
114
115
                    </LinearLayout>
116
117
118
119
                </RelativeLayout>
120
121
                <RelativeLayout
122
                    android:layout_width="0dp"
123
                    android:layout_height="match_parent"
124
                    android:layout_weight="1">
125
126
                    <LinearLayout
127
                        android:layout_width="wrap_content"
128
                        android:layout_height="wrap_content"
129
                        android:layout_centerInParent="true"
130
                        android:gravity="center"
131
                        android:orientation="vertical">
132
133
                        <TextView
134
                            android:layout_width="wrap_content"
135
                            android:layout_height="wrap_content"
136
                            android:textSize="14sp"
137
                            android:textColor="@color/ui_62"
138
                            android:gravity="center_horizontal"
139
                            android:text="服务费" />
140
141
                        <TextView
142
                            android:layout_width="wrap_content"
143
                            android:layout_height="wrap_content"
144
                            android:textSize="11sp"
145
                            android:textColor="@color/ui_62"
146
                            android:gravity="center_horizontal"
147
                            android:text="(元/度)" />
148
149
                    </LinearLayout>
150
151
                </RelativeLayout>
152
153
                <RelativeLayout
154
                    android:layout_width="0dp"
155
                    android:layout_height="match_parent"
156
                    android:layout_weight="1">
157
158
                    <LinearLayout
159
                        android:layout_width="wrap_content"
160
                        android:layout_height="wrap_content"
161
                        android:layout_centerInParent="true"
162
                        android:gravity="center"
163
                        android:orientation="vertical">
164
165
                        <TextView
166
                            android:layout_width="wrap_content"
167
                            android:layout_height="wrap_content"
168
                            android:textSize="14sp"
169
                            android:textColor="@color/ui_62"
170
                            android:gravity="center_horizontal"
171
                            android:text="实际费用" />
172
173
                        <TextView
174
                            android:layout_width="wrap_content"
175
                            android:layout_height="wrap_content"
176
                            android:textSize="11sp"
177
                            android:textColor="@color/ui_62"
178
                            android:gravity="center_horizontal"
179
                            android:text="(元/度)" />
180
181
                    </LinearLayout>
182
183
                </RelativeLayout>
184
185
            </LinearLayout>
186
187
            <View
188
                android:layout_width="match_parent"
189
                android:layout_height="0.5dp"
190
                android:background="@color/ui_6d"
191
                android:layout_marginLeft="15dp"
192
                android:layout_marginRight="15dp" />
193
194
            <LinearLayout
56
            <LinearLayout
195
                android:id="@+id/ll_details"
57
                android:id="@+id/ll_details"
196
                android:layout_width="match_parent"
58
                android:layout_width="match_parent"
197
                android:layout_height="wrap_content"
59
                android:layout_height="wrap_content"
198
                android:paddingTop="10dp"
199
                android:paddingBottom="10dp"
200
                android:layout_marginLeft="15dp"
60
                android:layout_marginLeft="15dp"
201
                android:layout_marginRight="15dp"
61
                android:layout_marginRight="15dp"
202
                android:orientation="vertical">
203
204
            </LinearLayout>
205
206
            <View
207
                android:layout_width="match_parent"
208
                android:layout_height="0.5dp"
209
                android:background="@color/ui_6d"
210
                android:layout_marginLeft="15dp"
211
                android:layout_marginRight="15dp" />
62
                android:orientation="vertical"
63
                android:paddingTop="10dp"
64
                android:paddingBottom="10dp"></LinearLayout>
212
65
213
            <TextView
66
            <TextView
214
                android:layout_width="wrap_content"
67
                android:layout_width="wrap_content"
215
                android:layout_height="wrap_content"
68
                android:layout_height="wrap_content"
216
                android:textSize="12sp"
217
                android:textColor="@color/ui_68"
218
                android:layout_gravity="center_horizontal"
69
                android:layout_gravity="center_horizontal"
219
                android:layout_marginTop="22dp"
70
                android:layout_marginTop="22dp"
220
                android:layout_marginBottom="20dp"
71
                android:layout_marginBottom="20dp"
221
                android:text="充电费用仅供参考,请以充电桩上的费用为准" />
72
                android:text="充电费用仅供参考,请以充电桩上的费用为准"
73
                android:textColor="@color/ui_68"
74
                android:textSize="12sp" />
222
75
223
        </LinearLayout>
76
        </LinearLayout>
224
77

+ 62 - 61
app/src/main/res/layout/item_details_list.xml

1
<?xml version="1.0" encoding="utf-8"?>
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:orientation="horizontal" android:layout_width="match_parent"
4
    android:layout_height="match_parent">
3
    xmlns:tools="http://schemas.android.com/tools"
4
    android:layout_width="match_parent"
5
    android:layout_height="match_parent"
6
    android:orientation="vertical">
5
7
6
    <RelativeLayout
7
        android:layout_width="0dp"
8
        android:layout_height="45dp"
9
        android:layout_weight="1.5">
8
    <LinearLayout
9
        android:layout_width="match_parent"
10
        android:layout_height="wrap_content"
11
        android:orientation="horizontal">
10
12
11
        <TextView
12
            android:id="@+id/tv_time"
13
        <ImageView
14
            android:id="@+id/icon"
13
            android:layout_width="wrap_content"
15
            android:layout_width="wrap_content"
14
            android:layout_height="wrap_content"
16
            android:layout_height="wrap_content"
15
            android:textSize="14sp"
16
            android:textColor="@color/ui_62"
17
            android:layout_centerInParent="true"
18
            android:gravity="center_horizontal"
19
            android:text=""
20
            />
21
        
22
    </RelativeLayout>
17
            android:layout_gravity="center_vertical"
18
            android:layout_marginLeft="15dp"
19
            android:layout_marginRight="24dp"
20
            android:src="@drawable/fast_icon" />
23
21
24
    <RelativeLayout
25
        android:layout_width="0dp"
26
        android:layout_height="45dp"
27
        android:layout_weight="1">
28
29
        <TextView
30
            android:id="@+id/tv_danjia"
31
            android:layout_width="wrap_content"
22
        <LinearLayout
23
            android:layout_width="match_parent"
32
            android:layout_height="wrap_content"
24
            android:layout_height="wrap_content"
33
            android:textSize="14sp"
34
            android:textColor="@color/ui_62"
35
            android:layout_centerInParent="true"
36
            android:gravity="center_horizontal"
37
            android:text="" />
38
39
    </RelativeLayout>
25
            android:orientation="vertical">
40
26
41
    <RelativeLayout
42
        android:layout_width="0dp"
43
        android:layout_height="45dp"
44
        android:layout_weight="1">
27
            <TextView
28
                android:id="@+id/time"
29
                android:layout_width="wrap_content"
30
                android:layout_height="wrap_content"
31
                android:paddingTop="15dp"
32
                android:textColor="#333333"
33
                android:textSize="15sp"
34
                tools:text="00:00-07:00" />
45
35
46
        <TextView
47
            android:id="@+id/tv_fuwu"
48
            android:layout_width="wrap_content"
49
            android:layout_height="wrap_content"
50
            android:textSize="14sp"
51
            android:textColor="@color/ui_62"
52
            android:layout_centerInParent="true"
53
            android:gravity="center_horizontal"
54
            android:text="" />
36
            <LinearLayout
37
                android:layout_width="wrap_content"
38
                android:layout_height="wrap_content"
39
                android:orientation="horizontal"
40
                android:paddingTop="5dp">
55
41
56
    </RelativeLayout>
57
58
    <RelativeLayout
59
        android:layout_width="0dp"
60
        android:layout_height="45dp"
61
        android:layout_weight="1">
62
63
        <TextView
64
            android:id="@+id/tv_shiji"
65
            android:layout_width="wrap_content"
66
            android:layout_height="wrap_content"
67
            android:textSize="14sp"
68
            android:textColor="@color/ui_62"
69
            android:layout_centerInParent="true"
70
            android:gravity="center_horizontal"
71
            android:text="" />
42
                <TextView
43
                    android:id="@+id/total_price"
44
                    android:layout_width="wrap_content"
45
                    android:layout_height="wrap_content"
46
                    android:textColor="#FA6400"
47
                    android:textSize="20sp"
48
                    android:textStyle="bold"
49
                    tools:text="1.1406" />
72
50
73
    </RelativeLayout>
51
                <TextView
52
                    android:layout_width="wrap_content"
53
                    android:layout_height="wrap_content"
54
                    android:paddingLeft="2dp"
55
                    android:text="元/度"
56
                    android:textColor="#FA6400"
57
                    android:textSize="12sp" />
74
58
59
            </LinearLayout>
75
60
61
            <TextView
62
                android:id="@+id/price"
63
                android:layout_width="wrap_content"
64
                android:layout_height="wrap_content"
65
                android:paddingTop="2dp"
66
                android:paddingBottom="15dp"
67
                android:textColor="#999999"
68
                android:textSize="12sp"
69
                tools:text="电费:0.5906元/度 服务费:0.5906元/度" />
70
        </LinearLayout>
71
    </LinearLayout>
76
72
73
    <View
74
        android:layout_width="match_parent"
75
        android:layout_height="0.5dp"
76
        android:layout_marginLeft="12dp"
77
        android:background="#DDDDDD" />
77
</LinearLayout>
78
</LinearLayout>