Browse Source

web页面跳转原生功能添加

huyuguo 3 years ago
parent
commit
f2a095d83e

+ 63 - 4
app/src/main/java/com/electric/chargingpile/activity/MyWebViewActivity.java

19
import android.os.Environment;
19
import android.os.Environment;
20
import android.os.Handler;
20
import android.os.Handler;
21
import android.provider.MediaStore;
21
import android.provider.MediaStore;
22
23
import androidx.annotation.NonNull;
24
import androidx.core.content.FileProvider;
25
26
import android.text.TextUtils;
22
import android.text.TextUtils;
27
import android.util.Log;
23
import android.util.Log;
28
import android.view.KeyEvent;
24
import android.view.KeyEvent;
43
import android.widget.TextView;
39
import android.widget.TextView;
44
import android.widget.Toast;
40
import android.widget.Toast;
45
41
42
import androidx.annotation.NonNull;
43
import androidx.core.content.FileProvider;
44
46
import com.afollestad.materialdialogs.DialogAction;
45
import com.afollestad.materialdialogs.DialogAction;
47
import com.afollestad.materialdialogs.MaterialDialog;
46
import com.afollestad.materialdialogs.MaterialDialog;
48
import com.blankj.utilcode.util.LogUtils;
47
import com.blankj.utilcode.util.LogUtils;
49
import com.electric.chargingpile.BuildConfig;
48
import com.electric.chargingpile.BuildConfig;
50
import com.electric.chargingpile.R;
49
import com.electric.chargingpile.R;
51
import com.electric.chargingpile.application.MainApplication;
50
import com.electric.chargingpile.application.MainApplication;
51
import com.electric.chargingpile.data.CarOwnerCertificateBean;
52
import com.electric.chargingpile.data.ChargingShareBean;
52
import com.electric.chargingpile.data.ChargingShareBean;
53
import com.electric.chargingpile.data.User;
53
import com.electric.chargingpile.data.User;
54
import com.electric.chargingpile.entity.CarSeriesEntity;
54
import com.electric.chargingpile.manager.ProfileManager;
55
import com.electric.chargingpile.manager.ProfileManager;
55
import com.electric.chargingpile.util.BarColorUtil;
56
import com.electric.chargingpile.util.BarColorUtil;
56
import com.electric.chargingpile.util.DES3;
57
import com.electric.chargingpile.util.DES3;
57
import com.electric.chargingpile.util.ImageUitl;
58
import com.electric.chargingpile.util.ImageUitl;
58
import com.electric.chargingpile.util.JsonUtils;
59
import com.electric.chargingpile.util.JsonUtils;
60
import com.electric.chargingpile.util.LoadingDialog;
59
import com.electric.chargingpile.util.ToastUtil;
61
import com.electric.chargingpile.util.ToastUtil;
60
import com.electric.chargingpile.util.Util;
62
import com.electric.chargingpile.util.Util;
61
import com.electric.chargingpile.view.AlertDialogTwo;
63
import com.electric.chargingpile.view.AlertDialogTwo;
93
    private TextView tv_webTitle, tv_webShare;
95
    private TextView tv_webTitle, tv_webShare;
94
    private ImageView iv_webClose, iv_webBack, iv_message;
96
    private ImageView iv_webClose, iv_webBack, iv_message;
95
    private ProgressBar pb_webBar;
97
    private ProgressBar pb_webBar;
98
    private LoadingDialog loadDialog;
96
    private WebView webView;
99
    private WebView webView;
97
    private String canRefresh = "false";
100
    private String canRefresh = "false";
98
    private String index = "0";
101
    private String index = "0";
