Ver Código Fonte

启屏广告优化

huyuguo 5 anos atrás
pai
commit
da50298b50

+ 2 - 2
app/src/main/AndroidManifest.xml

1
<?xml version="1.0" encoding="utf-8"?>
1
<?xml version="1.0" encoding="utf-8"?>
2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
    package="com.electric.chargingpile"
3
    package="com.electric.chargingpile"
4
    android:versionCode="85"
5
    android:versionName="3.4.7">
4
    android:versionCode="86"
5
    android:versionName="3.4.8">
6
    <!-- 极光 -->
6
    <!-- 极光 -->
7
    <application
7
    <application
8
        android:name=".application.MainApplication"
8
        android:name=".application.MainApplication"

+ 33 - 27
app/src/main/java/com/electric/chargingpile/activity/WelcomeActivity.java

29

29

30
import com.alibaba.fastjson.JSON;
30
import com.alibaba.fastjson.JSON;
31
import com.amap.api.maps.MapsInitializer;
31
import com.amap.api.maps.MapsInitializer;
32
import com.andview.refreshview.utils.Utils;
32
import com.blankj.utilcode.util.CacheUtils;
33
import com.blankj.utilcode.util.CacheUtils;
33
import com.blankj.utilcode.util.EmptyUtils;
34
import com.blankj.utilcode.util.EmptyUtils;
34
import com.blankj.utilcode.util.LogUtils;
35
import com.blankj.utilcode.util.LogUtils;
35
import com.blankj.utilcode.util.StringUtils;
36
import com.blankj.utilcode.util.StringUtils;
37
import com.electric.chargingpile.BuildConfig;
36
import com.electric.chargingpile.R;
38
import com.electric.chargingpile.R;
37
import com.electric.chargingpile.application.MainApplication;
39
import com.electric.chargingpile.application.MainApplication;
38
import com.electric.chargingpile.data.AdDetail;
40
import com.electric.chargingpile.data.AdDetail;
138
                case 9:
140
                case 9:
