Commit f6203fad by wjg

1、优化增加空闲弹窗

2、KDS增加视频支持
parent 15a99390
...@@ -88,6 +88,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -88,6 +88,7 @@ public class GoodsDetailDialog extends Dialog {
this.setContentView(R.layout.view_goods_detail); this.setContentView(R.layout.view_goods_detail);
initViews(); initViews();
regsitTimeoutReceiver(); regsitTimeoutReceiver();
LauncherActivity.IN_MAIN = false;
} }
@Override @Override
...@@ -221,6 +222,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -221,6 +222,7 @@ public class GoodsDetailDialog extends Dialog {
pagerThread = null; pagerThread = null;
} }
unregsitTimeoutReceiver(); unregsitTimeoutReceiver();
LauncherActivity.IN_MAIN = true;
} }
}; };
......
...@@ -703,6 +703,7 @@ public class LauncherActivity extends Activity { ...@@ -703,6 +703,7 @@ public class LauncherActivity extends Activity {
public static Long TIMESTAMP = System.currentTimeMillis(); public static Long TIMESTAMP = System.currentTimeMillis();
public static Boolean TIMEOUT_TOGGLE = true; public static Boolean TIMEOUT_TOGGLE = true;
public static Boolean IN_MAIN = true;
/** 判断空闲时间定时器 */ /** 判断空闲时间定时器 */
private class TimeoutThread extends Thread { private class TimeoutThread extends Thread {
...@@ -712,12 +713,17 @@ public class LauncherActivity extends Activity { ...@@ -712,12 +713,17 @@ public class LauncherActivity extends Activity {
try { try {
while (true) { while (true) {
Thread.sleep(1000); Thread.sleep(1000);
if (!TIMEOUT_TOGGLE || HLApplication.getGoodsCount() <= 0) { // 打开确认订单弹窗,停止判断空闲 if (!TIMEOUT_TOGGLE || (IN_MAIN && HLApplication.getGoodsCount() <= 0)) {
// 打开确认订单弹窗,停止判断空闲 或 在首页,但购物车没有商品
TIMESTAMP = Utils.getTimestamp(); TIMESTAMP = Utils.getTimestamp();
continue; continue;
} }
// if (!IN_MAIN) {
// TIMESTAMP = Utils.getTimestamp();
// continue;
// }
// Log.i(AppConfig.TAG, String.valueOf(Utils.getTimestamp() - TIMESTAMP)); // Log.i(AppConfig.TAG, String.valueOf(Utils.getTimestamp() - TIMESTAMP));
if (Utils.getTimestamp() - TIMESTAMP > 1000 * 30) { if (Utils.getTimestamp() - TIMESTAMP > 1000 * 5) {
TIMESTAMP = Utils.getTimestamp(); TIMESTAMP = Utils.getTimestamp();
// Utils.fastBroadcast(HLApplication.SELF, Base.BROADCAST_ACTION_CLEAR_GOODS); // Utils.fastBroadcast(HLApplication.SELF, Base.BROADCAST_ACTION_CLEAR_GOODS);
// Utils.fastBroadcast(HLApplication.SELF, Base.BROADCAST_ACTION_TIMEOUT); // Utils.fastBroadcast(HLApplication.SELF, Base.BROADCAST_ACTION_TIMEOUT);
......
...@@ -8,8 +8,10 @@ import android.content.IntentFilter; ...@@ -8,8 +8,10 @@ import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.view.Display; import android.view.Display;
import android.view.View;
import android.widget.GridView; import android.widget.GridView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.VideoView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -48,6 +50,7 @@ public class MenuPresentation extends Presentation { ...@@ -48,6 +50,7 @@ public class MenuPresentation extends Presentation {
private ImageView imgLeft; private ImageView imgLeft;
private ImageView imgRight; private ImageView imgRight;
private VideoView vidRight;
private GridView gridCooking; private GridView gridCooking;
private GridView gridWaiting; private GridView gridWaiting;
private GridView gridCompleted; private GridView gridCompleted;
...@@ -72,6 +75,7 @@ public class MenuPresentation extends Presentation { ...@@ -72,6 +75,7 @@ public class MenuPresentation extends Presentation {
private void initViews() { private void initViews() {
imgLeft = findViewById(R.id.img_left); imgLeft = findViewById(R.id.img_left);
imgRight = findViewById(R.id.img_right); imgRight = findViewById(R.id.img_right);
vidRight = findViewById(R.id.vid_right);
gridCooking = findViewById(R.id.grid_cooking); gridCooking = findViewById(R.id.grid_cooking);
gridWaiting = findViewById(R.id.grid_waiting); gridWaiting = findViewById(R.id.grid_waiting);
gridCompleted = findViewById(R.id.grid_completed); gridCompleted = findViewById(R.id.grid_completed);
...@@ -105,14 +109,39 @@ public class MenuPresentation extends Presentation { ...@@ -105,14 +109,39 @@ public class MenuPresentation extends Presentation {
Utils.getGlide(getContext()).load(mainData.getImages().getLeft()).into(imgLeft); Utils.getGlide(getContext()).load(mainData.getImages().getLeft()).into(imgLeft);
} }
String url = "";
if (mainData.getShopState().equals(Base.FALSE)) { if (mainData.getShopState().equals(Base.FALSE)) {
Utils.getGlide(getContext()).load(getRightImage(ImageState.CLOSED.getCode())).into(imgRight); url = getRightImage(ImageState.CLOSED.getCode());
} else if (!CollectionUtils.isEmpty(cookingOrders)) { } else if (!CollectionUtils.isEmpty(cookingOrders)) {
Utils.getGlide(getContext()).load(getRightImage(ImageState.COOKING.getCode())).into(imgRight); url = getRightImage(ImageState.COOKING.getCode());
} else if (!CollectionUtils.isEmpty(completedOrders)) { } else if (!CollectionUtils.isEmpty(completedOrders)) {
Utils.getGlide(getContext()).load(getRightImage(ImageState.COMPLETED.getCode())).into(imgRight); url = getRightImage(ImageState.COMPLETED.getCode());
} else { } else {
Utils.getGlide(getContext()).load(getRightImage(ImageState.NOT_COMPLETED.getCode())).into(imgRight); url = getRightImage(ImageState.NOT_COMPLETED.getCode());
}
if (StringUtils.isEmpty(url)) {
vidRight.pause();
vidRight.setVisibility(View.INVISIBLE);
imgRight.setVisibility(View.INVISIBLE);
return;
}
// url = "http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/e6582afb60924.mp4";
if (url.substring(url.lastIndexOf(".")).equalsIgnoreCase(".mp4")) {
vidRight.setVisibility(View.VISIBLE);
imgRight.setVisibility(View.GONE);
vidRight.setOnPreparedListener(mp -> {
mp.start();
mp.setLooping(true);
});
vidRight.setVideoPath(url);
vidRight.requestFocus();
vidRight.start();
} else {
vidRight.pause();
vidRight.setVisibility(View.GONE);
imgRight.setVisibility(View.VISIBLE);
Utils.getGlide(getContext()).load(url).into(imgRight);
} }
} }
......
...@@ -40,6 +40,7 @@ public class TipsDialog extends Dialog { ...@@ -40,6 +40,7 @@ public class TipsDialog extends Dialog {
} }
initViews(); initViews();
regsitTimeoutReceiver(); regsitTimeoutReceiver();
LauncherActivity.IN_MAIN = false;
} }
private void initViews() { private void initViews() {
...@@ -65,7 +66,10 @@ public class TipsDialog extends Dialog { ...@@ -65,7 +66,10 @@ public class TipsDialog extends Dialog {
return super.dispatchTouchEvent(ev); return super.dispatchTouchEvent(ev);
} }
OnDismissListener dismissListener = dialog -> unregsitTimeoutReceiver(); OnDismissListener dismissListener = dialog -> {
unregsitTimeoutReceiver();
LauncherActivity.IN_MAIN = true;
};
private TimeoutReceiver timeoutReceiver; private TimeoutReceiver timeoutReceiver;
......
...@@ -135,5 +135,12 @@ ...@@ -135,5 +135,12 @@
android:layout_weight="0.5" android:layout_weight="0.5"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />
<VideoView
android:id="@+id/vid_right"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
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