135
138
136
139
137
    private void initView() {
140
    private void initView() {
141
        loadDialog = new LoadingDialog(this);
142
        loadDialog.setCanceledOnTouchOutside(false);
138
        rl_point = (RelativeLayout) findViewById(R.id.rl_point);
143
        rl_point = (RelativeLayout) findViewById(R.id.rl_point);
139
        tv_point = (TextView) findViewById(R.id.tv_point);
144
        tv_point = (TextView) findViewById(R.id.tv_point);
140
        animation = AnimationUtils.loadAnimation(MyWebViewActivity.this, R.anim.nn);
145
        animation = AnimationUtils.loadAnimation(MyWebViewActivity.this, R.anim.nn);
715
            case "14":
720
            case "14":
716
                startActivity(new Intent(getApplication(), UnansweredActivity.class));
721
                startActivity(new Intent(getApplication(), UnansweredActivity.class));
717
                break;
722
                break;
723
            case "15":
724
                if (MainApplication.isLogin()) {
725
                    loadDialog.show();
726
                    getCarOwnerCertificateList();
727
                } else {
728
                    startActivity(new Intent(getApplicationContext(), LoginActivity.class));
729
                    ToastUtil.showToast(getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
730
                    index = "15";
731
                }
732
                break;
718
        }
733
        }
719
734
720
    }
735
    }
1560
        super.onDestroy();
1575
        super.onDestroy();
1561
        list.clear();
1576
        list.clear();
1562
    }
1577
    }
1578
1579
    /**
1580
     * 获取车主认证信息
1581
     */
1582
    private void getCarOwnerCertificateList() {
1583
        long tokenTime = System.currentTimeMillis() / 1000 - MainMapActivity.cha - 1;
1584
        String token = null;
1585
        try {
1586
            token = DES3.encode(String.valueOf(tokenTime));
1587
            token = URLEncoder.encode(token, "UTF-8");
1588
        } catch (Exception e) {
1589
            e.printStackTrace();
1590
        }
1591
1592
        String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token;
1593
        OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
1594
            @Override
1595
            public void onError(Call call, Exception e) {
1596
                e.printStackTrace();
1597
                loadDialog.dismiss();
1598
                Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
1599
            }
1600
1601
            @Override
1602
            public void onResponse(String response) {
1603
                loadDialog.dismiss();
1604
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
1605
                if ("01".equals(rtnCode)) {
1606
                    String data = JsonUtils.getKeyResult(response, "data");
1607
                    List<CarOwnerCertificateBean> list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
1608
                    if (list.size() == 0) {
1609
                        startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
1610
                    } else {
1611
                        Intent intent = new Intent(getApplication(), CarOwnerCertificateListActivity.class);
1612
                        intent.putExtra("data", data);
1613
                        startActivity(intent);
1614
                    }
1615
                } else {
1616
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
1617
                    Toast.makeText(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT).show();
1618
                }
1619
            }
1620
        });
1621
    }
1563
}
1622
}

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

77
    public static String firstPoint = "";
77
    public static String firstPoint = "";
78
    public static Boolean firstSsyd;
78
    public static Boolean firstSsyd;
79
    public static String password = "";
79
    public static String password = "";
80
//    public static String url = "http://59.110.68.162";// 充电桩测试环境
80
    public static String url = "http://59.110.68.162";// 充电桩测试环境
81
//    public static String pic_url = "http://59.110.68.162/zhannew/uploadfile/";
81
//    public static String pic_url = "http://59.110.68.162/zhannew/uploadfile/";
82
    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
82
//    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
83
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
83
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
84

84

85
    //    public static String urlNew = "http://123.56.67.7:83/api/0300";// 一电测试环境
85
    //    public static String urlNew = "http://123.56.67.7:83/api/0300";// 一电测试环境

+ 1 - 1
app/src/main/res/layout/activity_unanswered.xml

18
            android:layout_width="wrap_content"
18
            android:layout_width="wrap_content"
19
            android:layout_height="wrap_content"
19
            android:layout_height="wrap_content"
20
            android:layout_centerInParent="true"
20
            android:layout_centerInParent="true"
21
            android:text="待答问题"
21
            android:text="待答问题"
22
            android:textColor="#222222"
22
            android:textColor="#222222"
23
            android:textSize="18sp"/>
23
            android:textSize="18sp"/>
24
24