139
                    try {
141
                    try {
140
                        String data = JsonUtils.getKeyResult(msg.obj.toString(), "data");
142
                        String data = JsonUtils.getKeyResult(msg.obj.toString(), "data");
141
//                        Log.e("welcome===",data);
142
                        String ad_major = JsonUtils.getKeyResult(data, "ad_major");
143
                        String ad_major = JsonUtils.getKeyResult(data, "ad_major");
143
//                        LogUtils.e(ad_major);
144
                        if (EmptyUtils.isNotEmpty(ad_major)) {
144
                        if (EmptyUtils.isNotEmpty(ad_major)) {
145
                            MainApplication.haveActivity = true;
145
                            MainApplication.haveActivity = true;
146
                            MainApplication.ad_major = ad_major;
146
                            MainApplication.ad_major = ad_major;
147
                            img = JsonUtils.getKeyResult(ad_major, "img");
147
                            img = JsonUtils.getKeyResult(ad_major, "img");
148
//                            Log.e("img===", img);
149
                            url = JsonUtils.getKeyResult(ad_major, "url");
148
                            url = JsonUtils.getKeyResult(ad_major, "url");
150
//                            Log.e("url===", url);
151
                            String content = JsonUtils.getKeyResult(ad_major, "content");
149
                            String content = JsonUtils.getKeyResult(ad_major, "content");
152
//                            Log.e("content===", content);
153
                            String icon = JsonUtils.getKeyResult(ad_major, "icon");
150
                            String icon = JsonUtils.getKeyResult(ad_major, "icon");
154
//                            Log.e("icon===", icon);
155
                            String title = JsonUtils.getKeyResult(ad_major, "title");
151
                            String title = JsonUtils.getKeyResult(ad_major, "title");
156
//                            Log.e("title===", title);
157
                            String is_dui = JsonUtils.getKeyResult(ad_major, "is_dui");
152
                            String is_dui = JsonUtils.getKeyResult(ad_major, "is_dui");
158
                            if (is_dui.equals("1")) {
153
                            if (is_dui.equals("1")) {
159
                                MainApplication.current_url = url;
154
                                MainApplication.current_url = url;
160
                            }
155
                            }
161

156

162
                            dealOperatorData();
157
                            dealOperatorData();
163

164
//                            Log.e("!!!!!pic", MainApplication.url + "/zhannew//uploadfile/" + img);
165

166
                            imgUrl = MainApplication.url + "/zhannew//uploadfile/" + img;
158
                            imgUrl = MainApplication.url + "/zhannew//uploadfile/" + img;
167

159

168
                            if (!imgUrl.toString().equals("")) {
160
                            if (!imgUrl.toString().equals("")) {
198
                            MainApplication.list_addetail = JsonUtils.parseToObjectList(ad_detail, AdDetail.class);
190
                            MainApplication.list_addetail = JsonUtils.parseToObjectList(ad_detail, AdDetail.class);
199
                        }
191
                        }
200
                        String huodonglabel = JsonUtils.getKeyResult(data, "huodonglabel");
192
                        String huodonglabel = JsonUtils.getKeyResult(data, "huodonglabel");
201
//                        Log.e("ad=====",ad);
202

203
                        String levellabel = JsonUtils.getKeyResult(data, "levellabel");
193
                        String levellabel = JsonUtils.getKeyResult(data, "levellabel");
204

194

205
                        if (null == levellabel) {
195
                        if (null == levellabel) {
243
                        if (EmptyUtils.isNotEmpty(jsonArray) && jsonArray.size() > 0) {
233
                        if (EmptyUtils.isNotEmpty(jsonArray) && jsonArray.size() > 0) {
244
                            String welcome_ad = jsonArray.getJSONObject(0).toString();
234
                            String welcome_ad = jsonArray.getJSONObject(0).toString();
245
                            img = JsonUtils.getKeyResult(welcome_ad, "img");
235
                            img = JsonUtils.getKeyResult(welcome_ad, "img");
246
//                            Log.e("img===", img);
247
                            url = JsonUtils.getKeyResult(welcome_ad, "url");
236
                            url = JsonUtils.getKeyResult(welcome_ad, "url");
248
//                            Log.e("url===", url);
249
                            String content = JsonUtils.getKeyResult(welcome_ad, "content");
237
                            String content = JsonUtils.getKeyResult(welcome_ad, "content");
250
//                            Log.e("content===", content);
251
                            String icon = JsonUtils.getKeyResult(welcome_ad, "icon");
238
                            String icon = JsonUtils.getKeyResult(welcome_ad, "icon");
252
//                            Log.e("icon===", icon);
253
                            String title = JsonUtils.getKeyResult(welcome_ad, "title");
239
                            String title = JsonUtils.getKeyResult(welcome_ad, "title");
254
//                            Log.e("title===", title);
255
                            String is_dui = JsonUtils.getKeyResult(welcome_ad, "is_dui");
240
                            String is_dui = JsonUtils.getKeyResult(welcome_ad, "is_dui");
256
                            if (is_dui.equals("1")) {
241
                            if (is_dui.equals("1")) {
257
                                MainApplication.current_url = url;
242
                                MainApplication.current_url = url;
258
                            }
243
                            }
259

244

260
//                            Log.e("!!!!!pic", MainApplication.url + "/zhannew//uploadfile/" + img);
261

262
                            imgUrl = MainApplication.url + "/zhannew//uploadfile/" + img;
245
                            imgUrl = MainApplication.url + "/zhannew//uploadfile/" + img;
263

246

264
                            if (!imgUrl.toString().equals("")) {
247
                            if (!imgUrl.toString().equals("")) {
423
            public void run() {
406
            public void run() {
424
                try {
407
                try {
425
                    // 创建Socket
408
                    // 创建Socket
426
                    // socket = new Socket("192.168.1.110",54321);
427
//                    socket = new Socket("192.168.3.147", 9503); // IP:10.14.114.127,端口54321
428
                    socket = new Socket("cdz.evcharge.cc", 9503); // IP:10.14.114.127,端口54321
409
                    String host = "";
410
                    if (MainApplication.url.contains("cdz.evcharge.cc")) {
411
                        host = "cdz.evcharge.cc";
412
                    } else {
413
                        host = "59.110.68.162";
414
                    }
415
                    socket = new Socket(host, 9503);
429
                    // 向服务器发送消息
416
                    // 向服务器发送消息
430
                    PrintWriter out = new PrintWriter(new BufferedWriter(
417
                    PrintWriter out = new PrintWriter(new BufferedWriter(
431
                            new OutputStreamWriter(socket.getOutputStream())), true);
418
                            new OutputStreamWriter(socket.getOutputStream())), true);
451
//                    Log.e("timer===", time + "");
438
//                    Log.e("timer===", time + "");
452
                    String Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - MainMapActivity.cha) / 10) + "qwerty");
439
                    String Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - MainMapActivity.cha) / 10) + "qwerty");
453
//                    Log.d("11111","{\"fun\":\"init\",\"timer\":" + "\"" + Token + "\"" + "}");
440
//                    Log.d("11111","{\"fun\":\"init\",\"timer\":" + "\"" + Token + "\"" + "}");
454
                    ete2("{\"fun\":\"init\",\"timer\":" + "\"" + Token + "\"" + "}");
441
                    StringBuffer initParams = new StringBuffer();
442
                    initParams.append("{\"fun\":\"init\",\"timer\":\"" + Token + "\"");
443

444
                    initParams.append(",\"w\":\"" + Utils.getScreenWidth(WelcomeActivity.this) + "\"");
445
                    initParams.append(",\"h\":\"" + Utils.getScreenHeight(WelcomeActivity.this) + "\"");
446
                    initParams.append(",\"version_name\":\"" + BuildConfig.VERSION_NAME + "\"");
447
                    initParams.append(",\"version_code\":\"" + BuildConfig.VERSION_CODE + "\"");
448
                    initParams.append(",\"os\":\"android "+ Build.VERSION.RELEASE +"\""); // 操作系统及版本
449
//                    initParams.append(",\"version\":\"" + Build.VERSION.RELEASE + "\""); // 操作系统版本
450
                    initParams.append(",\"brand\":\"" + Build.BRAND + "\""); // 品牌
451
                    initParams.append(",\"model\":\"" + Build.MODEL + "\""); // 型号
452
                    initParams.append("}");
453
                    ete2(initParams.toString());
455
                } catch (Exception e) {
454
                } catch (Exception e) {
455
                    e.printStackTrace();
456
                }
456
                }
457
            }
457
            }
458
        }).start();
458
        }).start();
