Commit ecac0f7e by wjg

1.0.18

parent 9886d66a
...@@ -18,8 +18,8 @@ android { ...@@ -18,8 +18,8 @@ android {
applicationId "com.ihaoin.hooloo.device" applicationId "com.ihaoin.hooloo.device"
minSdkVersion 26 minSdkVersion 26
targetSdkVersion 30 targetSdkVersion 30
versionCode 16 versionCode 17
versionName "1.0.16" versionName "1.0.17"
ndk { ndk {
//选择要添加的对应 cpu 类型的 .so 库。 //选择要添加的对应 cpu 类型的 .so 库。
......
...@@ -30,6 +30,6 @@ public class AppConfig { ...@@ -30,6 +30,6 @@ public class AppConfig {
public static String HOST_BRAIN = ""; public static String HOST_BRAIN = "";
public static final String HOST_BRAIN_PROD = "https://api.ihaoin.com"; public static final String HOST_BRAIN_PROD = "https://api.ihaoin.com";
public static final String HOST_BRAIN_TEST = "https://api.ihaoin.com"; public static final String HOST_BRAIN_TEST = "http://47.94.241.71:10004";
// public static final String HOST_BRAIN_TEST = "http://brain-dev.ihaoin.com"; // public static final String HOST_BRAIN_TEST = "http://brain-dev.ihaoin.com";
} }
...@@ -6,10 +6,11 @@ public class Base { ...@@ -6,10 +6,11 @@ public class Base {
public static final Integer DELETE = 2; public static final Integer DELETE = 2;
private static final String SOCKET_HOST_PROD = "http://192.168.8.101:8000"; private static final String SOCKET_HOST_PROD = "http://192.168.8.101:8000";
private static final String SOCKET_HOST_DEBUG = "http://192.168.1.155:8000"; private static final String SOCKET_HOST_DEBUG = "http://192.168.8.101:8000";
private static String SOCKET_HOST = AppConfig.DEBUG ? SOCKET_HOST_DEBUG : SOCKET_HOST_PROD; private static String SOCKET_HOST = AppConfig.DEBUG ? SOCKET_HOST_DEBUG : SOCKET_HOST_PROD;
public static final String NSP_UPGRADE = SOCKET_HOST + "/upgrade"; public static final String NSP_UPGRADE = SOCKET_HOST + "/upgrade";
public static final String NSP_KDS = SOCKET_HOST + "/kds"; public static final String NSP_KDS = SOCKET_HOST + "/kds";
public static final String NSP_INTERACTION = SOCKET_HOST + "/interaction";
public static final String NSP_MACHINE = SOCKET_HOST + "/getMachineInfo"; public static final String NSP_MACHINE = SOCKET_HOST + "/getMachineInfo";
public static final String PUSH_DEFAULT_EXTRA = "PUSH_DEFAULT_EXTRA"; public static final String PUSH_DEFAULT_EXTRA = "PUSH_DEFAULT_EXTRA";
......
...@@ -31,9 +31,9 @@ public class MachineInfoSocket extends Thread { ...@@ -31,9 +31,9 @@ public class MachineInfoSocket extends Thread {
private void connectSocket() { private void connectSocket() {
try { try {
mSocket = IO.socket(Base.NSP_MACHINE); mSocket = IO.socket(Base.NSP_MACHINE);
mSocket.connect();
mSocket.on("connect", onConnect); mSocket.on("connect", onConnect);
mSocket.on("disconnect", onDisconnect); mSocket.on("disconnect", onDisconnect);
mSocket.connect();
} catch (Exception e) { } catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage()); Utils.i("连接server失败,错误原因:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
......
package com.ihaoin.hooloo.device.interaction;
import android.content.Context;
import com.ihaoin.hooloo.device.base.Base;
import com.ihaoin.hooloo.device.util.CollectionUtils;
import com.ihaoin.hooloo.device.util.StringUtils;
import com.ihaoin.hooloo.device.util.Utils;
import io.socket.client.Ack;
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;
/** Linux通信 交互屏 */
public class InteractionSocket extends Thread {
private Context mContext;
private Socket mSocket;
public InteractionSocket(Context context) {
this.mContext = context;
}
@Override
public void run() {
connectSocket();
}
private void connectSocket() {
try {
mSocket = IO.socket(Base.NSP_INTERACTION);
mSocket.on("connect", onConnect);
mSocket.on("disconnect", onDisconnect);
mSocket.on("reply", onReply);
mSocket.connect();
} catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
private Emitter.Listener onConnect = args -> {
Utils.i("interaction socket connected");
mSocket.emit("notice", "", (Ack) ack -> process("notice", ack));
};
private Emitter.Listener onDisconnect = args -> {
Utils.i("interaction socket disconnected");
};
private Emitter.Listener onReply = args -> {
Utils.i("interaction socket reply");
process("reply", args);
};
private void process(String func, Object[] args) {
if (CollectionUtils.isEmpty(args)) {
Utils.i("interaction " + func + " args empty");
return;
}
String content = args[0].toString();
if (StringUtils.isEmpty(content)) {
Utils.i("interaction " + func + " content empty");
return;
}
// InteractionMsg msg = JsonUtils.readValue(content, InteractionMsg.class);
// if (msg == null) {
// Utils.i("interaction " + func + " msg empty");
// return;
// }
Utils.i("interaction " + func + " receive msg: " + content);
// Utils.sendInteractionMsgBroadcast(mContext, msg);
}
public void close() {
try {
Utils.i("close interaction socket");
if (mSocket != null) {
mSocket.disconnect();
mSocket.off("connect", onConnect);
mSocket.off("disconnect", onDisconnect);
mSocket.off("reply", onReply);
// mSocket.close();
// mSocket = null;
}
} catch (Exception e) {
Utils.i("close失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
public void sendMessage(String content) {
if (mSocket == null) {
Utils.i("interaction socket未连接");
return;
}
try {
mSocket.emit("notice", content, (Ack) args -> {
});
} catch (Exception e) {
Utils.i("发送消息失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
}
...@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.data.vo.PostersVo; import com.ihaoin.hooloo.device.data.vo.PostersVo;
import com.ihaoin.hooloo.device.interaction.InteractionSocket;
import com.ihaoin.hooloo.device.interaction.adapter.ImagePagerAdapter; import com.ihaoin.hooloo.device.interaction.adapter.ImagePagerAdapter;
import com.ihaoin.hooloo.device.network.HttpUtil; import com.ihaoin.hooloo.device.network.HttpUtil;
import com.ihaoin.hooloo.device.network.NetworkHandler; import com.ihaoin.hooloo.device.network.NetworkHandler;
...@@ -36,6 +37,7 @@ public class InteractionPresentation extends Presentation { ...@@ -36,6 +37,7 @@ public class InteractionPresentation extends Presentation {
private GetPostersThread getPostersThread = null; private GetPostersThread getPostersThread = null;
private GetPostersHandler getPostersHandler = new GetPostersHandler(); private GetPostersHandler getPostersHandler = new GetPostersHandler();
private InteractionSocket socket;
public InteractionPresentation(Context outerContext, Display display) { public InteractionPresentation(Context outerContext, Display display) {
super(outerContext, display); super(outerContext, display);
...@@ -47,13 +49,25 @@ public class InteractionPresentation extends Presentation { ...@@ -47,13 +49,25 @@ public class InteractionPresentation extends Presentation {
setContentView(R.layout.present_interaction); setContentView(R.layout.present_interaction);
initViews(); initViews();
// startSocket();
setOnDismissListener(dismissListener); setOnDismissListener(dismissListener);
getPostersThread = new GetPostersThread(); getPostersThread = new GetPostersThread();
getPostersThread.start(); getPostersThread.start();
} }
// private void startSocket() {
// socket = new InteractionSocket(this.getContext());
// socket.start();
// }
//
// private void stopSocket() {
// if (socket != null) {
// socket.close();
// socket = null;
// }
// }
private void initViews() { private void initViews() {
imagePager = findViewById(R.id.image_pager); imagePager = findViewById(R.id.image_pager);
pagerHandler = new PagerHandler(); pagerHandler = new PagerHandler();
...@@ -94,9 +108,9 @@ public class InteractionPresentation extends Presentation { ...@@ -94,9 +108,9 @@ public class InteractionPresentation extends Presentation {
if (state == 2) { if (state == 2) {
times = System.currentTimeMillis(); times = System.currentTimeMillis();
} }
if (state == 0) { // if (state == 0) {
Utils.i("he state: " + state + ", times: " + (System.currentTimeMillis() - times)); // Utils.i("he state: " + state + ", times: " + (System.currentTimeMillis() - times));
} // }
} }
}; };
...@@ -200,7 +214,7 @@ public class InteractionPresentation extends Presentation { ...@@ -200,7 +214,7 @@ public class InteractionPresentation extends Presentation {
// imagePager.setCurrentItem(pagerIndex, true); // imagePager.setCurrentItem(pagerIndex, true);
pagerIndex++; pagerIndex++;
Utils.i("showImage: " + pagerIndex); // Utils.i("showImage: " + pagerIndex);
imagePager.smoothScrollToPosition(pagerIndex); imagePager.smoothScrollToPosition(pagerIndex);
} }
} }
...@@ -215,5 +229,6 @@ public class InteractionPresentation extends Presentation { ...@@ -215,5 +229,6 @@ public class InteractionPresentation extends Presentation {
pagerThread.interrupt(); pagerThread.interrupt();
pagerThread = null; pagerThread = null;
} }
// stopSocket();
}; };
} }
...@@ -30,20 +30,21 @@ public class KDSSocket extends Thread { ...@@ -30,20 +30,21 @@ public class KDSSocket extends Thread {
private void connectSocket() { private void connectSocket() {
try { try {
Utils.i("kds socket connecting " + Base.NSP_KDS);
mSocket = IO.socket(Base.NSP_KDS); mSocket = IO.socket(Base.NSP_KDS);
mSocket.connect();
mSocket.on("connect", onConnect); mSocket.on("connect", onConnect);
mSocket.on("disconnect", onDisconnect); mSocket.on("disconnect", onDisconnect);
mSocket.on("reply", onReply); mSocket.on("reply", onReply);
mSocket.connect();
} catch (Exception e) { } catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage()); Utils.i("kds 连接server失败,错误原因:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
private Emitter.Listener onConnect = args -> { private Emitter.Listener onConnect = args -> {
Utils.i("kds socket connected"); Utils.i("kds socket connected");
mSocket.emit("notice", "test", (Ack) ack -> Utils.i("notice: " + JsonUtils.toString(ack))); mSocket.emit("notice", "", (Ack) ack -> Utils.i("kds notice: " + JsonUtils.toString(ack)));
}; };
private Emitter.Listener onDisconnect = args -> { private Emitter.Listener onDisconnect = args -> {
...@@ -53,17 +54,17 @@ public class KDSSocket extends Thread { ...@@ -53,17 +54,17 @@ public class KDSSocket extends Thread {
private Emitter.Listener onReply = args -> { private Emitter.Listener onReply = args -> {
Utils.i("kds socket reply"); Utils.i("kds socket reply");
if (CollectionUtils.isEmpty(args)) { if (CollectionUtils.isEmpty(args)) {
Utils.i("reply args empty"); Utils.i("kds reply args empty");
return; return;
} }
String content = args[0].toString(); String content = args[0].toString();
if (StringUtils.isEmpty(content)) { if (StringUtils.isEmpty(content)) {
Utils.i("reply content empty"); Utils.i("kds reply content empty");
return; return;
} }
KDSMsg msg = JsonUtils.readValue(content, KDSMsg.class); KDSMsg msg = JsonUtils.readValue(content, KDSMsg.class);
if (msg == null) { if (msg == null) {
Utils.i("reply msg empty"); Utils.i("kds reply msg empty");
return; return;
} }
Utils.i("kds reply: " + content); Utils.i("kds reply: " + content);
...@@ -82,7 +83,7 @@ public class KDSSocket extends Thread { ...@@ -82,7 +83,7 @@ public class KDSSocket extends Thread {
// mSocket = null; // mSocket = null;
} }
} catch (Exception e) { } catch (Exception e) {
Utils.i("close失败,错误原因:" + e.getMessage()); Utils.i("kds close失败,错误原因:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
...@@ -97,7 +98,7 @@ public class KDSSocket extends Thread { ...@@ -97,7 +98,7 @@ public class KDSSocket extends Thread {
}); });
} catch (Exception e) { } catch (Exception e) {
Utils.i("发送消息失败,错误原因:" + e.getMessage()); Utils.i("kds 发送消息失败,错误原因:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
......
...@@ -78,7 +78,7 @@ public class KdsPresentation extends Presentation { ...@@ -78,7 +78,7 @@ public class KdsPresentation extends Presentation {
setOnDismissListener(dismissListener); setOnDismissListener(dismissListener);
startTimer(); startTimer();
startSocket(); // startSocket();
new OrderToasterThread().start(); new OrderToasterThread().start();
...@@ -177,9 +177,9 @@ public class KdsPresentation extends Presentation { ...@@ -177,9 +177,9 @@ public class KdsPresentation extends Presentation {
if (state == 2) { if (state == 2) {
times = System.currentTimeMillis(); times = System.currentTimeMillis();
} }
if (state == 0) { // if (state == 0) {
Utils.i("he state: " + state + ", times: " + (System.currentTimeMillis() - times)); // Utils.i("he state: " + state + ", times: " + (System.currentTimeMillis() - times));
} // }
} }
}; };
...@@ -196,17 +196,17 @@ public class KdsPresentation extends Presentation { ...@@ -196,17 +196,17 @@ public class KdsPresentation extends Presentation {
imagePagerAdapter.setImages(mainData.getImages().getLeft().stream().filter(x -> !StringUtils.isEmpty(x)).collect(Collectors.toList())); imagePagerAdapter.setImages(mainData.getImages().getLeft().stream().filter(x -> !StringUtils.isEmpty(x)).collect(Collectors.toList()));
} }
private void startSocket() { // private void startSocket() {
kdsSocket = new KDSSocket(this.getContext()); // kdsSocket = new KDSSocket(this.getContext());
kdsSocket.start(); // kdsSocket.start();
} // }
//
private void stopSocket() { // private void stopSocket() {
if (kdsSocket != null) { // if (kdsSocket != null) {
kdsSocket.close(); // kdsSocket.close();
kdsSocket = null; // kdsSocket = null;
} // }
} // }
private TimerThread timerThread; private TimerThread timerThread;
...@@ -252,7 +252,7 @@ public class KdsPresentation extends Presentation { ...@@ -252,7 +252,7 @@ public class KdsPresentation extends Presentation {
return; return;
} }
imagePosition++; imagePosition++;
Utils.i("showImage: " + imagePosition); // Utils.i("showImage: " + imagePosition);
recyclerImagePager.smoothScrollToPosition(imagePosition); recyclerImagePager.smoothScrollToPosition(imagePosition);
} }
...@@ -480,8 +480,7 @@ public class KdsPresentation extends Presentation { ...@@ -480,8 +480,7 @@ public class KdsPresentation extends Presentation {
timerThread.interrupt(); timerThread.interrupt();
timerThread = null; timerThread = null;
} }
// stopSocket();
stopSocket();
}; };
private KDSMessageReceiver mKDSMessageReceiver = null; private KDSMessageReceiver mKDSMessageReceiver = null;
......
...@@ -11,6 +11,7 @@ import androidx.annotation.NonNull; ...@@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.ihaoin.hooloo.device.base.AppConfig; import com.ihaoin.hooloo.device.base.AppConfig;
import com.ihaoin.hooloo.device.base.Base; import com.ihaoin.hooloo.device.base.Base;
import com.ihaoin.hooloo.device.data.vo.KDSMsg;
import com.ihaoin.hooloo.device.util.CollectionUtils; import com.ihaoin.hooloo.device.util.CollectionUtils;
import com.ihaoin.hooloo.device.util.JsonUtils; import com.ihaoin.hooloo.device.util.JsonUtils;
import com.ihaoin.hooloo.device.util.StringUtils; import com.ihaoin.hooloo.device.util.StringUtils;
...@@ -43,6 +44,7 @@ public class UpdateSocket extends Thread { ...@@ -43,6 +44,7 @@ public class UpdateSocket extends Thread {
mSocket.on("connect", onConnect); mSocket.on("connect", onConnect);
mSocket.on("disconnect", onDisconnect); mSocket.on("disconnect", onDisconnect);
mSocket.on("upgrade", onUpgrade); mSocket.on("upgrade", onUpgrade);
mSocket.on("reply", onReply);
mSocket.connect(); mSocket.connect();
} catch (Exception e) { } catch (Exception e) {
Utils.i(AppConfig.TAG_UPDATE, "连接server失败,错误原因:" + e.getMessage()); Utils.i(AppConfig.TAG_UPDATE, "连接server失败,错误原因:" + e.getMessage());
...@@ -117,6 +119,26 @@ public class UpdateSocket extends Thread { ...@@ -117,6 +119,26 @@ public class UpdateSocket extends Thread {
} }
} }
private Emitter.Listener onReply = args -> {
Utils.i("kds socket reply");
if (CollectionUtils.isEmpty(args)) {
Utils.i("kds reply args empty");
return;
}
String content = args[0].toString();
if (StringUtils.isEmpty(content)) {
Utils.i("kds reply content empty");
return;
}
KDSMsg msg = JsonUtils.readValue(content, KDSMsg.class);
if (msg == null) {
Utils.i("kds reply msg empty");
return;
}
Utils.i("kds reply: " + content);
Utils.sendKdsMsgBroadcast(mContext, msg);
};
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
private Handler startUpdateServiceHandler = new Handler() { private Handler startUpdateServiceHandler = new Handler() {
@Override @Override
......
...@@ -36,15 +36,15 @@ ...@@ -36,15 +36,15 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20px" android:layout_marginTop="20px"
android:text="制作完成" android:text="已完成,扫码取"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/ts_complete_text" /> android:textSize="@dimen/ts_complete_text" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="中间扫码取杯" android:text="搅拌后饮用"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/ts_complete_text" /> android:textSize="@dimen/ts_complete_text1" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout
......
...@@ -217,4 +217,5 @@ ...@@ -217,4 +217,5 @@
<dimen name="ts_setting_desc">16sp</dimen> <dimen name="ts_setting_desc">16sp</dimen>
<dimen name="ts_complete_number">250px</dimen> <dimen name="ts_complete_number">250px</dimen>
<dimen name="ts_complete_text">95px</dimen> <dimen name="ts_complete_text">95px</dimen>
<dimen name="ts_complete_text1">105px</dimen>
</resources> </resources>
...@@ -233,4 +233,5 @@ ...@@ -233,4 +233,5 @@
<dimen name="ts_setting_desc">16sp</dimen> <dimen name="ts_setting_desc">16sp</dimen>
<dimen name="ts_complete_number">220px</dimen> <dimen name="ts_complete_number">220px</dimen>
<dimen name="ts_complete_text">80px</dimen> <dimen name="ts_complete_text">80px</dimen>
<dimen name="ts_complete_text1">90px</dimen>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment