fix bug 修改Json传递失败问题
This commit is contained in:
@@ -48,7 +48,7 @@ android {
|
|||||||
*/
|
*/
|
||||||
// buildConfigField("String", "SERVER_IP", "\"120.27.209.4\"")
|
// buildConfigField("String", "SERVER_IP", "\"120.27.209.4\"")
|
||||||
// buildConfigField("String", "SERVER_PORT", "\"56792\"")
|
// buildConfigField("String", "SERVER_PORT", "\"56792\"")
|
||||||
buildConfigField("String", "SERVER_IP", "\"127.0.0.1\"")
|
buildConfigField("String", "SERVER_IP", "\"192.168.0.108\"")
|
||||||
buildConfigField("String", "SERVER_PORT", "\"56792\"")
|
buildConfigField("String", "SERVER_PORT", "\"56792\"")
|
||||||
/**
|
/**
|
||||||
* 门禁连接地址
|
* 门禁连接地址
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.ydd.sportfaceid;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.widget.ContentLoadingProgressBar;
|
import android.support.v4.widget.ContentLoadingProgressBar;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
@@ -20,7 +19,6 @@ import com.ydd.sportfaceid.config.SDAppConfig;
|
|||||||
import com.ydd.sportfaceid.event.QRCodeEvent;
|
import com.ydd.sportfaceid.event.QRCodeEvent;
|
||||||
import com.ydd.sportfaceid.main.SDBaseActivity;
|
import com.ydd.sportfaceid.main.SDBaseActivity;
|
||||||
import com.ydd.sportfaceid.netty.config.Constant;
|
import com.ydd.sportfaceid.netty.config.Constant;
|
||||||
import com.ydd.sportfaceid.netty.message.DeviceType;
|
|
||||||
import com.ydd.sportfaceid.service.ClientService;
|
import com.ydd.sportfaceid.service.ClientService;
|
||||||
import com.ydd.sportfaceid.setting.SDSettingActivity;
|
import com.ydd.sportfaceid.setting.SDSettingActivity;
|
||||||
import com.ydd.sportfaceid.utils.DeviceIdUtil;
|
import com.ydd.sportfaceid.utils.DeviceIdUtil;
|
||||||
@@ -155,17 +153,17 @@ public class MainActivity extends SDBaseActivity {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.btn_refresh:
|
case R.id.btn_refresh:
|
||||||
configView();
|
refreshWebView();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.btn_last_day:
|
case R.id.btn_last_day:
|
||||||
current_date = TimeUtil.getSpecifiedDayAfter(current_date,1);
|
current_date = TimeUtil.getSpecifiedDayAfter(current_date,1);
|
||||||
configView();
|
refreshWebView();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.btn_next_day:
|
case R.id.btn_next_day:
|
||||||
current_date = TimeUtil.getSpecifiedDayAfter(current_date,-1);
|
current_date = TimeUtil.getSpecifiedDayAfter(current_date,-1);
|
||||||
configView();
|
refreshWebView();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -185,10 +183,10 @@ public class MainActivity extends SDBaseActivity {
|
|||||||
private void initQrIcon() {
|
private void initQrIcon() {
|
||||||
Integer venueId = SDAppConfig.getInstance().getVenueId();
|
Integer venueId = SDAppConfig.getInstance().getVenueId();
|
||||||
String deviceName = DeviceIdUtil.generateDeviceId(this);
|
String deviceName = DeviceIdUtil.generateDeviceId(this);
|
||||||
DeviceType deviceType = SDAppConfig.getInstance().getDeviceType();
|
String deviceType = SDAppConfig.getInstance().getDeviceType();
|
||||||
String qrCert = deviceName + Constant.QRCODE_WORD + venueId + Constant.QRCODE_WORD + deviceType;
|
String qrCert = deviceName + Constant.QRCODE_WORD + venueId + Constant.QRCODE_WORD + deviceType;
|
||||||
if (venueId != 0) {
|
if (venueId != null) {
|
||||||
Bitmap qrImage = QRCodeUtil.createQRImage(qrCert, qrCodeIvEnter.getWidth(), qrCodeIvEnter.getHeight());
|
Bitmap qrImage = QRCodeUtil.createQRImage(qrCert, 100, 100);
|
||||||
qrCodeIvEnter.setImageBitmap(qrImage);
|
qrCodeIvEnter.setImageBitmap(qrImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.ydd.sportfaceid.netty.message.DeviceType;
|
|
||||||
|
|
||||||
public class SDAppConfig {
|
public class SDAppConfig {
|
||||||
|
|
||||||
private static SDAppConfig config;
|
private static SDAppConfig config;
|
||||||
@@ -20,7 +18,7 @@ public class SDAppConfig {
|
|||||||
* 场馆ID
|
* 场馆ID
|
||||||
*/
|
*/
|
||||||
private Integer venueId;
|
private Integer venueId;
|
||||||
private DeviceType deviceType;
|
private String deviceType;
|
||||||
|
|
||||||
private SDAppConfig() {
|
private SDAppConfig() {
|
||||||
}
|
}
|
||||||
@@ -48,16 +46,16 @@ public class SDAppConfig {
|
|||||||
this.venueId = sp.getInt(STORE_VENUE, 0);
|
this.venueId = sp.getInt(STORE_VENUE, 0);
|
||||||
String storeType = sp.getString(STORE_DEVICE_TYPE, "ENTER");
|
String storeType = sp.getString(STORE_DEVICE_TYPE, "ENTER");
|
||||||
if (!TextUtils.isEmpty(storeType)) {
|
if (!TextUtils.isEmpty(storeType)) {
|
||||||
this.deviceType = DeviceType.valueOf(storeType);
|
this.deviceType = storeType;
|
||||||
}
|
}
|
||||||
configSet(venueId, deviceType);
|
configSet(venueId, deviceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configSet(Integer venueId, DeviceType deviceType) {
|
public void configSet(Integer venueId, String deviceType) {
|
||||||
this.venueId = venueId;
|
this.venueId = venueId;
|
||||||
this.deviceType = deviceType;
|
this.deviceType = deviceType;
|
||||||
spEditor.putInt(STORE_VENUE, venueId);
|
spEditor.putInt(STORE_VENUE, venueId);
|
||||||
spEditor.putString(STORE_DEVICE_TYPE, deviceType.name());
|
spEditor.putString(STORE_DEVICE_TYPE, deviceType);
|
||||||
spEditor.commit();
|
spEditor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,11 +67,11 @@ public class SDAppConfig {
|
|||||||
this.venueId = venueId;
|
this.venueId = venueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceType getDeviceType() {
|
public String getDeviceType() {
|
||||||
return deviceType;
|
return deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceType(DeviceType deviceType) {
|
public void setDeviceType(String deviceType) {
|
||||||
this.deviceType = deviceType;
|
this.deviceType = deviceType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.app.Activity;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.ydd.sportfaceid.config.SDAppConfig;
|
import com.ydd.sportfaceid.config.SDAppConfig;
|
||||||
import com.ydd.sportfaceid.netty.message.DeviceType;
|
|
||||||
import com.ydd.sportfaceid.netty.message.HeartBeat;
|
import com.ydd.sportfaceid.netty.message.HeartBeat;
|
||||||
import com.ydd.sportfaceid.netty.message.MessageDTO;
|
import com.ydd.sportfaceid.netty.message.MessageDTO;
|
||||||
import com.ydd.sportfaceid.service.MessageService;
|
import com.ydd.sportfaceid.service.MessageService;
|
||||||
@@ -87,7 +86,7 @@ public class ClientHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
HeartBeat hb = new HeartBeat();
|
HeartBeat hb = new HeartBeat();
|
||||||
hb.setDeviceName(DeviceIdUtil.generateDeviceId(mContext));
|
hb.setDeviceName(DeviceIdUtil.generateDeviceId(mContext));
|
||||||
hb.setVenueId(SDAppConfig.getInstance().getVenueId());
|
hb.setVenueId(SDAppConfig.getInstance().getVenueId());
|
||||||
hb.setEnterOrOut(SDAppConfig.getInstance().getDeviceType());
|
hb.setDeviceType(SDAppConfig.getInstance().getDeviceType());
|
||||||
return hb;
|
return hb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.ydd.sportfaceid.netty.message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备属性,控制入场还是控制出场
|
|
||||||
*/
|
|
||||||
public enum DeviceType {
|
|
||||||
|
|
||||||
ENTER(0,"进场"),
|
|
||||||
OUT(1,"出场");
|
|
||||||
private int code;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
DeviceType(int code, String name) {
|
|
||||||
this.code = code;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(int code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,7 +20,7 @@ public class HeartBeat implements Serializable {
|
|||||||
private String deviceName; //设备号
|
private String deviceName; //设备号
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
private DeviceType EnterOrOut; //出入标志
|
private String deviceType; //出入标志
|
||||||
|
|
||||||
public Integer getVenueId() {
|
public Integer getVenueId() {
|
||||||
return venueId;
|
return venueId;
|
||||||
@@ -38,11 +38,11 @@ public class HeartBeat implements Serializable {
|
|||||||
this.deviceName = deviceName;
|
this.deviceName = deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceType getEnterOrOut() {
|
public String getDeviceType() {
|
||||||
return EnterOrOut;
|
return deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnterOrOut(DeviceType enterOrOut) {
|
public void setDeviceType(String deviceType) {
|
||||||
EnterOrOut = enterOrOut;
|
this.deviceType = deviceType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package com.ydd.sportfaceid.setting;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Base64;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@@ -13,25 +11,20 @@ import android.widget.RadioButton;
|
|||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.ydd.sportfaceid.R;
|
import com.ydd.sportfaceid.R;
|
||||||
import com.ydd.sportfaceid.config.SDAppConfig;
|
import com.ydd.sportfaceid.config.SDAppConfig;
|
||||||
import com.ydd.sportfaceid.main.SDBaseActivity;
|
import com.ydd.sportfaceid.main.SDBaseActivity;
|
||||||
import com.ydd.sportfaceid.netty.message.DeviceType;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import com.ydd.sportfaceid.utils.JsonMapper;
|
import com.ydd.sportfaceid.utils.JsonMapper;
|
||||||
import com.ydd.sportfaceid.utils.TimeUntil;
|
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class SDSettingActivity extends SDBaseActivity {
|
public class SDSettingActivity extends SDBaseActivity {
|
||||||
public static final String TAG = "SDSettingActivity_TAG";
|
public static final String TAG = "SDSettingActivity_TAG";
|
||||||
@@ -46,14 +39,12 @@ public class SDSettingActivity extends SDBaseActivity {
|
|||||||
|
|
||||||
List<VenueItem> resultList = null;
|
List<VenueItem> resultList = null;
|
||||||
|
|
||||||
boolean init = false;
|
|
||||||
|
|
||||||
Handler handler = new Handler(){
|
Handler handler = new Handler(){
|
||||||
|
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case 1:
|
case 1:
|
||||||
init = true;
|
initSpinner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,40 +55,37 @@ public class SDSettingActivity extends SDBaseActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_sdsetting);
|
setContentView(R.layout.activity_sdsetting);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
@Override
|
String url = "https://lmqhznn.goho.co/getVenueList";
|
||||||
public void run() {
|
OkHttpClient client = new OkHttpClient();
|
||||||
String url = "https://lmqhznn.goho.co/getVenueList";
|
Request request = new Request.Builder()
|
||||||
OkHttpClient client = new OkHttpClient();
|
.url(url)
|
||||||
Request request = new Request.Builder()
|
.build();
|
||||||
.url(url)
|
Response response = null;
|
||||||
.build();
|
try {
|
||||||
Response response = null;
|
response = client.newCall(request).execute();
|
||||||
try {
|
} catch (IOException e) {
|
||||||
response = client.newCall(request).execute();
|
Log.e(TAG, "setConfigError: ", e);
|
||||||
} catch (IOException e) {
|
//Can't toast on a thread that has not called Looper.prepare()
|
||||||
Log.e(TAG, "setConfigError: ", e);
|
// showToast("网络异常,请稍候再试!");
|
||||||
showToast("网络异常,请稍候再试!");
|
|
||||||
}
|
|
||||||
if (!response.isSuccessful()) {
|
|
||||||
}
|
|
||||||
String result = null;
|
|
||||||
try {
|
|
||||||
result = response.body().string();
|
|
||||||
System.out.println("result ================" + result);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
resultList = JsonMapper.fromJson(result,new TypeToken<List<VenueItem>>(){}.getType());
|
|
||||||
Message message = new Message();
|
|
||||||
message.what = 1;
|
|
||||||
handler.sendMessage(message);
|
|
||||||
}
|
}
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
}
|
||||||
|
String result = null;
|
||||||
|
try {
|
||||||
|
result = response.body().string();
|
||||||
|
System.out.println("result ================" + result);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
resultList = JsonMapper.fromJson(result,new TypeToken<List<VenueItem>>(){}.getType());
|
||||||
|
List<VenueItem> objectList = new Gson().fromJson(result, new TypeToken<List<VenueItem>>(){}.getType());
|
||||||
|
System.out.println(resultList.get(0).getVenueId());
|
||||||
|
System.out.println(objectList.get(0).getVenueId());
|
||||||
|
Message message = new Message();
|
||||||
|
message.what = 1;
|
||||||
|
handler.sendMessage(message);
|
||||||
}).start();
|
}).start();
|
||||||
while (init){
|
|
||||||
initSpinner();
|
|
||||||
init = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -136,7 +124,7 @@ public class SDSettingActivity extends SDBaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String deviceTypeStr = (String) radioButton.getTag();
|
String deviceTypeStr = (String) radioButton.getTag();
|
||||||
DeviceType deviceType = DeviceType.valueOf(deviceTypeStr);
|
String deviceType = deviceTypeStr;
|
||||||
|
|
||||||
SDAppConfig.getInstance().configSet(venueId, deviceType);
|
SDAppConfig.getInstance().configSet(venueId, deviceType);
|
||||||
showToast("设置成功!");
|
showToast("设置成功!");
|
||||||
@@ -177,14 +165,14 @@ public class SDSettingActivity extends SDBaseActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// TODO: wyb, 2020-07-29, 这里可以设置为当前场馆的index.
|
// TODO: wyb, 2020-07-29, 这里可以设置为当前场馆的index.
|
||||||
int position = 0;
|
// int position = 0;
|
||||||
for (VenueItem venueItem : resultList){
|
// for (VenueItem venueItem : resultList){
|
||||||
if (spinnerValue.equals(venueItem.getVenueId())){
|
// if (spinnerValue.equals(venueItem.getVenueId())){
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
position ++ ;
|
// position ++ ;
|
||||||
}
|
// }
|
||||||
venueCellView.setSelection(position, false);
|
// venueCellView.setSelection(position, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.ydd.sportfaceid.setting;
|
package com.ydd.sportfaceid.setting;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class VenueItem implements Serializable {
|
public class VenueItem implements Serializable {
|
||||||
|
@Expose
|
||||||
private Integer venueId;
|
private Integer venueId;
|
||||||
|
@Expose
|
||||||
private String venueName;
|
private String venueName;
|
||||||
|
|
||||||
public VenueItem(Integer venueId, String venueName) {
|
public VenueItem(Integer venueId, String venueName) {
|
||||||
@@ -26,4 +30,9 @@ public class VenueItem implements Serializable {
|
|||||||
public void setVenueName(String venueName) {
|
public void setVenueName(String venueName) {
|
||||||
this.venueName = venueName;
|
this.venueName = venueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return venueId + "-" + venueName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@color/bg_color"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<TextView
|
<TextView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
@@ -14,5 +8,4 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:text="测试场馆1"
|
tools:text="测试场馆1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
</LinearLayout>
|
|
||||||
Reference in New Issue
Block a user