459

460
    }
459
    }
461

460

462

461

466
            public void run() {
465
            public void run() {
467
                try {
466
                try {
468
                    // 创建Socket
467
                    // 创建Socket
469
                    // socket = new Socket("192.168.1.110",54321);
470
//                    socket = new Socket("192.168.3.147", 9503); // IP:10.14.114.127,端口54321
471
                    socket = new Socket("cdz.evcharge.cc", 9503); // IP:10.14.114.127,端口54321
468
                    String host = "";
469
                    if (MainApplication.url.contains("cdz.evcharge.cc")) {
470
                        host = "cdz.evcharge.cc";
471
                    } else {
472
                        host = "59.110.68.162";
473
                    }
474
                    socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
472
//                    SocketAddress socAddress = new InetSocketAddress("cdz.d1ev.com", 9503);
475
//                    SocketAddress socAddress = new InetSocketAddress("cdz.d1ev.com", 9503);
473
//                    socket.connect(socAddress, 5000);
476
//                    socket.connect(socAddress, 5000);
474
                    // 向服务器发送消息
477
                    // 向服务器发送消息
780
        }
783
        }
781
    }
784
    }
782

785

786
    /**
787
     * 获取运营商信息
788
     */
783
    private void getOperatorData() {
789
    private void getOperatorData() {
784
        String url = MainApplication.url + "/zhannew/basic/web/index.php/suppiler/suppiler-list";
790
        String url = MainApplication.url + "/zhannew/basic/web/index.php/suppiler/suppiler-list";
785
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
791
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {

+ 2 - 2
app/src/main/java/com/electric/chargingpile/application/MainApplication.java

75
    public static String firstPoint = "";
75
    public static String firstPoint = "";
76
    public static Boolean firstSsyd;
76
    public static Boolean firstSsyd;
77
    public static String password = "";
77
    public static String password = "";
78
//    public static String url = "http://59.110.68.162";// 充电桩测试环境
79
        public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
78
    public static String url = "http://59.110.68.162";// 充电桩测试环境
79
//        public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
80
//    public static String urlNew = "http://123.56.67.7:83/api/0300";// 一电测试环境
80
//    public static String urlNew = "http://123.56.67.7:83/api/0300";// 一电测试环境
81
    public static String urlNew = "https://api.touchev.com:83/api/0300";// 一电正式环境
81
    public static String urlNew = "https://api.touchev.com:83/api/0300";// 一电正式环境
82
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
82
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";

+ 4 - 2
app/src/main/res/layout/activity_main_map.xml

1769
1769
1770
    </LinearLayout>
1770
    </LinearLayout>
1771
1771
1772
    <!-- 首页弹出广告布局 -->
1772
    <!-- 首页弹出广告布局 start -->
1773
    <com.zhy.autolayout.AutoRelativeLayout
1773
    <com.zhy.autolayout.AutoRelativeLayout
1774
        android:id="@+id/rl_ad"
1774
        android:id="@+id/rl_ad"
1775
        android:layout_width="match_parent"
1775
        android:layout_width="match_parent"
1799
            android:scaleType="fitXY" />
1799
            android:scaleType="fitXY" />
1800
1800
1801
    </com.zhy.autolayout.AutoRelativeLayout>
1801
    </com.zhy.autolayout.AutoRelativeLayout>
1802
    <!-- 首页弹出广告布局 end -->
1802
1803
1803
    <!-- 首页首次启动弹出隐私协议 -->
1804
    <!-- 首页首次启动弹出隐私协议 start -->
1804
    <android.support.constraint.ConstraintLayout
1805
    <android.support.constraint.ConstraintLayout
1805
        android:id="@+id/rl_privacy_protocol"
1806
        android:id="@+id/rl_privacy_protocol"
1806
        android:layout_width="match_parent"
1807
        android:layout_width="match_parent"
1846
        </android.support.constraint.ConstraintLayout>
1847
        </android.support.constraint.ConstraintLayout>
1847
1848
1848
    </android.support.constraint.ConstraintLayout>
1849
    </android.support.constraint.ConstraintLayout>
1850
    <!-- 首页首次启动弹出隐私协议 end -->
1849
1851
1850
1852
1851
</RelativeLayout>
1853
</RelativeLayout>

+ 20 - 24
app/src/main/res/layout/activity_welcome.xml

4
    android:layout_width="match_parent"
4
    android:layout_width="match_parent"
5
    android:layout_height="match_parent">
5
    android:layout_height="match_parent">
6

6

7
    <!-- logo start    -->
7
    <LinearLayout
8
    <LinearLayout
8
        android:layout_width="match_parent"
9
        android:layout_width="match_parent"
9
        android:layout_height="match_parent"
10
        android:layout_height="match_parent"
11
        android:layout_centerVertical="true"
12
        android:layout_centerVertical="true"
12
        android:background="#ffffff"
13
        android:background="#ffffff"
13
        android:orientation="vertical">
14
        android:orientation="vertical">
14

15
        <ImageView
15
        <ImageView
16
            android:id="@+id/img_welcome"
16
            android:id="@+id/img_welcome"
17
            android:layout_width="160dp"
17
            android:layout_width="160dp"
18
            android:layout_height="59dp"
18
            android:layout_height="59dp"
19
            android:contentDescription="@null"
20
            android:visibility="visible"
21
            android:layout_gravity="center_horizontal"
19
            android:layout_gravity="center_horizontal"
22
            android:layout_marginTop="240dp"
20
            android:layout_marginTop="240dp"
23
            android:src="@drawable/bg_welcome_text"/>
24

25

26
        <TextView
27
            android:layout_width="wrap_content"
28
            android:layout_height="wrap_content"
29
            android:layout_gravity="center"
30
            android:layout_marginTop="25dp"
31
            android:text="充电桩"
32
            android:textSize="25sp"
33
            android:visibility="gone" />
34

21
            android:contentDescription="@null"
22
            android:src="@drawable/bg_welcome_text"
23
            android:visibility="visible" />
35
    </LinearLayout>
24
    </LinearLayout>
25
    <!-- logo end    -->
36

26

37
    <!-- 360 首发标识 -->
27
    <!-- 360 首发标识 start -->
38
    <!--<ImageView-->
28
    <!--<ImageView-->
39
        <!--android:src="@drawable/logo_360"-->
40
        <!--android:layout_width="wrap_content"-->
41
        <!--android:layout_centerHorizontal="true"-->
42
        <!--android:layout_alignParentBottom="true"-->
43
        <!--android:layout_marginBottom="80dp"-->
44
        <!--android:layout_height="wrap_content" />-->
29
    <!--android:src="@drawable/logo_360"-->
30
    <!--android:layout_width="wrap_content"-->
31
    <!--android:layout_centerHorizontal="true"-->
32
    <!--android:layout_alignParentBottom="true"-->
33
    <!--android:layout_marginBottom="80dp"-->
34
    <!--android:layout_height="wrap_content" />-->
35
    <!-- 360 首发标识 end -->
45

36

37
    <!-- guide start    -->
46
    <android.support.v4.view.ViewPager
38
    <android.support.v4.view.ViewPager
47
        android:id="@+id/viewpager"
39
        android:id="@+id/viewpager"
48
        android:layout_width="fill_parent"
40
        android:layout_width="fill_parent"
49
        android:layout_height="fill_parent"
41
        android:layout_height="fill_parent"
50
        android:visibility="gone"></android.support.v4.view.ViewPager>
42
        android:visibility="gone" />
43
    <!-- guide end    -->
51

44

45
    <!-- 版本信息 start    -->
52
    <TextView
46
    <TextView
53
        android:id="@+id/android"
47
        android:id="@+id/android"
54
        android:layout_width="wrap_content"
48
        android:layout_width="wrap_content"
59
        android:text=""
53
        android:text=""
60
        android:textColor="#AAAAAA"
54
        android:textColor="#AAAAAA"
61
        android:textSize="12sp" />
55
        android:textSize="12sp" />
56
    <!-- 版本信息 end    -->
62

57

58
    <!-- 版权信息 start    -->
63
    <com.zhy.autolayout.AutoLinearLayout
59
    <com.zhy.autolayout.AutoLinearLayout
64
        android:id="@+id/ll_1"
60
        android:id="@+id/ll_1"
65
        android:layout_width="wrap_content"
61
        android:layout_width="wrap_content"
84
            android:textColor="#AAAAAA"
80
            android:textColor="#AAAAAA"
85
            android:textSize="11sp" />
81
            android:textSize="11sp" />
86
    </com.zhy.autolayout.AutoLinearLayout>
82
    </com.zhy.autolayout.AutoLinearLayout>
87

83
    <!-- 版权信息 end    -->
88

84

89
</RelativeLayout>
85
</RelativeLayout>