Commit ecac0f7e by wjg

1.0.18

parent 9886d66a
......@@ -18,8 +18,8 @@ android {
applicationId "com.ihaoin.hooloo.device"
minSdkVersion 26
targetSdkVersion 30
versionCode 16
versionName "1.0.16"
versionCode 17
versionName "1.0.17"
ndk {
//选择要添加的对应 cpu 类型的 .so 库。
......
......@@ -30,6 +30,6 @@ public class AppConfig {
public static String HOST_BRAIN = "";
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";
}
......@@ -6,10 +6,11 @@ public class Base {
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_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;
public static final String NSP_UPGRADE = SOCKET_HOST + "/upgrade";
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 PUSH_DEFAULT_EXTRA = "PUSH_DEFAULT_EXTRA";
......
......@@ -31,9 +31,9 @@ public class MachineInfoSocket extends Thread {
private void connectSocket() {
try {
mSocket = IO.socket(Base.NSP_MACHINE);
mSocket.connect();
mSocket.on("connect", onConnect);
mSocket.on("disconnect", onDisconnect);
mSocket.connect();
} catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage());
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;
import com.ihaoin.hooloo.device.R;
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.network.HttpUtil;
import com.ihaoin.hooloo.device.network.NetworkHandler;
......@@ -36,6 +37,7 @@ public class InteractionPresentation extends Presentation {
private GetPostersThread getPostersThread = null;
private GetPostersHandler getPostersHandler = new GetPostersHandler();
private InteractionSocket socket;
public InteractionPresentation(Context outerContext, Display display) {
super(outerContext, display);
......@@ -47,13 +49,25 @@ public class InteractionPresentation extends Presentation {
setContentView(R.layout.present_interaction);
initViews();
// startSocket();
setOnDismissListener(dismissListener);
getPostersThread = new GetPostersThread();
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() {
imagePager = findViewById(R.id.image_pager);
pagerHandler = new PagerHandler();
......@@ -94,9 +108,9 @@ public class InteractionPresentation extends Presentation {
if (state == 2) {
times = System.currentTimeMillis();
}
if (state == 0) {
Utils.i("he state: " + state + ", times: " + (System.currentTimeMillis() - times));
}
// if (state == 0) {
// Utils.i("he state: " + state + ", times: " + (System.currentTimeMillis() - times));
// }
}
};
......@@ -200,7 +214,7 @@ public class InteractionPresentation extends Presentation {
// imagePager.setCurrentItem(pagerIndex, true);
pagerIndex++;
Utils.i("showImage: " + pagerIndex);
// Utils.i("showImage: " + pagerIndex);
imagePager.smoothScrollToPosition(pagerIndex);
}
}
......@@ -215,5 +229,6 @@ public class InteractionPresentation extends Presentation {
pagerThread.interrupt();
pagerThread = null;
}
// stopSocket();
};
}
......@@ -30,20 +30,21 @@ public class KDSSocket extends Thread {
private void connectSocket() {
try {
Utils.i("kds socket connecting " + Base.NSP_KDS);
mSocket = IO.socket(Base.NSP_KDS);
mSocket.connect();
mSocket.on("connect", onConnect);
mSocket.on("disconnect", onDisconnect);
mSocket.on("reply", onReply);
mSocket.connect();
} catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage());
Utils.i("kds 连接server失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
private Emitter.Listener onConnect = args -> {
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 -> {
......@@ -53,17 +54,17 @@ public class KDSSocket extends Thread {
private Emitter.Listener onReply = args -> {
Utils.i("kds socket reply");
if (CollectionUtils.isEmpty(args)) {
Utils.i("reply args empty");
Utils.i("kds reply args empty");
return;
}
String content = args[0].toString();
if (StringUtils.isEmpty(content)) {
Utils.i("reply content empty");
Utils.i("kds reply content empty");
return;
}
KDSMsg msg = JsonUtils.readValue(content, KDSMsg.class);
if (msg == null) {
Utils.i("reply msg empty");
Utils.i("kds reply msg empty");
return;
}
Utils.i("kds reply: " + content);
......@@ -82,7 +83,7 @@ public class KDSSocket extends Thread {
// mSocket = null;
}
} catch (Exception e) {
Utils.i("close失败,错误原因:" + e.getMessage());
Utils.i("kds close失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
......@@ -97,7 +98,7 @@ public class KDSSocket extends Thread {
});
} catch (Exception e) {
Utils.i("发送消息失败,错误原因:" + e.getMessage());
Utils.i("kds 发送消息失败,错误原因:" + e.getMessage());
e.printStackTrace();
}
}
......
......@@ -78,7 +78,7 @@ public class KdsPresentation extends Presentation {
setOnDismissListener(dismissListener);
startTimer();
startSocket();
// startSocket();
new OrderToasterThread().start();
......@@ -177,9 +177,9 @@ public class KdsPresentation extends Presentation {
if (state == 2) {
times = System.currentTimeMillis();
}
if (state == 0) {
Utils.i("he state: " + state + ", times: " + (System.currentTimeMillis() - times));
}
// if (state == 0) {
// Utils.i("he state: " + state + ", times: " + (System.currentTimeMillis() - times));
// }
}
};
......@@ -196,17 +196,17 @@ public class KdsPresentation extends Presentation {
imagePagerAdapter.setImages(mainData.getImages().getLeft().stream().filter(x -> !StringUtils.isEmpty(x)).collect(Collectors.toList()));
}
private void startSocket() {
kdsSocket = new KDSSocket(this.getContext());
kdsSocket.start();
}
private void stopSocket() {
if (kdsSocket != null) {
kdsSocket.close();
kdsSocket = null;
}
}
// private void startSocket() {
// kdsSocket = new KDSSocket(this.getContext());
// kdsSocket.start();
// }
//
// private void stopSocket() {
// if (kdsSocket != null) {
// kdsSocket.close();
// kdsSocket = null;
// }
// }
private TimerThread timerThread;
......@@ -252,7 +252,7 @@ public class KdsPresentation extends Presentation {
return;
}
imagePosition++;
Utils.i("showImage: " + imagePosition);
// Utils.i("showImage: " + imagePosition);
recyclerImagePager.smoothScrollToPosition(imagePosition);
}
......@@ -480,8 +480,7 @@ public class KdsPresentation extends Presentation {
timerThread.interrupt();
timerThread = null;
}
stopSocket();
// stopSocket();
};
private KDSMessageReceiver mKDSMessageReceiver = null;
......
......@@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
import com.fasterxml.jackson.databind.JsonNode;
import com.ihaoin.hooloo.device.base.AppConfig;
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.JsonUtils;
import com.ihaoin.hooloo.device.util.StringUtils;
......@@ -43,6 +44,7 @@ public class UpdateSocket extends Thread {
mSocket.on("connect", onConnect);
mSocket.on("disconnect", onDisconnect);
mSocket.on("upgrade", onUpgrade);
mSocket.on("reply", onReply);
mSocket.connect();
} catch (Exception e) {
Utils.i(AppConfig.TAG_UPDATE, "连接server失败,错误原因:" + e.getMessage());
......@@ -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")
private Handler startUpdateServiceHandler = new Handler() {
@Override
......
......@@ -36,15 +36,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20px"
android:text="制作完成"
android:text="已完成,扫码取"
android:textColor="@color/white"
android:textSize="@dimen/ts_complete_text" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="中间扫码取杯"
android:text="搅拌后饮用"
android:textColor="@color/white"
android:textSize="@dimen/ts_complete_text" />
android:textSize="@dimen/ts_complete_text1" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
......
......@@ -217,4 +217,5 @@
<dimen name="ts_setting_desc">16sp</dimen>
<dimen name="ts_complete_number">250px</dimen>
<dimen name="ts_complete_text">95px</dimen>
<dimen name="ts_complete_text1">105px</dimen>
</resources>
......@@ -233,4 +233,5 @@
<dimen name="ts_setting_desc">16sp</dimen>
<dimen name="ts_complete_number">220px</dimen>
<dimen name="ts_complete_text">80px</dimen>
<dimen name="ts_complete_text1">90px</dimen>
</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