mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
安卓端配置界面添加路径
This commit is contained in:
@@ -8,23 +8,17 @@ import android.content.IntentFilter;
|
||||
import android.location.LocationManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.multidex.MultiDex;
|
||||
|
||||
import com.kerwin.wumei.http.interceptor.CustomLoggingInterceptor;
|
||||
import com.kerwin.wumei.utils.SettingSPUtils;
|
||||
import com.kerwin.wumei.utils.XToastUtils;
|
||||
import com.kerwin.wumei.utils.sdkinit.ANRWatchDogInit;
|
||||
import com.kerwin.wumei.utils.sdkinit.UMengInit;
|
||||
import com.kerwin.wumei.utils.sdkinit.XBasicLibInit;
|
||||
import com.kerwin.wumei.utils.sdkinit.XUpdateInit;
|
||||
import com.xuexiang.xhttp2.XHttpSDK;
|
||||
import com.xuexiang.xrouter.launcher.XRouter;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServeUrl;
|
||||
|
||||
/**
|
||||
* @author xuexiang
|
||||
@@ -63,7 +57,6 @@ public class MyApp extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
initLibs();
|
||||
initHttp();
|
||||
app = this;
|
||||
mBroadcastData = new MutableLiveData<>();
|
||||
IntentFilter filter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
@@ -104,26 +97,11 @@ public class MyApp extends Application {
|
||||
//ANR监控
|
||||
ANRWatchDogInit.init();
|
||||
|
||||
// initXRouter();
|
||||
}
|
||||
|
||||
private void initHttp() {
|
||||
XHttpSDK.init(this); //初始化网络请求框架,必须首先执行
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
// XHttpSDK.debug(); //需要调试的时候执行
|
||||
// XHttpSDK.debug(new CustomLoggingInterceptor()); //设置自定义的日志打印拦截器
|
||||
XHttpSDK.setBaseUrl(getServeUrl()); //设置网络请求的基础地址
|
||||
// XHttpSDK.addInterceptor(new CustomDynamicInterceptor()); //设置动态参数添加拦截器
|
||||
// XHttpSDK.addInterceptor(new CustomExpiredInterceptor()); //请求失效校验拦截器
|
||||
}
|
||||
|
||||
private void initXRouter() {
|
||||
if (BuildConfig.DEBUG) { // 这两行必须写在init之前,否则这些配置在init过程中将无效
|
||||
XRouter.openLog(); // 打印日志
|
||||
XRouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
|
||||
}
|
||||
XRouter.init(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -109,6 +109,7 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.getToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
|
||||
@@ -349,7 +350,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
|
||||
*/
|
||||
private void getUserInfo(TextView avatar,TextView sign){
|
||||
if(!hasToken()) return;
|
||||
XHttp.get("/prod-api/getInfo")
|
||||
XHttp.get(getServerPath()+"/getInfo")
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<UserInfoApiResult<User>, User>(new TipRequestCallBack<User>() {
|
||||
@Override
|
||||
|
||||
@@ -54,10 +54,8 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServeUrl;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.getToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
|
||||
|
||||
|
||||
/**
|
||||
@@ -168,7 +166,7 @@ public class LoginFragment extends BaseFragment {
|
||||
* HTTP获取验证码
|
||||
*/
|
||||
private void getCatpureImage(){
|
||||
XHttp.get("/prod-api/captchaImage")
|
||||
XHttp.get(getServerPath()+"/captchaImage")
|
||||
.execute(new CallBackProxy<CaptchaImageApiResult<CaptureImage>, CaptureImage>(new TipRequestCallBack<CaptureImage>() {
|
||||
@Override
|
||||
public void onSuccess(CaptureImage image) throws Throwable {
|
||||
@@ -191,7 +189,7 @@ public class LoginFragment extends BaseFragment {
|
||||
* @param verifyCode 验证码
|
||||
*/
|
||||
private void loginByVerifyCode(String phoneNumber,String password, String verifyCode) {
|
||||
XHttp.post("/prod-api/login")
|
||||
XHttp.post(getServerPath()+ "/login")
|
||||
.upJson("{\"username\":\""+phoneNumber+"\",\"password\":\""+password+"\",\"code\":\""+verifyCode+"\",\"uuid\":\""+uuid+"\"}")
|
||||
.execute(new CallBackProxy<TokenApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,8 @@ import com.xuexiang.xutil.XUtil;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
|
||||
/**
|
||||
* @author xuexiang
|
||||
* @since 2019-10-15 22:38
|
||||
@@ -68,7 +70,7 @@ public class SettingsFragment extends BaseFragment implements SuperTextView.OnSu
|
||||
* HTTP退出登录
|
||||
*/
|
||||
private void logout(){
|
||||
XHttp.post("/prod-api/logout")
|
||||
XHttp.post(getServerPath()+"/logout")
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@Override
|
||||
public void onSuccess(String tokenResult) throws Throwable {
|
||||
|
||||
@@ -42,6 +42,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.getToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
|
||||
@@ -140,7 +141,7 @@ public class DeviceEditFragment extends BaseFragment {
|
||||
* HTTP获取最新设备信息
|
||||
*/
|
||||
private void getNewStatusData(){
|
||||
XHttp.get("/prod-api/system/status/getStatus/"+deviceNum)
|
||||
XHttp.get(getServerPath()+"/system/status/getStatus/"+deviceNum)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@Override
|
||||
@@ -163,7 +164,7 @@ public class DeviceEditFragment extends BaseFragment {
|
||||
* HTTP获取设备状态
|
||||
*/
|
||||
private void getDeviceStatus(Long device_id){
|
||||
XHttp.get("/prod-api/system/status/new/"+device_id)
|
||||
XHttp.get(getServerPath()+"/system/status/new/"+device_id)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new SimpleCallBack<IotDeviceStatus>() {
|
||||
@Override
|
||||
@@ -188,7 +189,7 @@ public class DeviceEditFragment extends BaseFragment {
|
||||
* HTTP获取设备信息
|
||||
*/
|
||||
private void getDevice(Long device_id){
|
||||
XHttp.get("/prod-api/system/device/"+device_id)
|
||||
XHttp.get(getServerPath()+"/system/device/"+device_id)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new SimpleCallBack<IotDevice>() {
|
||||
@Override
|
||||
@@ -220,7 +221,7 @@ public class DeviceEditFragment extends BaseFragment {
|
||||
*/
|
||||
private void updateDevice(IotDevice device){
|
||||
if(!hasToken()) return;
|
||||
XHttp.put("/prod-api/system/device")
|
||||
XHttp.put(getServerPath()+"/system/device")
|
||||
.upJson(JsonUtil.toJson(device))
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
|
||||
@@ -49,6 +49,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
|
||||
import static com.google.android.material.tabs.TabLayout.MODE_SCROLLABLE;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.getToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
|
||||
@@ -137,7 +138,7 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
|
||||
* HTTP获取分组列表
|
||||
*/
|
||||
private void getGroupList(@NonNull TabLayout.OnTabSelectedListener listener){
|
||||
XHttp.get("/prod-api/system/group/list?pageNum=1&pageSize=100")
|
||||
XHttp.get(getServerPath()+"/system/group/list?pageNum=1&pageSize=100")
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<ListApiResult<List<IotGroup>>, List<IotGroup>>(new TipRequestCallBack<List<IotGroup>>() {
|
||||
@Override
|
||||
@@ -177,7 +178,7 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
|
||||
* HTTP获取触发源字典列表
|
||||
*/
|
||||
private void getTriggerSourceDic(){
|
||||
XHttp.get("/prod-api/system/dict/data/type/iot_trigger_source")
|
||||
XHttp.get(getServerPath()+"/system/dict/data/type/iot_trigger_source")
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new SimpleCallBack<List<DictData>>() {
|
||||
@Override
|
||||
@@ -203,7 +204,7 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
|
||||
*/
|
||||
private void getGroup(Long groupId){
|
||||
if(!hasToken()) return;
|
||||
XHttp.get("/prod-api/system/group/"+groupId)
|
||||
XHttp.get(getServerPath()+"/system/group/"+groupId)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new SimpleCallBack<IotGroup>(){
|
||||
@Override
|
||||
@@ -229,7 +230,7 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
|
||||
*/
|
||||
private void addGroup(IotGroup group){
|
||||
if(!hasToken()) return;
|
||||
XHttp.post("/prod-api/system/group")
|
||||
XHttp.post(getServerPath()+"/system/group")
|
||||
.upJson(JsonUtil.toJson(group))
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@@ -256,7 +257,7 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
|
||||
*/
|
||||
private void editGroup(IotGroup group){
|
||||
if(!hasToken()) return;
|
||||
XHttp.put("/prod-api/system/group")
|
||||
XHttp.put(getServerPath()+"/system/group")
|
||||
.upJson(JsonUtil.toJson(group))
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@@ -282,7 +283,7 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
|
||||
*/
|
||||
private void deleteGroup(Long groupId){
|
||||
if(!hasToken()) return;
|
||||
XHttp.delete("/prod-api/system/group/"+groupId)
|
||||
XHttp.delete(getServerPath()+"/system/group/"+groupId)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.getToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
|
||||
@@ -178,7 +179,7 @@ public class DeviceSetFragment extends BaseFragment {
|
||||
* HTTP获取遥控按键功能字典列表
|
||||
*/
|
||||
private void getRFFunctionDic(){
|
||||
XHttp.get("/prod-api/system/dict/data/type/rf_function")
|
||||
XHttp.get(getServerPath()+"/system/dict/data/type/rf_function")
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new SimpleCallBack<List<DictData>>() {
|
||||
@Override
|
||||
@@ -208,7 +209,7 @@ public class DeviceSetFragment extends BaseFragment {
|
||||
* HTTP获取设备配置
|
||||
*/
|
||||
private void getDeviceSet(Long device_id){
|
||||
XHttp.get("/prod-api/system/set/new/"+device_id)
|
||||
XHttp.get(getServerPath()+"/system/set/new/"+device_id)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new SimpleCallBack<IotDeviceSet>() {
|
||||
@Override
|
||||
@@ -241,7 +242,7 @@ public class DeviceSetFragment extends BaseFragment {
|
||||
*/
|
||||
private void updateDeviceSet(IotDeviceSet deviceSet){
|
||||
if(!hasToken()) return;
|
||||
XHttp.put("/prod-api/system/set")
|
||||
XHttp.put(getServerPath()+"/system/set")
|
||||
.upJson(JsonUtil.toJson(deviceSet))
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
|
||||
@@ -47,6 +47,7 @@ import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static android.R.layout.simple_spinner_item;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.getToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
|
||||
@@ -197,7 +198,7 @@ public class DeviceStatusFragment extends BaseFragment implements CompoundButton
|
||||
* HTTP获取最新设备信息
|
||||
*/
|
||||
private void getNewStatusData(){
|
||||
XHttp.get("/prod-api/system/status/getStatus/"+deviceNum)
|
||||
XHttp.get(getServerPath()+"/system/status/getStatus/"+deviceNum)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@Override
|
||||
@@ -220,7 +221,7 @@ public class DeviceStatusFragment extends BaseFragment implements CompoundButton
|
||||
* HTTP获取灯模式字典列表
|
||||
*/
|
||||
private void getLightModeDic(){
|
||||
XHttp.get("/prod-api/system/dict/data/type/light_mode")
|
||||
XHttp.get(getServerPath()+"/system/dict/data/type/light_mode")
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new SimpleCallBack<List<DictData>>() {
|
||||
@Override
|
||||
@@ -246,7 +247,7 @@ public class DeviceStatusFragment extends BaseFragment implements CompoundButton
|
||||
* HTTP获取设备状态
|
||||
*/
|
||||
private void getDeviceStatus(Long device_id){
|
||||
XHttp.get("/prod-api/system/status/new/"+device_id)
|
||||
XHttp.get(getServerPath()+"/system/status/new/"+device_id)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new SimpleCallBack<IotDeviceStatus>() {
|
||||
@Override
|
||||
@@ -283,7 +284,7 @@ public class DeviceStatusFragment extends BaseFragment implements CompoundButton
|
||||
*/
|
||||
private void updateDeviceStatus(IotDeviceStatus deviceStatus){
|
||||
if(!hasToken()) return;
|
||||
XHttp.put("/prod-api/system/status")
|
||||
XHttp.put(getServerPath()+"/system/status")
|
||||
.upJson(JsonUtil.toJson(deviceStatus))
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package com.kerwin.wumei.fragment.device;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -36,13 +37,12 @@ import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getApIp;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getIsHttps;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServeUrl;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPort;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerip;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerAddress;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.setAccount;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.setApIp;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.setServeUrl;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.setServeAddress;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.setServePath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
|
||||
|
||||
@@ -56,11 +56,9 @@ public class SceneFragment extends BaseFragment {
|
||||
@BindView(R.id.txt_message)
|
||||
TextView txt_message;
|
||||
@BindView(R.id.et_serve)
|
||||
MaterialEditText et_serve_ip;
|
||||
@BindView(R.id.et_port)
|
||||
MaterialEditText et_port;
|
||||
@BindView(R.id.sb_https)
|
||||
SwitchButton sb_https;
|
||||
MaterialEditText et_serve_address;
|
||||
@BindView(R.id.et_path)
|
||||
MaterialEditText et_serve_path;
|
||||
@BindView(R.id.et_ap_address)
|
||||
MaterialEditText et_ap_address;
|
||||
|
||||
@@ -87,9 +85,8 @@ public class SceneFragment extends BaseFragment {
|
||||
*/
|
||||
@Override
|
||||
protected void initViews() {
|
||||
et_serve_ip.setText(getServerip());
|
||||
et_port.setText(getServerPort());
|
||||
sb_https.setChecked(getIsHttps());
|
||||
et_serve_address.setText(getServerAddress());
|
||||
et_serve_path.setText(getServerPath());
|
||||
et_ap_address.setText(getApIp());
|
||||
}
|
||||
|
||||
@@ -99,26 +96,22 @@ public class SceneFragment extends BaseFragment {
|
||||
@SingleClick
|
||||
@OnClick({ R.id.btn_save_serve,R.id.btn_connect_test,R.id.btn_open_ap})
|
||||
public void onViewClicked(View view) {
|
||||
if(!et_port.validate()) return;
|
||||
if(et_serve_ip.getEditValue().length()==0)
|
||||
if(et_serve_address.getEditValue().length()==0)
|
||||
{
|
||||
showMessage("服务端地址不能为空",false);
|
||||
showMessage("接口地址不能为空",false);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (view.getId()) {
|
||||
case R.id.btn_save_serve:
|
||||
setServeUrl(et_serve_ip.getEditValue(),et_port.getEditValue(),sb_https.isChecked());
|
||||
setServeAddress(et_serve_address.getEditValue());
|
||||
setServePath(et_serve_path.getEditValue());
|
||||
clearToken();
|
||||
setAccount("","");
|
||||
showMessage("服务端地址信息存储成功,请重新启动APP!",true);
|
||||
break;
|
||||
case R.id.btn_connect_test:
|
||||
if(et_serve_ip.getEditValue().length()==0 ||et_port.getEditValue().length()==0) {
|
||||
showMessage("地址和端口不能为空",false);
|
||||
}else {
|
||||
getCatpureImage();
|
||||
}
|
||||
break;
|
||||
case R.id.btn_open_ap:
|
||||
if(et_ap_address.getEditValue()==null || et_ap_address.getEditValue().length()==0){
|
||||
@@ -132,20 +125,22 @@ public class SceneFragment extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private String buildServeString(){
|
||||
String address="http://";
|
||||
if(sb_https.isChecked()){
|
||||
address="https://";
|
||||
}
|
||||
return address+et_serve_ip.getEditValue()+":"+et_port.getEditValue();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HTTP获取验证码(用于连接测试)
|
||||
*/
|
||||
private void getCatpureImage(){
|
||||
XHttp.get(buildServeString() + "/prod-api/captchaImage")
|
||||
String address=et_serve_address.getEditValue();
|
||||
String path=et_serve_path.getEditValue();
|
||||
if(path==null || path.length()==0){
|
||||
Log.d("地址", address.substring(address.length()-1));
|
||||
if(address.substring(address.length()-1).equals("/")){
|
||||
address=address.substring(0,address.length()-1);
|
||||
}
|
||||
}
|
||||
String fullPath=address+path;
|
||||
XHttp.get(fullPath+ "/captchaImage")
|
||||
.execute(new CallBackProxy<CaptchaImageApiResult<CaptureImage>, CaptureImage>(new TipRequestCallBack<CaptureImage>() {
|
||||
@Override
|
||||
public void onSuccess(CaptureImage image) throws Throwable {
|
||||
@@ -154,7 +149,7 @@ public class SceneFragment extends BaseFragment {
|
||||
}
|
||||
@Override
|
||||
public void onError(ApiException e) {
|
||||
showMessage("服务端连接失败\n"+"连接地址:"+buildServeString()+"\n错误提示:"+e.getMessage(),false);
|
||||
showMessage("服务端连接失败\n"+"地址:"+et_serve_address.getEditValue()+et_serve_path.getEditValue()+"\n错误提示:"+e.getMessage(),false);
|
||||
}
|
||||
}){});
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import me.samlss.broccoli.Broccoli;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.getToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
|
||||
@@ -306,7 +307,7 @@ public class SimpleTabFragment extends BaseFragment {
|
||||
*/
|
||||
private void updateDeviceStatus(IotDeviceStatus deviceStatus,SwitchIconView iconView){
|
||||
if(!hasToken()) return;
|
||||
XHttp.put("/prod-api/system/status")
|
||||
XHttp.put(getServerPath()+"/system/status")
|
||||
.upJson(JsonUtil.toJson(deviceStatus))
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@@ -333,7 +334,7 @@ public class SimpleTabFragment extends BaseFragment {
|
||||
* HTTP获取设备列表
|
||||
*/
|
||||
private void getDeviceList(){
|
||||
XHttp.get("/prod-api/system/device/list?"+"pageNum="+pageNum+"&pageSize="+pageSize+"&groupId="+groupId)
|
||||
XHttp.get(getServerPath()+"/system/device/list?"+"pageNum="+pageNum+"&pageSize="+pageSize+"&groupId="+groupId)
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<ListApiResult<List<IotDeviceVo>>, List<IotDeviceVo>>(new TipRequestCallBack<List<IotDeviceVo>>() {
|
||||
@Override
|
||||
@@ -362,7 +363,7 @@ public class SimpleTabFragment extends BaseFragment {
|
||||
* HTTP获取分类列表
|
||||
*/
|
||||
private void getCategoryList(){
|
||||
XHttp.get("/prod-api/system/category/list?pageNum=1&pageSize=100")
|
||||
XHttp.get(getServerPath()+"/system/category/list?pageNum=1&pageSize=100")
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<ListApiResult<List<IotCategory>>, List<IotCategory>>(new TipRequestCallBack<List<IotCategory>>() {
|
||||
@Override
|
||||
|
||||
@@ -41,10 +41,7 @@ import com.xuexiang.xui.widget.textview.supertextview.SuperButton;
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getIsHttps;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPort;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerip;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.setServeUrl;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.clearToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.getToken;
|
||||
import static com.kerwin.wumei.utils.TokenUtils.hasToken;
|
||||
@@ -106,7 +103,7 @@ public class AccountFragment extends BaseFragment {
|
||||
*/
|
||||
private void getUserInfo(){
|
||||
if(!hasToken()) return;
|
||||
XHttp.get("/prod-api/getInfo")
|
||||
XHttp.get(getServerPath()+"/getInfo")
|
||||
.headers("Authorization","Bearer "+getToken())
|
||||
.execute(new CallBackProxy<UserInfoApiResult<User>, User>(new TipRequestCallBack<User>() {
|
||||
@Override
|
||||
|
||||
@@ -45,8 +45,7 @@ import java.util.Locale;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPort;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerip;
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
|
||||
|
||||
@Page(anim = CoreAnim.none)
|
||||
public class ProfileFragment extends BaseFragment implements SuperTextView.OnSuperTextViewClickListener {
|
||||
@@ -86,29 +85,10 @@ public class ProfileFragment extends BaseFragment implements SuperTextView.OnSup
|
||||
*/
|
||||
@Override
|
||||
protected void initViews() {
|
||||
if(getServerip()!=null && getServerip().length()>0){
|
||||
String address="http://"+getServerip();
|
||||
String control=address;
|
||||
String emqx=address+":18083";
|
||||
if(getServerPort()!=null && getServerPort().length()>0){
|
||||
control=address+":"+getServerPort();
|
||||
}
|
||||
|
||||
String finalControl = control;
|
||||
String finalEmqx=emqx;
|
||||
XUIGroupListView.newSection(getContext())
|
||||
.addItemView(mControlGroupListView.createItemView("打开管理控制台"), v -> AgentWebActivity.goWeb(getContext(), finalControl))
|
||||
.addItemView(mControlGroupListView.createItemView("打开EMQX控制台"), v -> AgentWebActivity.goWeb(getContext(), finalEmqx))
|
||||
.addItemView(mControlGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
|
||||
.addItemView(mControlGroupListView.createItemView("应用版本 - V" + AppUtils.getAppVersionName()), v -> XToastUtils.toast("官网下载最新版本"))
|
||||
.addTo(mControlGroupListView);
|
||||
}else {
|
||||
XUIGroupListView.newSection(getContext())
|
||||
.addItemView(mControlGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
|
||||
.addItemView(mControlGroupListView.createItemView("应用版本 - V" + AppUtils.getAppVersionName()), v -> XToastUtils.toast("官网下载最新版本"))
|
||||
.addTo(mControlGroupListView);
|
||||
}
|
||||
|
||||
XUIGroupListView.newSection(getContext())
|
||||
.addItemView(mControlGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
|
||||
.addItemView(mControlGroupListView.createItemView("应用版本 - V" + AppUtils.getAppVersionName()), v -> XToastUtils.toast("官网下载最新版本"))
|
||||
.addTo(mControlGroupListView);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy", Locale.CHINA);
|
||||
String currentYear = dateFormat.format(new Date());
|
||||
mCopyrightTextView.setText(String.format(getResources().getString(R.string.about_copyright), currentYear));
|
||||
@@ -125,7 +105,7 @@ public class ProfileFragment extends BaseFragment implements SuperTextView.OnSup
|
||||
* HTTP退出登录
|
||||
*/
|
||||
private void logout(){
|
||||
XHttp.post("/prod-api/logout")
|
||||
XHttp.post(getServerPath()+"/logout")
|
||||
.execute(new CallBackProxy<NoDataApiResult<String>, String>(new TipRequestCallBack<String>() {
|
||||
@Override
|
||||
public void onSuccess(String tokenResult) throws Throwable {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package com.kerwin.wumei.utils;
|
||||
|
||||
|
||||
/**
|
||||
* SharedPreferences管理工具基类
|
||||
*
|
||||
@@ -29,15 +28,16 @@ public final class SettingUtils {
|
||||
private SettingUtils() {
|
||||
throw new UnsupportedOperationException("u can't instantiate me...");
|
||||
}
|
||||
|
||||
private static final String IS_FIRST_OPEN_KEY = "is_first_open_key";
|
||||
private static final String IS_AGREE_PRIVACY_KEY = "is_agree_privacy_key";
|
||||
private static final String USER_NAME="user_name";
|
||||
private static final String PASSWORD="password";
|
||||
private static final String SERVERIP="serve_ip";
|
||||
private static final String SERVERPORT="serve_port";
|
||||
private static final String ISHTTPS="is_https";
|
||||
private static final String APIP="ap_ip";
|
||||
private static final String WIFIPASSWORD="wifi_password";
|
||||
private static final String USER_NAME = "user_name";
|
||||
private static final String PASSWORD = "password";
|
||||
private static final String SERVERADDRESS = "serve_address";
|
||||
private static final String SERVERPATH = "serve_path";
|
||||
private static final String APIP = "ap_ip";
|
||||
private static final String WIFIPASSWORD = "wifi_password";
|
||||
|
||||
/**
|
||||
* 是否是第一次启动
|
||||
*/
|
||||
@@ -55,109 +55,105 @@ public final class SettingUtils {
|
||||
/**
|
||||
* 设置用户名和密码
|
||||
*/
|
||||
public static void setAccount(String userName,String password){
|
||||
MMKVUtils.put(USER_NAME,userName);
|
||||
MMKVUtils.put(PASSWORD,password);
|
||||
public static void setAccount(String userName, String password) {
|
||||
MMKVUtils.put(USER_NAME, userName);
|
||||
MMKVUtils.put(PASSWORD, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置服务端地址
|
||||
*/
|
||||
public static void setServeUrl(String serveIp, String servePort, Boolean isHttps){
|
||||
MMKVUtils.put(SERVERIP,serveIp);
|
||||
MMKVUtils.put(SERVERPORT,servePort);
|
||||
MMKVUtils.put(ISHTTPS,isHttps);
|
||||
public static void setServeAddress(String serveAddress) {
|
||||
MMKVUtils.put(SERVERADDRESS, serveAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务端地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getServeUrl(){
|
||||
String address="http://";
|
||||
if(getIsHttps()==true){
|
||||
address="https://";
|
||||
}
|
||||
address=address+getServerip()+":"+getServerPort();
|
||||
return address;
|
||||
public static String getServerAddress() {
|
||||
return MMKVUtils.getString(SERVERADDRESS, "http://wumei.live:88/");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备AP地址
|
||||
* 设置服务端路径
|
||||
*/
|
||||
public static void setServePath(String servePath) {
|
||||
MMKVUtils.put(SERVERPATH, servePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务路径
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static void setApIp(String apIp){
|
||||
MMKVUtils.put(APIP,apIp);
|
||||
public static String getServerPath() {
|
||||
return MMKVUtils.getString(SERVERPATH, "prod-api");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置设备AP地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static void setApIp(String apIp) {
|
||||
MMKVUtils.put(APIP, apIp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备AP地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getApIp(){
|
||||
return MMKVUtils.getString(APIP,"192.168.4.1");
|
||||
public static String getApIp() {
|
||||
return MMKVUtils.getString(APIP, "192.168.4.1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置wifi密码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static void setWifiPassword(String wifiPassword){
|
||||
MMKVUtils.put(WIFIPASSWORD,wifiPassword);
|
||||
public static void setWifiPassword(String wifiPassword) {
|
||||
MMKVUtils.put(WIFIPASSWORD, wifiPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取wifi密码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getWifiPassword(){
|
||||
return MMKVUtils.getString(WIFIPASSWORD,"");
|
||||
public static String getWifiPassword() {
|
||||
return MMKVUtils.getString(WIFIPASSWORD, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务端ip
|
||||
* @return
|
||||
*/
|
||||
public static String getServerip(){
|
||||
return MMKVUtils.getString(SERVERIP,"wumei.live");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务端端口
|
||||
* @return
|
||||
*/
|
||||
public static String getServerPort(){
|
||||
return MMKVUtils.getString(SERVERPORT,"88");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否使用https
|
||||
* @return
|
||||
*/
|
||||
public static Boolean getIsHttps(){
|
||||
return MMKVUtils.getBoolean(ISHTTPS,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUserName(){
|
||||
return MMKVUtils.getString(USER_NAME,"");
|
||||
public static String getUserName() {
|
||||
return MMKVUtils.getString(USER_NAME, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录密码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getPassword(){
|
||||
return MMKVUtils.getString(PASSWORD,"");
|
||||
public static String getPassword() {
|
||||
return MMKVUtils.getString(PASSWORD, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空登录密码
|
||||
*/
|
||||
public static void clearPassword(){
|
||||
MMKVUtils.put(PASSWORD,"");
|
||||
public static void clearPassword() {
|
||||
MMKVUtils.put(PASSWORD, "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,5 +167,4 @@ public final class SettingUtils {
|
||||
MMKVUtils.put(IS_AGREE_PRIVACY_KEY, isAgreePrivacy);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package com.kerwin.wumei.utils.sdkinit;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.kerwin.wumei.MyApp;
|
||||
import com.kerwin.wumei.core.BaseActivity;
|
||||
@@ -31,6 +32,8 @@ import com.xuexiang.xui.XUI;
|
||||
import com.xuexiang.xutil.XUtil;
|
||||
import com.xuexiang.xutil.common.StringUtils;
|
||||
|
||||
import static com.kerwin.wumei.utils.SettingUtils.getServerAddress;
|
||||
|
||||
/**
|
||||
* X系列基础库初始化
|
||||
*
|
||||
@@ -81,13 +84,14 @@ public final class XBasicLibInit {
|
||||
private static void initXHttp2(Application application) {
|
||||
//初始化网络请求框架,必须首先执行
|
||||
XHttpSDK.init(application);
|
||||
XHttpSDK.setSuccessCode(200);
|
||||
//需要调试的时候执行
|
||||
if (MyApp.isDebug()) {
|
||||
XHttpSDK.debug();
|
||||
}
|
||||
// XHttpSDK.debug(new CustomLoggingInterceptor()); //设置自定义的日志打印拦截器
|
||||
//设置网络请求的全局基础地址
|
||||
XHttpSDK.setBaseUrl("https://gitee.com/");
|
||||
XHttpSDK.setBaseUrl(getServerAddress());
|
||||
// //设置动态参数添加拦截器
|
||||
// XHttpSDK.addInterceptor(new CustomDynamicInterceptor());
|
||||
// //请求失效校验拦截器
|
||||
|
||||
@@ -45,6 +45,14 @@
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView25"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="开发环境路径为dev-api,生产环境为prod-api"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
@@ -54,7 +62,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/config_margin_18dp"
|
||||
android:text="地址/域名:" />
|
||||
android:text="接口地址:" />
|
||||
|
||||
<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
|
||||
android:id="@+id/et_serve"
|
||||
@@ -62,7 +70,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="38dp"
|
||||
android:hint="请输入服务端地址,例如:192.168.0.100"
|
||||
android:hint="例如:http://wumei.live:88/prod-api"
|
||||
android:inputType="text"
|
||||
app:met_clearButton="true"
|
||||
app:met_errorMessage="输入的服务地址有误"
|
||||
@@ -75,47 +83,33 @@
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:id="@+id/txt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/config_margin_18dp"
|
||||
android:text="端口:" />
|
||||
android:text="路径:" />
|
||||
|
||||
<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
|
||||
android:id="@+id/et_port"
|
||||
android:id="@+id/et_path"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="38dp"
|
||||
android:hint="请输入端口号,例如:80"
|
||||
android:inputType="number"
|
||||
android:hint="例如:dev-api"
|
||||
android:inputType="text"
|
||||
app:met_clearButton="true"
|
||||
app:met_errorMessage="输入的端口有误"
|
||||
app:met_errorMessage="输入的服务地址有误"
|
||||
app:met_floatingLabel="normal"
|
||||
app:met_floatingLabelText="服务端口" />
|
||||
app:met_floatingLabelText="服务端地址" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/config_margin_18dp"
|
||||
android:text="使用HTTPS:" />
|
||||
|
||||
<com.xuexiang.xui.widget.button.switchbutton.SwitchButton
|
||||
android:id="@+id/sb_https"
|
||||
style="@style/SwitchButtonStyle"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="90dp"
|
||||
app:swb_textOff="否"
|
||||
app:swb_textOn="是" />
|
||||
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user