Commit 4749ba25 by wjg

v2

parent 3e1b1fe1
...@@ -6,7 +6,6 @@ import android.graphics.Typeface; ...@@ -6,7 +6,6 @@ import android.graphics.Typeface;
import com.ihaoin.hooloo.device.base.AppConfig; import com.ihaoin.hooloo.device.base.AppConfig;
import com.ihaoin.hooloo.device.data.MainData; import com.ihaoin.hooloo.device.data.MainData;
import com.ihaoin.hooloo.device.data.TrolleyGoods; import com.ihaoin.hooloo.device.data.TrolleyGoods;
import com.ihaoin.hooloo.device.data.enums.PresentState;
import com.ihaoin.hooloo.device.data.vo.Category; import com.ihaoin.hooloo.device.data.vo.Category;
import com.ihaoin.hooloo.device.network.HttpUtil; import com.ihaoin.hooloo.device.network.HttpUtil;
import com.ihaoin.hooloo.device.util.CollectionUtils; import com.ihaoin.hooloo.device.util.CollectionUtils;
...@@ -69,13 +68,6 @@ public class HLApplication extends Application { ...@@ -69,13 +68,6 @@ public class HLApplication extends Application {
AppConfig.HOST = AppConfig.HOST_PROD; AppConfig.HOST = AppConfig.HOST_PROD;
AppConfig.WX_URL = AppConfig.WX_URL_PROD; AppConfig.WX_URL = AppConfig.WX_URL_PROD;
} }
// 第一个点单屏默认显示交互屏
if (AppConfig.DEFAULT_SCREEN_NO.equals("1")) {
AppConfig.DEFAULT_PRESENT = PresentState.KDS.getName();
} else {
AppConfig.DEFAULT_PRESENT = PresentState.INTERACTION.getName();
}
} }
private static MainData mainData = new MainData(); private static MainData mainData = new MainData();
......
package com.ihaoin.hooloo.device.base; package com.ihaoin.hooloo.device.base;
import com.ihaoin.hooloo.device.data.enums.PresentState;
public class AppConfig { public class AppConfig {
public static Boolean DEBUG = true; // TODO 编译环境 public static Boolean DEBUG = true; // TODO 编译环境
/** 点单屏编码, 1-菜单屏,2-交互屏 */ /** 点单屏编码, 1-菜单屏,2-交互屏 */
public static String DEFAULT_SCREEN_NO = "1"; // TODO 编译点单屏编码 public static Integer DEFAULT_SCREEN_NO = 1; // TODO 编译点单屏编码
/** 副屏内容 */
public static String DEFAULT_PRESENT = PresentState.KDS.getName();
public static String HL = "HL"; public static String HL = "HL";
public static String TAG = HL + "_TEST"; public static String TAG = HL + "_TEST";
public static String TAG_PUSH = HL + "_PUSH"; public static String TAG_PUSH = HL + "_PUSH";
public static String TAG_NETWORK = HL + "_NETWORK"; public static String TAG_NETWORK = HL + "_NETWORK";
public static String TAG_UPDATE = HL + "_UPDATE";
public static String UMENG_APPKEY = "6294708905844627b598aa78"; public static String UMENG_APPKEY = "6294708905844627b598aa78";
public static String UMENG_CHANNEL = "DEVICE_ORDER"; public static String UMENG_CHANNEL = "DEVICE_ORDER";
......
...@@ -16,7 +16,6 @@ public class Base { ...@@ -16,7 +16,6 @@ public class Base {
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";
public static final String PUSH_ACTION_ORDER_STATE_CHANGED = "ORDER_STATE_CHANGED";
public static final String PUSH_ACTION_SKU_STATE_CHANGED = "SKU_STATE_CHANGED"; public static final String PUSH_ACTION_SKU_STATE_CHANGED = "SKU_STATE_CHANGED";
public static final String PUSH_ACTION_QRCODE_VISITED = "QRCODE_VISITED"; public static final String PUSH_ACTION_QRCODE_VISITED = "QRCODE_VISITED";
public static final String PUSH_ACTION_GOODS_CHANGED = "GOODS_CHANGED"; public static final String PUSH_ACTION_GOODS_CHANGED = "GOODS_CHANGED";
...@@ -36,6 +35,4 @@ public class Base { ...@@ -36,6 +35,4 @@ public class Base {
public static final String BROADCAST_ACTION_KDS_INFO = "ACTION_KDS_INFO"; public static final String BROADCAST_ACTION_KDS_INFO = "ACTION_KDS_INFO";
public static final String BROADCAST_ACTION_INTERACTION_INFO = "ACTION_INTERACTION_INFO"; public static final String BROADCAST_ACTION_INTERACTION_INFO = "ACTION_INTERACTION_INFO";
public static final String BROADCAST_ACTION_GET_MACHINE_INFO = "ACTION_GET_MACHINE_INFO"; public static final String BROADCAST_ACTION_GET_MACHINE_INFO = "ACTION_GET_MACHINE_INFO";
public static final String BROADCAST_ACTION_PLAY_NEXT = "BROADCAST_ACTION_PLAY_NEXT";
} }
...@@ -40,9 +40,9 @@ public class MachineInfoSocket extends Thread { ...@@ -40,9 +40,9 @@ public class MachineInfoSocket extends Thread {
} }
} }
Emitter.Listener onConnect = args -> Utils.i("machine socket connected"); private Emitter.Listener onConnect = args -> Utils.i("machine socket connected");
Emitter.Listener onDisconnect = args -> Utils.i("machine socket disconnected"); private Emitter.Listener onDisconnect = args -> Utils.i("machine socket disconnected");
public void close() { public void close() {
try { try {
......
...@@ -2,20 +2,35 @@ package com.ihaoin.hooloo.device.component; ...@@ -2,20 +2,35 @@ package com.ihaoin.hooloo.device.component;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.util.CollectionUtils; import com.ihaoin.hooloo.device.util.CollectionUtils;
import com.ihaoin.hooloo.device.util.Utils; import com.ihaoin.hooloo.device.util.Utils;
import java.util.List; import java.util.List;
public class IntroViewPager extends ViewPager { public class IntroViewPager extends ViewPager {
private boolean isCanScroll = true;
public boolean isCanScroll() {
return isCanScroll;
}
public void setCanScroll(boolean canScroll) {
isCanScroll = canScroll;
}
public IntroViewPager(@NonNull Context context) { public IntroViewPager(@NonNull Context context) {
super(context); super(context);
} }
...@@ -25,6 +40,25 @@ public class IntroViewPager extends ViewPager { ...@@ -25,6 +40,25 @@ public class IntroViewPager extends ViewPager {
} }
@Override @Override
public boolean onTouchEvent(MotionEvent ev) {
if (isCanScroll) {
return super.onTouchEvent(ev);
} else {
return false;
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (isCanScroll) {
return super.onInterceptTouchEvent(ev);
} else {
return false;
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (getAdapter() == null) { if (getAdapter() == null) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec);
...@@ -32,28 +66,29 @@ public class IntroViewPager extends ViewPager { ...@@ -32,28 +66,29 @@ public class IntroViewPager extends ViewPager {
} }
int index = getCurrentItem(); int index = getCurrentItem();
int height = 0; int height = 0;
View v = getView(index); View v = getChildAt(index % introUrls.size());
if (v != null) { if (v != null) {
v.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); v.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
height = v.getMeasuredHeight(); height = v.getMeasuredHeight();
} }
Utils.i("onMeasure v=" + (v != null) + ", index=" + index + ", h=" + height);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec);
} }
private List<View> introViews; private List<String> introUrls;
public void setIntroViews(List<View> introViews) { public void setIntroUrls(List<String> introUrls) {
this.introViews = introViews; this.introUrls = introUrls;
this.setAdapter(pagerAdapter); this.setAdapter(pagerAdapter);
} }
public View getView(int index) { // public View getView(int index) {
if (CollectionUtils.isEmpty(introViews)) { // if (CollectionUtils.isEmpty(introViews)) {
return null; // return null;
} // }
return introViews.get(index % introViews.size()); // return introViews.get(index % introViews.size());
} // }
public int getCount() { public int getCount() {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
...@@ -66,7 +101,7 @@ public class IntroViewPager extends ViewPager { ...@@ -66,7 +101,7 @@ public class IntroViewPager extends ViewPager {
private PagerAdapter pagerAdapter = new PagerAdapter() { private PagerAdapter pagerAdapter = new PagerAdapter() {
@Override @Override
public int getCount() { public int getCount() {
return CollectionUtils.isEmpty(introViews) ? 0 : Integer.MAX_VALUE; return CollectionUtils.isEmpty(introUrls) ? 0 : Integer.MAX_VALUE;
} }
@Override @Override
...@@ -76,15 +111,14 @@ public class IntroViewPager extends ViewPager { ...@@ -76,15 +111,14 @@ public class IntroViewPager extends ViewPager {
@Override @Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
View view = getView(position); container.removeView((View) object);
container.removeView(view);
Utils.i("destroyItem: " + position); Utils.i("destroyItem: " + position);
} }
@NonNull @NonNull
@Override @Override
public Object instantiateItem(@NonNull ViewGroup container, int position) { public Object instantiateItem(@NonNull ViewGroup container, int position) {
if (CollectionUtils.isEmpty(introViews)) { if (CollectionUtils.isEmpty(introUrls)) {
return null; return null;
} }
Utils.i("instantiateItem: " + position); Utils.i("instantiateItem: " + position);
...@@ -93,4 +127,12 @@ public class IntroViewPager extends ViewPager { ...@@ -93,4 +127,12 @@ public class IntroViewPager extends ViewPager {
return view; return view;
} }
}; };
private View getView(Integer position) {
ImageView imageView = (ImageView) LayoutInflater.from(getContext()).inflate(R.layout.intro_image, null);
String url = introUrls.get(position % introUrls.size());
Utils.i("getView: " + (position % introUrls.size()));
Utils.getGlide(getContext()).load(url).diskCacheStrategy(DiskCacheStrategy.ALL).into(imageView);
return imageView;
}
} }
package com.ihaoin.hooloo.device.component;
import android.view.animation.BounceInterpolator;
public class MyBounceInterpolator extends BounceInterpolator {
private static float bounce(float t) {
return t * t * 8.0f;
}
@Override
public float getInterpolation(float t) {
// _b(t) = t * t * 8
// bs(t) = _b(t) for t < 0.3535
// bs(t) = _b(t - 0.54719) + 0.7 for t < 0.7408
// bs(t) = _b(t - 0.8526) + 0.9 for t < 0.9644
// bs(t) = _b(t - 1.0435) + 0.95 for t <= 1.0
// b(t) = bs(t * 1.1226)
t *= 1.1226f;
if (t < 0.3535f) return bounce(t + 0.02f);
else if (t < 0.7408f) return bounce(t - 0.54719f) + 0.85f;
else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.95f;
else return bounce(t - 1.0435f) + 0.95f;
}
}
...@@ -125,6 +125,7 @@ public class ParticleSmasher extends View { ...@@ -125,6 +125,7 @@ public class ParticleSmasher extends View {
*/ */
public void reShowView(View view) { public void reShowView(View view) {
view.animate().setDuration(100).setStartDelay(0).scaleX(1).scaleY(1).translationX(0).translationY(0).alpha(1).start(); view.animate().setDuration(100).setStartDelay(0).scaleX(1).scaleY(1).translationX(0).translationY(0).alpha(1).start();
// view.setVisibility(View.VISIBLE);
} }
......
...@@ -58,7 +58,7 @@ public class SmashAnimator { ...@@ -58,7 +58,7 @@ public class SmashAnimator {
private long mStartDelay = 150L; private long mStartDelay = 150L;
private float mHorizontalMultiple = 3; // 粒子水平变化幅度 private float mHorizontalMultiple = 3; // 粒子水平变化幅度
private float mVerticalMultiple = 4; // 粒子垂直变化幅度 private float mVerticalMultiple = 4; // 粒子垂直变化幅度
private int mRadius = Utils.dp2Px(2); // 粒子基础半径 private int mRadius = Utils.dp2Px(4); // 粒子基础半径
// 加速度插值器 // 加速度插值器
private static final Interpolator DEFAULT_INTERPOLATOR = new AccelerateInterpolator(0.6f); private static final Interpolator DEFAULT_INTERPOLATOR = new AccelerateInterpolator(0.6f);
...@@ -290,8 +290,9 @@ public class SmashAnimator { ...@@ -290,8 +290,9 @@ public class SmashAnimator {
} }
}); });
valueAnimator.start(); valueAnimator.start();
// 将View 缩放至0、透明至0 // 将View 缩放至0、透明至0
view.animate().setDuration(260).setStartDelay(startDelay).scaleX(0).scaleY(0).alpha(0).start(); view.animate().setDuration(260).setStartDelay(startDelay).scaleX(0).scaleY(0).alpha(0).start();
// view.setVisibility(View.INVISIBLE);
} }
......
package com.ihaoin.hooloo.device.data.enums; package com.ihaoin.hooloo.device.data.enums;
import com.ihaoin.hooloo.device.util.StringUtils;
public enum PresentState { public enum PresentState {
NONE("不显示"), NONE(0, "不显示"),
KDS("菜单屏"), KDS(1, "菜单屏"),
INTERACTION("交互屏"); INTERACTION(2, "交互屏");
private Integer code;
private String name; private String name;
PresentState(String name) { PresentState(Integer code, String name) {
this.code = code;
this.name = name; this.name = name;
} }
public static PresentState get(String name) { public static PresentState get(Integer code) {
if (StringUtils.isEmpty(name)) { if (code == null) {
return NONE; return NONE;
} }
for (PresentState state : PresentState.values()) { for (PresentState state : PresentState.values()) {
if (state.getName().equals(name)) { if (state.getCode().equals(code)) {
return state; return state;
} }
} }
...@@ -28,4 +28,13 @@ public enum PresentState { ...@@ -28,4 +28,13 @@ public enum PresentState {
public String getName() { public String getName() {
return name; return name;
} }
public Integer getCode() {
return code;
}
@Override
public String toString() {
return code + "-" + name;
}
} }
package com.ihaoin.hooloo.device.data.vo; package com.ihaoin.hooloo.device.data.vo;
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.enums.ImageState; import com.ihaoin.hooloo.device.data.enums.ImageState;
import com.ihaoin.hooloo.device.util.Utils;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -33,7 +33,7 @@ public class InteractionMsg implements Serializable { ...@@ -33,7 +33,7 @@ public class InteractionMsg implements Serializable {
private String backgroundDesc; private String backgroundDesc;
/** 推荐的商品id */ /** 推荐的商品id */
private Integer goodIds; private Integer goodsId;
/** 推荐的商品 */ /** 推荐的商品 */
private String recommendGoods; private String recommendGoods;
...@@ -61,7 +61,9 @@ public class InteractionMsg implements Serializable { ...@@ -61,7 +61,9 @@ public class InteractionMsg implements Serializable {
static { static {
mIdelMsg.setPicture(ImageState.IDEL.getCode()); mIdelMsg.setPicture(ImageState.IDEL.getCode());
mIdelMsg.setIsContinue(Base.TRUE); mIdelMsg.setIsContinue(Base.TRUE);
mIdelMsg.setSentences(Utils.getSents("LOO感谢你", "感谢在美好的时间遇到了你")); if (AppConfig.DEBUG) {
// mIdelMsg.setSentences(Utils.getSents("LOO感谢你", "感谢在美好的时间遇到了你"));
}
} }
public static InteractionMsg getIdelMsg() { public static InteractionMsg getIdelMsg() {
...@@ -156,12 +158,12 @@ public class InteractionMsg implements Serializable { ...@@ -156,12 +158,12 @@ public class InteractionMsg implements Serializable {
this.recognizePerson = recognizePerson; this.recognizePerson = recognizePerson;
} }
public Integer getGoodIds() { public Integer getGoodsId() {
return goodIds; return goodsId;
} }
public void setGoodIds(Integer goodIds) { public void setGoodsId(Integer goodsId) {
this.goodIds = goodIds; this.goodsId = goodsId;
} }
public Integer getIsContinue() { public Integer getIsContinue() {
......
...@@ -10,6 +10,9 @@ public class Sentence implements Serializable { ...@@ -10,6 +10,9 @@ public class Sentence implements Serializable {
/** 字号 */ /** 字号 */
private Integer fontSize; private Integer fontSize;
/** 间距 */
private Integer marginTop;
/** 文字 */ /** 文字 */
private String sentence; private String sentence;
...@@ -36,4 +39,12 @@ public class Sentence implements Serializable { ...@@ -36,4 +39,12 @@ public class Sentence implements Serializable {
public void setSentence(String sentence) { public void setSentence(String sentence) {
this.sentence = sentence; this.sentence = sentence;
} }
public Integer getMarginTop() {
return marginTop;
}
public void setMarginTop(Integer marginTop) {
this.marginTop = marginTop;
}
} }
...@@ -10,6 +10,7 @@ import android.widget.ImageView; ...@@ -10,6 +10,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.chad.library.adapter.base.BaseSectionQuickAdapter; import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder; import com.chad.library.adapter.base.BaseViewHolder;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
...@@ -71,7 +72,7 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -71,7 +72,7 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
imgThumbnail.setImageDrawable(null); imgThumbnail.setImageDrawable(null);
} else { } else {
// Utils.getGlide(mContext).load(Utils.getThumbnailUrl(goods.getPics().getThumbnail())).apply(options).into(imgThumbnail); // Utils.getGlide(mContext).load(Utils.getThumbnailUrl(goods.getPics().getThumbnail())).apply(options).into(imgThumbnail);
Utils.getGlide(mContext).load(Utils.getThumbnailUrl(goods.getPics().getThumbnail())).into(imgThumbnail); Utils.getGlide(mContext).load(Utils.getThumbnailUrl(goods.getPics().getThumbnail())).diskCacheStrategy(DiskCacheStrategy.ALL).into(imgThumbnail);
} }
Sku sku = Utils.getDefaultSku(goods.getSkus()); Sku sku = Utils.getDefaultSku(goods.getSkus());
......
...@@ -6,6 +6,7 @@ import android.view.ViewGroup; ...@@ -6,6 +6,7 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder; import com.chad.library.adapter.base.BaseViewHolder;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
...@@ -35,7 +36,7 @@ public class RecommendAdapter extends BaseQuickAdapter<ScrollBean, BaseViewHolde ...@@ -35,7 +36,7 @@ public class RecommendAdapter extends BaseQuickAdapter<ScrollBean, BaseViewHolde
// RoundedCorners roundedCorners = new RoundedCorners(5); // RoundedCorners roundedCorners = new RoundedCorners(5);
// RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); // RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
Utils.getGlide(mContext).load(recommend.getPic()).into(imgRecommend); Utils.getGlide(mContext).load(recommend.getPic()).diskCacheStrategy(DiskCacheStrategy.ALL).into(imgRecommend);
View layoutItem = helper.getView(R.id.layout_item); View layoutItem = helper.getView(R.id.layout_item);
layoutItem.setOnClickListener(v -> { layoutItem.setOnClickListener(v -> {
......
...@@ -155,7 +155,7 @@ public class ConfirmOrderDialog extends Dialog { ...@@ -155,7 +155,7 @@ public class ConfirmOrderDialog extends Dialog {
try { try {
ConfirmOrder confirmOrder = new ConfirmOrder(); ConfirmOrder confirmOrder = new ConfirmOrder();
confirmOrder.setMachineCode(AppConfig.MACHINE_CODE); confirmOrder.setMachineCode(AppConfig.MACHINE_CODE);
confirmOrder.setScreenNo(SharedPreferencesUtils.getScreenNo(getContext())); confirmOrder.setScreenNo(String.valueOf(SharedPreferencesUtils.getScreenNo(getContext())));
confirmOrder.setSeqNo(genSeqNo()); confirmOrder.setSeqNo(genSeqNo());
confirmOrder.setGoods(confirmGoods); confirmOrder.setGoods(confirmGoods);
String json = JsonUtils.getMapper().writeValueAsString(confirmOrder); String json = JsonUtils.getMapper().writeValueAsString(confirmOrder);
......
...@@ -24,6 +24,7 @@ import android.widget.TextView; ...@@ -24,6 +24,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.ihaoin.hooloo.device.HLApplication; import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
...@@ -75,8 +76,6 @@ public class GoodsDetailDialog extends Dialog { ...@@ -75,8 +76,6 @@ public class GoodsDetailDialog extends Dialog {
private Button butnBuy; private Button butnBuy;
private Button butnTrolley; private Button butnTrolley;
private List<View> introViews;
public GoodsDetailDialog(@NonNull Context context, Goods goods) { public GoodsDetailDialog(@NonNull Context context, Goods goods) {
super(context); super(context);
this.mGoods = goods; this.mGoods = goods;
...@@ -135,21 +134,19 @@ public class GoodsDetailDialog extends Dialog { ...@@ -135,21 +134,19 @@ public class GoodsDetailDialog extends Dialog {
butnClose.setOnClickListener(x -> dismiss()); butnClose.setOnClickListener(x -> dismiss());
introViews = new ArrayList<>();
if (mGoods.getPics() != null && !CollectionUtils.isEmpty(mGoods.getPics().getIntroImages())) { if (mGoods.getPics() != null && !CollectionUtils.isEmpty(mGoods.getPics().getIntroImages())) {
introPager.setIntroUrls(mGoods.getPics().getIntroImages());
for (int i = 0; i < mGoods.getPics().getIntroImages().size(); i++) { for (int i = 0; i < mGoods.getPics().getIntroImages().size(); i++) {
String url = mGoods.getPics().getIntroImages().get(i);
View imgIntro = getIntroImage(url);
View btnIntro = getIntroButton(i); View btnIntro = getIntroButton(i);
introViews.add(imgIntro);
introIndicator.addView(btnIntro); introIndicator.addView(btnIntro);
} }
introPager.setIntroViews(introViews);
Utils.check(introIndicator, 0); Utils.check(introIndicator, 0);
// introIndicator.check(0); introIndicator.check(0);
if (introIndicator.getChildCount() > 1) { if (mGoods.getPics().getIntroImages().size() <= 1) {
introIndicator.setVisibility(View.VISIBLE); introPager.setCanScroll(false);
} else {
startPagerThread(); startPagerThread();
introIndicator.setVisibility(View.VISIBLE);
introPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { introPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override @Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
...@@ -158,7 +155,8 @@ public class GoodsDetailDialog extends Dialog { ...@@ -158,7 +155,8 @@ public class GoodsDetailDialog extends Dialog {
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
Utils.check(introIndicator, position); int index = position % introIndicator.getChildCount();
Utils.check(introIndicator, index);
} }
@Override @Override
...@@ -254,17 +252,13 @@ public class GoodsDetailDialog extends Dialog { ...@@ -254,17 +252,13 @@ public class GoodsDetailDialog extends Dialog {
} }
} }
private Integer introPagerIndex = 0;
private class PagerHandler extends Handler { private class PagerHandler extends Handler {
@Override @Override
public void handleMessage(@NonNull Message msg) { public void handleMessage(@NonNull Message msg) {
int index = introPager.getCurrentItem(); introPagerIndex++;
int count = introPager.getCount(); introPager.setCurrentItem(introPagerIndex, true);
if (index + 1 >= count) {
index = 0;
} else {
index++;
}
introPager.setCurrentItem(index, true);
} }
} }
...@@ -288,7 +282,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -288,7 +282,7 @@ public class GoodsDetailDialog extends Dialog {
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
imgIntro.setLayoutParams(layoutParams); imgIntro.setLayoutParams(layoutParams);
imgIntro.setAdjustViewBounds(true); imgIntro.setAdjustViewBounds(true);
Utils.getGlide(getContext()).load(url).into(imgIntro); Utils.getGlide(getContext()).load(url).diskCacheStrategy(DiskCacheStrategy.ALL).into(imgIntro);
return imgIntro; return imgIntro;
} }
...@@ -579,7 +573,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -579,7 +573,7 @@ public class GoodsDetailDialog extends Dialog {
imageView.setAdjustViewBounds(true); imageView.setAdjustViewBounds(true);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
// layoutParams.bottomMargin = Utils.getDimens(getContext(), R.dimen.padding5); // layoutParams.bottomMargin = Utils.getDimens(getContext(), R.dimen.padding5);
Utils.getGlide(getContext()).load(url).into(imageView); Utils.getGlide(getContext()).load(url).diskCacheStrategy(DiskCacheStrategy.ALL).into(imageView);
layoutImages.addView(imageView, layoutParams); layoutImages.addView(imageView, layoutParams);
}); });
} }
......
...@@ -31,6 +31,7 @@ import androidx.recyclerview.widget.GridLayoutManager; ...@@ -31,6 +31,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import com.ihaoin.hooloo.device.HLApplication; import com.ihaoin.hooloo.device.HLApplication;
...@@ -70,6 +71,7 @@ import java.util.List; ...@@ -70,6 +71,7 @@ import java.util.List;
public class LauncherActivity extends Activity { public class LauncherActivity extends Activity {
private SkuStateChangeReceiver skuChangeReceiver; private SkuStateChangeReceiver skuChangeReceiver;
private GoodsChangeReceiver goodsChangeReceiver; private GoodsChangeReceiver goodsChangeReceiver;
private InteractionReceiver interactionReceiver = null;
private TouchReceiver touchReceiver; private TouchReceiver touchReceiver;
private ScrollView scrollCategory; private ScrollView scrollCategory;
...@@ -118,13 +120,14 @@ public class LauncherActivity extends Activity { ...@@ -118,13 +120,14 @@ public class LauncherActivity extends Activity {
registGoodsChangeReceiver(); registGoodsChangeReceiver();
registTouchReceiver(); registTouchReceiver();
registHdmiReceiver(); registHdmiReceiver();
registInteractionReceiver();
initSettingsQueue(); initSettingsQueue();
startMachineClient(); startMachineClient();
startTimeoutThread(); startTimeoutThread();
getMachineCode(); getMachineCode();
// startUpdateSocket(); startUpdateSocket();
// new UpdateService().start(); // new UpdateService().start();
View.OnClickListener l = v -> { View.OnClickListener l = v -> {
...@@ -136,22 +139,23 @@ public class LauncherActivity extends Activity { ...@@ -136,22 +139,23 @@ public class LauncherActivity extends Activity {
msg.setIsBreak(1); msg.setIsBreak(1);
msg.setSentences(Utils.getSents("HOO感谢你", "感谢在美好的时间遇到了你")); msg.setSentences(Utils.getSents("HOO感谢你", "感谢在美好的时间遇到了你"));
break; break;
case R.id.butn_2: // case R.id.butn_2:
msg.setPicture(ImageState.HOO_THANK2.getCode()); // msg.setPicture(ImageState.HOO_THANK2.getCode());
msg.setIsContinue(0); // msg.setIsContinue(0);
msg.setIsBreak(1); // msg.setIsBreak(1);
msg.setSentences(Utils.getSents("HOO感谢你啊", "感谢在美好的时间遇到了你", "感谢在美好的时间遇到了你", "感谢在美好的时间遇到了你")); // msg.setSentences(Utils.getSents("HOO感谢你啊", "感谢在美好的时间遇到了你", "感谢在美好的时间遇到了你", "感谢在美好的时间遇到了你"));
break; // break;
case R.id.butn_3: case R.id.butn_3:
msg.setPicture(ImageState.HOO_ENTERTAIN.getCode()); msg = JsonUtils.readValue("{\"state\":2,\"stateDesc\":\"男\",\"sentences\":[{\"turn\":1,\"fontSize\":50,\"sentence\":\"小哥哥晚上好啊\"},{\"turn\":2,\"fontSize\":40,\"sentence\":\"打工辛苦\"},{\"turn\":3,\"fontSize\":40,\"sentence\":\"上衣尤其有个性\"}],\"cutToPicture\":\"hoo转场\",\"picture\":\"hoo接待\",\"background\":\"hoo接待\",\"backgroundDesc\":\"中秋晚上多云沙漠\",\"recommendGoods\":\"拿铁\",\"goodsId\":15000,\"goodsIcon\":\"https://hooloo-saas-test.oss-cn-beijing.aliyuncs.com/hooloo/2022/07/09/图片规格 [已恢复]-14.png\",\"recommendSentence\":\"喝杯拿铁吧,下面有菜单哈\",\"recognizePerson\":\"\",\"isContinue\":1,\"isBreak\":0}", InteractionMsg.class);
msg.setCutToPicture(ImageState.HOO_CUT.getCode()); break;
msg.setIsContinue(0); case R.id.butn_4:
msg.setIsBreak(0); msg = JsonUtils.readValue("{\"state\":2,\"stateDesc\":\"男\",\"sentences\":[{\"turn\":1,\"fontSize\":50,\"sentence\":\"大哥哥上午好呐\"},{\"turn\":2,\"fontSize\":40,\"sentence\":\"出门打工\"},{\"turn\":3,\"fontSize\":40,\"sentence\":\"衬衫真有个性\"}],\"cutToPicture\":\"hoo转场2\",\"picture\":\"hoo接待\",\"background\":\"hoo接待\",\"backgroundDesc\":\"中秋上午多云沙漠\",\"recommendGoods\":\"拿铁\",\"goodsId\":180,\"goodsIcon\":\"https://hooloo-saas-test.oss-cn-beijing.aliyuncs.com/hooloo/2022/07/09/图片规格[已恢复]-14.png\",\"recommendSentence\":\"来杯拿铁补充原动力吧,希望给你带来好心情2\",\"recognizePerson\":\"person_2\",\"isContinue\":0,\"isBreak\":0}", InteractionMsg.class);
msg.setSentences(Utils.getSents("HOO感谢你啊", "感谢在美好的时间遇到了你", "感谢在美好的时间遇到了你", "感谢在美好的时间遇到了你")); break;
case R.id.butn_41:
msg.setGoodIds(151); msg = JsonUtils.readValue("{\"state\":2,\"stateDesc\":\"男\",\"sentences\":[{\"turn\":1,\"fontSize\":50,\"sentence\":\"大哥哥上午好呐\"},{\"turn\":2,\"fontSize\":40,\"sentence\":\"出门打工\"},{\"turn\":3,\"fontSize\":40,\"sentence\":\"衬衫真有个性\"}],\"cutToPicture\":\"hoo转场2\",\"picture\":\"\",\"background\":\"hoo接待\",\"backgroundDesc\":\"中秋上午多云沙漠\",\"recommendGoods\":\"拿铁\",\"goodsId\":181,\"goodsIcon\":\"https://hooloo-saas-test.oss-cn-beijing.aliyuncs.com/hooloo/2022/07/09/图片规格[已恢复]-14.png\",\"recommendSentence\":\"来杯拿铁补充原动力吧,希望给你带来好心情3\",\"recognizePerson\":\"person_2\",\"isContinue\":0,\"isBreak\":1}", InteractionMsg.class);
msg.setRecommendSentence("我要给你推荐一个特别好喝的美式咖啡哦哦哦"); break;
msg.setRecommendGoods("美式"); case R.id.butn_5:
msg = JsonUtils.readValue("{\"state\":2,\"stateDesc\":\"男\",\"sentences\":[{\"turn\":1,\"fontSize\":40,\"sentence\":\"大哥哥是这款不和你心意吗?可以翻翻看别的哦4~\"}],\"cutToPicture\":\"\",\"picture\":\"hoo接待\",\"background\":\"hoo接待\",\"backgroundDesc\":\"中秋上午多云森林\",\"recommendGoods\":\"\",\"goodsId\":0,\"goodsIcon\":\"\",\"recommendSentence\":\"\",\"recognizePerson\":\"person_2\",\"isContinue\":1,\"isBreak\":1}", InteractionMsg.class);
break; break;
case R.id.butn_6: case R.id.butn_6:
msg.setPicture(ImageState.LOO_THANK.getCode()); msg.setPicture(ImageState.LOO_THANK.getCode());
...@@ -175,19 +179,27 @@ public class LauncherActivity extends Activity { ...@@ -175,19 +179,27 @@ public class LauncherActivity extends Activity {
Utils.sendInteractionMsgBroadcast(LauncherActivity.this, msg); Utils.sendInteractionMsgBroadcast(LauncherActivity.this, msg);
}; };
findViewById(R.id.butn_1).setOnClickListener(l); findViewById(R.id.butn_1).setOnClickListener(l);
findViewById(R.id.butn_2).setOnClickListener(l); // findViewById(R.id.butn_2).setOnClickListener(l);
findViewById(R.id.butn_3).setOnClickListener(l); findViewById(R.id.butn_3).setOnClickListener(l);
findViewById(R.id.butn_4).setOnClickListener(l);
findViewById(R.id.butn_41).setOnClickListener(l);
findViewById(R.id.butn_5).setOnClickListener(l);
findViewById(R.id.butn_6).setOnClickListener(l); findViewById(R.id.butn_6).setOnClickListener(l);
findViewById(R.id.butn_7).setOnClickListener(l); findViewById(R.id.butn_7).setOnClickListener(l);
findViewById(R.id.butn_10).setOnClickListener(l); findViewById(R.id.butn_10).setOnClickListener(l);
if (!AppConfig.DEBUG) {
findViewById(R.id.butn_1).setVisibility(View.GONE); findViewById(R.id.butn_1).setVisibility(View.GONE);
findViewById(R.id.butn_2).setVisibility(View.GONE); // findViewById(R.id.butn_2).setVisibility(View.GONE);
findViewById(R.id.butn_3).setVisibility(View.GONE); findViewById(R.id.butn_3).setVisibility(View.GONE);
findViewById(R.id.butn_4).setVisibility(View.GONE);
findViewById(R.id.butn_41).setVisibility(View.GONE);
findViewById(R.id.butn_5).setVisibility(View.GONE);
findViewById(R.id.butn_6).setVisibility(View.GONE); findViewById(R.id.butn_6).setVisibility(View.GONE);
findViewById(R.id.butn_7).setVisibility(View.GONE); findViewById(R.id.butn_7).setVisibility(View.GONE);
findViewById(R.id.butn_10).setVisibility(View.GONE); findViewById(R.id.butn_10).setVisibility(View.GONE);
} }
}
private void initViews() { private void initViews() {
...@@ -400,7 +412,7 @@ public class LauncherActivity extends Activity { ...@@ -400,7 +412,7 @@ public class LauncherActivity extends Activity {
butnCategory.setChecked(true); butnCategory.setChecked(true);
} }
int finalIndex = i; int finalIndex = i;
Utils.getGlide(LauncherActivity.this).load(category.getIcon()).into(new CustomTarget<Drawable>() { Utils.getGlide(LauncherActivity.this).load(category.getIcon()).diskCacheStrategy(DiskCacheStrategy.ALL).into(new CustomTarget<Drawable>() {
@Override @Override
public void onResourceReady(@NonNull Drawable drawable, @Nullable Transition<? super Drawable> transition) { public void onResourceReady(@NonNull Drawable drawable, @Nullable Transition<? super Drawable> transition) {
drawable.setBounds(rect); drawable.setBounds(rect);
...@@ -574,6 +586,7 @@ public class LauncherActivity extends Activity { ...@@ -574,6 +586,7 @@ public class LauncherActivity extends Activity {
this.unregistGoodsChangeReceiver(); this.unregistGoodsChangeReceiver();
this.unregistTouchReceiver(); this.unregistTouchReceiver();
this.unregistHdmiReceiver(); this.unregistHdmiReceiver();
this.unregistInteractionReceiver();
stopMachineClient(); stopMachineClient();
stopUpdateSocket(); stopUpdateSocket();
System.exit(0); System.exit(0);
...@@ -680,7 +693,7 @@ public class LauncherActivity extends Activity { ...@@ -680,7 +693,7 @@ public class LauncherActivity extends Activity {
/** 显示副屏内容 */ /** 显示副屏内容 */
private boolean preparePresentView() { private boolean preparePresentView() {
PresentState present = PresentState.get(SharedPreferencesUtils.getPresentation(LauncherActivity.this)); PresentState present = PresentState.get(SharedPreferencesUtils.getScreenNo(LauncherActivity.this));
switch (present) { switch (present) {
case KDS: case KDS:
hideInteractionView(); hideInteractionView();
...@@ -868,6 +881,53 @@ public class LauncherActivity extends Activity { ...@@ -868,6 +881,53 @@ public class LauncherActivity extends Activity {
} }
} }
private void registInteractionReceiver() {
interactionReceiver = new InteractionReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(Base.BROADCAST_ACTION_INTERACTION_INFO);
registerReceiver(interactionReceiver, filter);
}
private void unregistInteractionReceiver() {
if (interactionReceiver != null) {
unregisterReceiver(interactionReceiver);
interactionReceiver = null;
}
}
private class InteractionReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
InteractionMsg msg = (InteractionMsg) intent.getSerializableExtra("msg");
if (msg == null) {
return;
}
if (msg.getGoodsId() == null || msg.getGoodsId() <= 0) {
return;
}
if (HLApplication.getMainData() == null || CollectionUtils.isEmpty(HLApplication.getMainData().getRecommends())) {
return;
}
Recommend recommend = null;
for (Recommend rmd : HLApplication.getMainData().getRecommends()) {
if (rmd == null || rmd.getGoods() == null || rmd.getGoods().getGoodsId() == null) {
continue;
}
if (rmd.getGoods().getGoodsId().equals(msg.getGoodsId())) {
recommend = rmd;
break;
}
}
if (recommend == null) {
return;
}
HLApplication.getMainData().getRecommends().remove(recommend);
HLApplication.getMainData().getRecommends().add(0, recommend);
mainDataChanged();
}
}
class SkuStateChangeReceiver extends BroadcastReceiver { class SkuStateChangeReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
...@@ -954,13 +1014,13 @@ public class LauncherActivity extends Activity { ...@@ -954,13 +1014,13 @@ public class LauncherActivity extends Activity {
boolean state = intent.getBooleanExtra("state", false); boolean state = intent.getBooleanExtra("state", false);
if (AppConfig.DEBUG) { if (AppConfig.DEBUG) {
Utils.showToast(LauncherActivity.this, "hdmi state: " + state); Utils.showToast(LauncherActivity.this, "hdmi state: " + state);
} else {
if (state) {
new Handler().postDelayed(() -> preparePresentView(), 1000 * 5);
} else {
hidePresentView();
}
} }
// TODO TEST
// if (state) {
// new Handler().postDelayed(() -> preparePresentView(), 1000 * 5);
// } else {
// hidePresentView();
// }
} }
} }
......
...@@ -30,16 +30,6 @@ public class InteractionSocket extends Thread { ...@@ -30,16 +30,6 @@ public class InteractionSocket extends Thread {
private void connectSocket() { private void connectSocket() {
try { try {
// TODO TEST
// Utils.sendInteractionMsgBroadcast(mContext, IAGen.getMsg1());
// Thread.sleep(30 * 1000);
// Utils.sendInteractionMsgBroadcast(mContext, IAGen.getMsg3());
// Thread.sleep(30 * 1000);
// Utils.sendInteractionMsgBroadcast(mContext, IAGen.getMsg2());
// while (true) {
// Thread.sleep(30 * 1000);
// }
mSocket = IO.socket(Base.NSP_INTERACTION); mSocket = IO.socket(Base.NSP_INTERACTION);
mSocket.connect(); mSocket.connect();
mSocket.on("connect", onConnect); mSocket.on("connect", onConnect);
...@@ -51,14 +41,14 @@ public class InteractionSocket extends Thread { ...@@ -51,14 +41,14 @@ public class InteractionSocket extends Thread {
} }
} }
Emitter.Listener onConnect = args -> { private Emitter.Listener onConnect = args -> {
Utils.i("interaction socket connected"); Utils.i("interaction socket connected");
mSocket.emit("notice", "test", (Ack) ack -> process("notice", ack)); mSocket.emit("notice", "test", (Ack) ack -> process("notice", ack));
}; };
Emitter.Listener onDisconnect = args -> Utils.i("interaction socket disconnected"); private Emitter.Listener onDisconnect = args -> Utils.i("interaction socket disconnected");
Emitter.Listener onReply = args -> { private Emitter.Listener onReply = args -> {
Utils.i("interaction socket reply"); Utils.i("interaction socket reply");
process("reply", args); process("reply", args);
}; };
......
package com.ihaoin.hooloo.device.interaction.view; package com.ihaoin.hooloo.device.interaction.view;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Presentation; import android.app.Presentation;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.graphics.Color; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
...@@ -22,7 +21,6 @@ import android.view.ViewGroup; ...@@ -22,7 +21,6 @@ import android.view.ViewGroup;
import android.view.animation.AlphaAnimation; import android.view.animation.AlphaAnimation;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.AnimationSet; import android.view.animation.AnimationSet;
import android.view.animation.BounceInterpolator;
import android.view.animation.RotateAnimation; import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation; import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation; import android.view.animation.TranslateAnimation;
...@@ -31,18 +29,21 @@ import android.widget.ImageView; ...@@ -31,18 +29,21 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.ihaoin.hooloo.device.HLApplication; import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.base.Base; import com.ihaoin.hooloo.device.base.Base;
import com.ihaoin.hooloo.device.component.AnimationListener; import com.ihaoin.hooloo.device.component.AnimationListener;
import com.ihaoin.hooloo.device.component.AnimatorListener; import com.ihaoin.hooloo.device.component.AnimatorListener;
import com.ihaoin.hooloo.device.component.MyBounceInterpolator;
import com.ihaoin.hooloo.device.component.WarpLinearLayout; import com.ihaoin.hooloo.device.component.WarpLinearLayout;
import com.ihaoin.hooloo.device.component.animation.ExplosionField; import com.ihaoin.hooloo.device.component.particlesmasher.ParticleSmasher;
import com.ihaoin.hooloo.device.component.particlesmasher.SmashAnimator;
import com.ihaoin.hooloo.device.data.enums.ImageState; import com.ihaoin.hooloo.device.data.enums.ImageState;
import com.ihaoin.hooloo.device.data.vo.Goods;
import com.ihaoin.hooloo.device.data.vo.InteractionMsg; import com.ihaoin.hooloo.device.data.vo.InteractionMsg;
import com.ihaoin.hooloo.device.data.vo.Sentence; import com.ihaoin.hooloo.device.data.vo.Sentence;
import com.ihaoin.hooloo.device.interaction.InteractionSocket; import com.ihaoin.hooloo.device.interaction.InteractionSocket;
...@@ -52,6 +53,7 @@ import com.ihaoin.hooloo.device.util.StringUtils; ...@@ -52,6 +53,7 @@ import com.ihaoin.hooloo.device.util.StringUtils;
import com.ihaoin.hooloo.device.util.Utils; import com.ihaoin.hooloo.device.util.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.Queue;
...@@ -60,8 +62,6 @@ public class InteractionPresentation extends Presentation { ...@@ -60,8 +62,6 @@ public class InteractionPresentation extends Presentation {
private Queue<InteractionMsg> mMsgQueue = new LinkedList<>(); private Queue<InteractionMsg> mMsgQueue = new LinkedList<>();
private InteractionSocket interactionSocket = null; private InteractionSocket interactionSocket = null;
private ImageView background;
// private LottieAnimationView lottieView;
private WarpLinearLayout layoutLine1; private WarpLinearLayout layoutLine1;
private WarpLinearLayout layoutLine2; private WarpLinearLayout layoutLine2;
private WarpLinearLayout layoutLine3; private WarpLinearLayout layoutLine3;
...@@ -74,6 +74,9 @@ public class InteractionPresentation extends Presentation { ...@@ -74,6 +74,9 @@ public class InteractionPresentation extends Presentation {
private View layoutRecommend; private View layoutRecommend;
private TextView recommendText; private TextView recommendText;
private ImageView recommendIcon; private ImageView recommendIcon;
private View light1;
private View light2;
private Typeface typeface;
public InteractionPresentation(Context outerContext, Display display) { public InteractionPresentation(Context outerContext, Display display) {
super(outerContext, display); super(outerContext, display);
...@@ -94,9 +97,10 @@ public class InteractionPresentation extends Presentation { ...@@ -94,9 +97,10 @@ public class InteractionPresentation extends Presentation {
} }
private void initViews() { private void initViews() {
typeface = Utils.getInteractionFont(getContext());
frameView = findViewById(R.id.frame_view); frameView = findViewById(R.id.frame_view);
layoutCharsFly = findViewById(R.id.layout_chars_fly); layoutCharsFly = findViewById(R.id.layout_chars_fly);
// lottieView = findViewById(R.id.lottie_view);
layoutLine1 = findViewById(R.id.layout_line_1); layoutLine1 = findViewById(R.id.layout_line_1);
layoutLine2 = findViewById(R.id.layout_line_2); layoutLine2 = findViewById(R.id.layout_line_2);
...@@ -108,9 +112,17 @@ public class InteractionPresentation extends Presentation { ...@@ -108,9 +112,17 @@ public class InteractionPresentation extends Presentation {
layoutRecommend = findViewById(R.id.layout_recommend); layoutRecommend = findViewById(R.id.layout_recommend);
recommendText = findViewById(R.id.txt_recommend); recommendText = findViewById(R.id.txt_recommend);
recommendIcon = findViewById(R.id.img_goods_icon); recommendIcon = findViewById(R.id.img_goods_icon);
light1 = findViewById(R.id.light1);
light2 = findViewById(R.id.light2);
recommendText.setTypeface(typeface);
recommendText.setIncludeFontPadding(false);
// ((TextView) findViewById(R.id.test1)).setTypeface(typeface);
// ((TextView) findViewById(R.id.test2)).setTypeface(typeface);
} }
private void setInteractionMsg(InteractionMsg msg) { private void setInteractionMsg(InteractionMsg msg) {
Utils.showToast(getContext(), String.format("交互屏消息,队列:%s, 转场:%s, 动画:%s, 重复:%s, 打断:%s, 商品:%s", mMsgQueue.size(), msg.getCutToPicture(), msg.getPicture(), msg.getIsContinue(), msg.getIsBreak(), msg.getGoodsId()), Toast.LENGTH_LONG);
HLApplication.RECOGNIZE_PERSON = msg.getRecognizePerson(); HLApplication.RECOGNIZE_PERSON = msg.getRecognizePerson();
if (Base.TRUE.equals(msg.getIsBreak()) || mMsgQueue.size() >= 2) { if (Base.TRUE.equals(msg.getIsBreak()) || mMsgQueue.size() >= 2) {
mMsgQueue.clear(); mMsgQueue.clear();
...@@ -153,40 +165,82 @@ public class InteractionPresentation extends Presentation { ...@@ -153,40 +165,82 @@ public class InteractionPresentation extends Presentation {
if (layoutRecommend.getVisibility() == View.INVISIBLE) { if (layoutRecommend.getVisibility() == View.INVISIBLE) {
return; return;
} }
Animation animation = new AlphaAnimation(1, 0);
animation.setDuration(400); ParticleSmasher smasher = new ParticleSmasher(InteractionPresentation.this);
animation.setAnimationListener(new AnimationListener() { // 默认为爆炸动画
smasher.with(layoutRecommend)
.setStyle(SmashAnimator.STYLE_EXPLOSION)
.setDuration(600) // 设置动画时间
.setStartDelay(0) // 设置动画前延时
.setHorizontalMultiple(1) // 设置横向运动幅度,默认为3
.setVerticalMultiple(1) // 设置竖向运动幅度,默认为4
.addAnimatorListener(new SmashAnimator.OnAnimatorListener() {
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimatorEnd() {
layoutRecommend.setVisibility(View.INVISIBLE); layoutRecommend.setVisibility(View.INVISIBLE);
recommendText.setText("");
recommendIcon.setImageDrawable(null);
smasher.reShowView(layoutRecommend);
startRecommendInAnim(msg);
} }
}); }).start();
layoutRecommend.setAnimation(animation);
animation.start();
startRecommendInAnim(msg); // Animation animation = new AlphaAnimation(1, 0);
// animation.setDuration(400);
// animation.setAnimationListener(new AnimationListener() {
// @Override
// public void onAnimationEnd(Animation animation) {
// layoutRecommend.setVisibility(View.INVISIBLE);
// }
// });
// layoutRecommend.setAnimation(animation);
// animation.start();
} }
private void startRecommendInAnim(InteractionMsg msg) { private void startRecommendInAnim(InteractionMsg msg) {
if (msg == null || StringUtils.isEmpty(msg.getRecommendSentence())) { if (msg == null || StringUtils.isEmpty(msg.getRecommendSentence()) || StringUtils.isEmpty(msg.getRecommendGoods())) {
return;
}
Goods goods = Utils.getGoods(msg.getGoodIds());
if (goods == null) {
return; return;
} }
int start = msg.getRecommendSentence().indexOf(goods.getName()); int start = msg.getRecommendSentence().indexOf(msg.getRecommendGoods());
int end = start + goods.getName().length(); int end = start + msg.getRecommendGoods().length();
SpannableStringBuilder builder = new SpannableStringBuilder(msg.getRecommendSentence()); SpannableStringBuilder builder = new SpannableStringBuilder(msg.getRecommendSentence());
builder.setSpan(new ForegroundColorSpan(getContext().getColor(R.color.colorLogo)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new ForegroundColorSpan(getContext().getColor(R.color.colorLogo)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new AbsoluteSizeSpan(Utils.getDimens(getContext(), R.dimen.ts_interaction_recommend_big)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new AbsoluteSizeSpan(Utils.getDimens(getContext(), R.dimen.ts_interaction_recommend_big)), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
recommendText.setText(builder); recommendText.setText(builder);
Utils.getGlide(getContext()).load(Utils.getThumbnailUrl(goods.getPics().getThumbnail())).into(recommendIcon); Utils.getGlide(getContext()).load(Utils.getThumbnailUrl(msg.getGoodsIcon())).diskCacheStrategy(DiskCacheStrategy.ALL).into(recommendIcon);
Animation alphaAnimation = new AlphaAnimation(0, 1);
TranslateAnimation leftAnimation = new TranslateAnimation(-light1.getWidth(), 1080, 0, 0);
TranslateAnimation rightAnimation = new TranslateAnimation(light2.getWidth(), -1080, 0, 0);
alphaAnimation.setDuration(600);
leftAnimation.setDuration(600);
rightAnimation.setDuration(600);
layoutRecommend.setVisibility(View.VISIBLE); layoutRecommend.setVisibility(View.VISIBLE);
Animation animation = new AlphaAnimation(0, 1); light1.setVisibility(View.VISIBLE);
animation.setDuration(400); light2.setVisibility(View.VISIBLE);
layoutRecommend.setAnimation(animation);
animation.start(); layoutRecommend.setAnimation(alphaAnimation);
light1.setAnimation(leftAnimation);
light2.setAnimation(rightAnimation);
leftAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
light1.setVisibility(View.INVISIBLE);
}
});
rightAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
light2.setVisibility(View.INVISIBLE);
}
});
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(alphaAnimation);
animationSet.addAnimation(leftAnimation);
animationSet.addAnimation(rightAnimation);
animationSet.start();
} }
/** 播放ip动画 */ /** 播放ip动画 */
...@@ -194,6 +248,14 @@ public class InteractionPresentation extends Presentation { ...@@ -194,6 +248,14 @@ public class InteractionPresentation extends Presentation {
InteractionMsg msg = pollMsg(); InteractionMsg msg = pollMsg();
Boolean infinite = Base.TRUE.equals(msg.getIsContinue()); Boolean infinite = Base.TRUE.equals(msg.getIsContinue());
if (StringUtils.isEmpty(msg.getPicture())) {
// 动画为空,只更换文字
// 清空文字动画 之后 播放文字动画
Message message = textAnimHandler.obtainMessage(2, msg);
textAnimHandler.sendMessage(message);
return;
}
if (StringUtils.isEmpty(msg.getCutToPicture())) { // 没有转场动画 if (StringUtils.isEmpty(msg.getCutToPicture())) { // 没有转场动画
// 清空文字动画 之后 播放文字动画 // 清空文字动画 之后 播放文字动画
Message message = textAnimHandler.obtainMessage(2, msg); Message message = textAnimHandler.obtainMessage(2, msg);
...@@ -284,7 +346,7 @@ public class InteractionPresentation extends Presentation { ...@@ -284,7 +346,7 @@ public class InteractionPresentation extends Presentation {
} }
if (layoutLine1.getChildCount() <= 0 && layoutLine2.getChildCount() <= 0 && layoutLine3.getChildCount() <= 0 && layoutLine4.getChildCount() <= 0) { if (layoutLine1.getChildCount() <= 0 && layoutLine2.getChildCount() <= 0 && layoutLine3.getChildCount() <= 0 && layoutLine4.getChildCount() <= 0) {
// 播放文字动画 // 没有文字直接 播放文字动画
if (msg != null) { if (msg != null) {
Message message = textAnimHandler.obtainMessage(1, msg); Message message = textAnimHandler.obtainMessage(1, msg);
textAnimHandler.sendMessage(message); textAnimHandler.sendMessage(message);
...@@ -292,9 +354,18 @@ public class InteractionPresentation extends Presentation { ...@@ -292,9 +354,18 @@ public class InteractionPresentation extends Presentation {
return; return;
} }
new ExplosionField(InteractionPresentation.this).explode(layouts, new AnimatorListenerAdapter() { // 有文字播放爆炸动作后 播放文字动画
ParticleSmasher smasher = new ParticleSmasher(InteractionPresentation.this);
// 默认为爆炸动画
smasher.with(layouts)
.setStyle(SmashAnimator.STYLE_EXPLOSION)
.setDuration(600) // 设置动画时间
.setStartDelay(0) // 设置动画前延时
.setHorizontalMultiple(1) // 设置横向运动幅度,默认为3
.setVerticalMultiple(1) // 设置竖向运动幅度,默认为4
.addAnimatorListener(new SmashAnimator.OnAnimatorListener() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimatorEnd() {
for (int line = 0; line < layouts.getChildCount(); line++) { for (int line = 0; line < layouts.getChildCount(); line++) {
WarpLinearLayout layout = (WarpLinearLayout) layouts.getChildAt(line); WarpLinearLayout layout = (WarpLinearLayout) layouts.getChildAt(line);
for (int i = 0; i < layout.getChildCount(); i++) { for (int i = 0; i < layout.getChildCount(); i++) {
...@@ -302,13 +373,69 @@ public class InteractionPresentation extends Presentation { ...@@ -302,13 +373,69 @@ public class InteractionPresentation extends Presentation {
layout.setVisibility(View.GONE); layout.setVisibility(View.GONE);
} }
} }
smasher.reShowView(layouts);
if (msg != null) { if (msg != null) {
// 播放文字动画 // 播放文字动画
Message message = textAnimHandler.obtainMessage(1, msg); Message message = textAnimHandler.obtainMessage(1, msg);
textAnimHandler.sendMessage(message); textAnimHandler.sendMessage(message);
} }
} }
}); }).start();
// for (int i = 0; i < layouts.getChildCount(); i++) {
// WarpLinearLayout layout = (WarpLinearLayout) layouts.getChildAt(i);
// if (layout.getChildCount() <= 0) {
// continue;
// }
//
// ParticleSmasher smasher = new ParticleSmasher(InteractionPresentation.this);
// // 默认为爆炸动画
// int finalI = i;
// smasher.with(layout)
// .setStyle(SmashAnimator.STYLE_EXPLOSION)
// .setDuration(1000) // 设置动画时间
// .setStartDelay(0) // 设置动画前延时
// .setHorizontalMultiple(1) // 设置横向运动幅度,默认为3
// .setVerticalMultiple(1) // 设置竖向运动幅度,默认为4
// .addAnimatorListener(new SmashAnimator.OnAnimatorListener() {
// @Override
// public void onAnimatorEnd() {
//// for (int line = 0; line < layouts.getChildCount(); line++) {
//// WarpLinearLayout layout = (WarpLinearLayout) layouts.getChildAt(line);
//// for (int i = 0; i < layout.getChildCount(); i++) {
// layout.removeAllViews();
// layout.setVisibility(View.GONE);
// smasher.reShowView(layouts);
//// }
//// }
// if (finalI == 0) {
// if (msg != null) {
// // 播放文字动画
// Message message = textAnimHandler.obtainMessage(1, msg);
// textAnimHandler.sendMessage(message);
// }
// }
// }
// }).start();
// }
// new ExplosionField(InteractionPresentation.this).explode(layouts, new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animation) {
// for (int line = 0; line < layouts.getChildCount(); line++) {
// WarpLinearLayout layout = (WarpLinearLayout) layouts.getChildAt(line);
// for (int i = 0; i < layout.getChildCount(); i++) {
// layout.removeAllViews();
// layout.setVisibility(View.GONE);
// }
// }
// if (msg != null) {
// // 播放文字动画
// Message message = textAnimHandler.obtainMessage(1, msg);
// textAnimHandler.sendMessage(message);
// }
// }
// });
} }
/** 开始文字动画 */ /** 开始文字动画 */
...@@ -331,13 +458,17 @@ public class InteractionPresentation extends Presentation { ...@@ -331,13 +458,17 @@ public class InteractionPresentation extends Presentation {
if (StringUtils.isEmpty(sentenceStr)) { if (StringUtils.isEmpty(sentenceStr)) {
continue; continue;
} }
for (int j = 0; j < sentenceStr.length(); j++) { for (int j = 0; j < sentenceStr.length(); j++) {
String text = String.valueOf(sentenceStr.charAt(j)); String text = String.valueOf(sentenceStr.charAt(j));
TextView popText = new TextView(getContext()); TextView popText = new TextView(getContext());
popText.setTextColor(Color.RED); popText.setIncludeFontPadding(false);
popText.setTypeface(typeface);
popText.setTextColor(getContext().getColor(R.color.textGray11));
popText.setText(text); popText.setText(text);
popText.setTextSize(sentence.getFontSize()); popText.setTextSize(sentence.getFontSize());
popText.setVisibility(View.VISIBLE); popText.setVisibility(View.VISIBLE);
popText.setPadding(0, 40, 0, 0);
layout.addView(popText); layout.addView(popText);
layout.setVisibility(View.VISIBLE); layout.setVisibility(View.VISIBLE);
...@@ -350,7 +481,7 @@ public class InteractionPresentation extends Presentation { ...@@ -350,7 +481,7 @@ public class InteractionPresentation extends Presentation {
} }
}); });
scaleAnimation.setDuration(duration); scaleAnimation.setDuration(duration);
scaleAnimation.setInterpolator(new BounceInterpolator()); scaleAnimation.setInterpolator(new MyBounceInterpolator());
scaleAnimation.setStartOffset(delay); scaleAnimation.setStartOffset(delay);
popText.setAnimation(scaleAnimation); popText.setAnimation(scaleAnimation);
textInAnimationSet.addAnimation(scaleAnimation); textInAnimationSet.addAnimation(scaleAnimation);
...@@ -359,6 +490,7 @@ public class InteractionPresentation extends Presentation { ...@@ -359,6 +490,7 @@ public class InteractionPresentation extends Presentation {
List<String> chars = getRandomChars(); List<String> chars = getRandomChars();
for (int k = 0; k < chars.size(); k++) { for (int k = 0; k < chars.size(); k++) {
TextView flyView = new TextView(getContext()); TextView flyView = new TextView(getContext());
flyView.setTypeface(typeface);
int startX = ((RelativeLayout.LayoutParams) viewStart.getLayoutParams()).leftMargin; int startX = ((RelativeLayout.LayoutParams) viewStart.getLayoutParams()).leftMargin;
int startY = ((RelativeLayout.LayoutParams) viewStart.getLayoutParams()).topMargin; int startY = ((RelativeLayout.LayoutParams) viewStart.getLayoutParams()).topMargin;
...@@ -372,7 +504,7 @@ public class InteractionPresentation extends Presentation { ...@@ -372,7 +504,7 @@ public class InteractionPresentation extends Presentation {
AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, flyX, flyY); AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, flyX, flyY);
flyView.setText(chars.get(k)); flyView.setText(chars.get(k));
flyView.setTextSize(30); flyView.setTextSize(30);
flyView.setTextColor(Color.BLACK); flyView.setTextColor(getRandomColor());
flyView.setVisibility(View.INVISIBLE); flyView.setVisibility(View.INVISIBLE);
layoutCharsFly.addView(flyView, layoutParams); layoutCharsFly.addView(flyView, layoutParams);
...@@ -426,6 +558,13 @@ public class InteractionPresentation extends Presentation { ...@@ -426,6 +558,13 @@ public class InteractionPresentation extends Presentation {
return list; return list;
} }
List<Integer> list = Arrays.asList(getContext().getColor(R.color.fly_text1), getContext().getColor(R.color.fly_text2), getContext().getColor(R.color.fly_text3), getContext().getColor(R.color.fly_text4), getContext().getColor(R.color.fly_text5), getContext().getColor(R.color.fly_text6), getContext().getColor(R.color.fly_text7));
/** 生成随机颜色 */
private Integer getRandomColor() {
return list.get(RandomUtils.getRandom(0, list.size()));
}
private OnDismissListener dismissListener = dialog -> { private OnDismissListener dismissListener = dialog -> {
Utils.i("interaction present dismiss"); Utils.i("interaction present dismiss");
frameView.cancelAnimation(); frameView.cancelAnimation();
...@@ -446,7 +585,7 @@ public class InteractionPresentation extends Presentation { ...@@ -446,7 +585,7 @@ public class InteractionPresentation extends Presentation {
} }
} }
InteractionReceiver interactionReceiver = null; private InteractionReceiver interactionReceiver = null;
private void registInteractionReceiver() { private void registInteractionReceiver() {
interactionReceiver = new InteractionReceiver(); interactionReceiver = new InteractionReceiver();
......
...@@ -41,14 +41,14 @@ public class KDSSocket extends Thread { ...@@ -41,14 +41,14 @@ public class KDSSocket extends Thread {
} }
} }
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", "test", (Ack) ack -> Utils.i("notice: " + JsonUtils.toString(ack)));
}; };
Emitter.Listener onDisconnect = args -> Utils.i("kds socket disconnected"); private Emitter.Listener onDisconnect = args -> Utils.i("kds socket disconnected");
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("reply args empty");
......
...@@ -9,6 +9,7 @@ import android.widget.ImageView; ...@@ -9,6 +9,7 @@ import android.widget.ImageView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.util.CollectionUtils; import com.ihaoin.hooloo.device.util.CollectionUtils;
import com.ihaoin.hooloo.device.util.Utils; import com.ihaoin.hooloo.device.util.Utils;
...@@ -40,7 +41,14 @@ public class ImagePagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol ...@@ -40,7 +41,14 @@ public class ImagePagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder h, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder h, int position) {
BaseViewHolder holder = (BaseViewHolder) h; BaseViewHolder holder = (BaseViewHolder) h;
String url = images.get(position % images.size()); String url = images.get(position % images.size());
Utils.getGlide(context).load(url).into(holder.image); Utils.getGlide(context).load(url).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.image);
}
public int getRealCount() {
if (CollectionUtils.isEmpty(images)) {
return 0;
}
return images.size();
} }
@Override @Override
......
...@@ -233,7 +233,7 @@ public class KdsPresentation extends Presentation { ...@@ -233,7 +233,7 @@ public class KdsPresentation extends Presentation {
private Integer statePosition = 3; private Integer statePosition = 3;
private void setNextImage() { private void setNextImage() {
if (imagePagerAdapter == null || imagePagerAdapter.getItemCount() <= 1) { if (imagePagerAdapter == null || imagePagerAdapter.getRealCount() <= 1) {
return; return;
} }
imagePosition++; imagePosition++;
......
...@@ -201,7 +201,7 @@ public class HttpUtil { ...@@ -201,7 +201,7 @@ public class HttpUtil {
checkUpdate.setAppName(packageInfo.packageName); checkUpdate.setAppName(packageInfo.packageName);
checkUpdate.setVersionCode(packageInfo.versionCode); checkUpdate.setVersionCode(packageInfo.versionCode);
checkUpdate.setVersionName(packageInfo.versionName); checkUpdate.setVersionName(packageInfo.versionName);
checkUpdate.setType(SharedPreferencesUtils.getScreenNo(HLApplication.SELF)); checkUpdate.setType(String.valueOf(SharedPreferencesUtils.getScreenNo(HLApplication.SELF)));
String content = JsonUtils.toString(checkUpdate).replaceAll("\"", "'"); String content = JsonUtils.toString(checkUpdate).replaceAll("\"", "'");
String params = String.format("{\"params\": \"%s\"}", content); String params = String.format("{\"params\": \"%s\"}", content);
......
...@@ -15,7 +15,6 @@ import com.ihaoin.hooloo.device.base.Base; ...@@ -15,7 +15,6 @@ import com.ihaoin.hooloo.device.base.Base;
import com.ihaoin.hooloo.device.data.enums.PresentState; import com.ihaoin.hooloo.device.data.enums.PresentState;
import com.ihaoin.hooloo.device.home.view.LauncherActivity; import com.ihaoin.hooloo.device.home.view.LauncherActivity;
import com.ihaoin.hooloo.device.util.SharedPreferencesUtils; import com.ihaoin.hooloo.device.util.SharedPreferencesUtils;
import com.ihaoin.hooloo.device.util.StringUtils;
import com.ihaoin.hooloo.device.util.Utils; import com.ihaoin.hooloo.device.util.Utils;
public class SettingsActivity extends Activity { public class SettingsActivity extends Activity {
...@@ -26,9 +25,7 @@ public class SettingsActivity extends Activity { ...@@ -26,9 +25,7 @@ public class SettingsActivity extends Activity {
private TextView txtMachineCode; private TextView txtMachineCode;
private View layoutMachineCode; private View layoutMachineCode;
private View layoutScreen; private View layoutScreen;
private View layoutPresentation;
private TextView txtScreenNo; private TextView txtScreenNo;
private TextView txtPresentation;
private ToggleButton butnLogcat; private ToggleButton butnLogcat;
private View butnClose; private View butnClose;
...@@ -50,15 +47,14 @@ public class SettingsActivity extends Activity { ...@@ -50,15 +47,14 @@ public class SettingsActivity extends Activity {
layoutMachineCode = findViewById(R.id.layout_machine_code); layoutMachineCode = findViewById(R.id.layout_machine_code);
layoutScreen = findViewById(R.id.layout_screen); layoutScreen = findViewById(R.id.layout_screen);
txtScreenNo = findViewById(R.id.txt_screen_no); txtScreenNo = findViewById(R.id.txt_screen_no);
layoutPresentation = findViewById(R.id.layout_presentation);
txtPresentation = findViewById(R.id.txt_presentation);
butnLogcat = findViewById(R.id.butn_logcat); butnLogcat = findViewById(R.id.butn_logcat);
butnClose = findViewById(R.id.butn_close); butnClose = findViewById(R.id.butn_close);
txtVersion.setText(getAppVersionName()); txtVersion.setText(getAppVersionName());
txtMachineCode.setText(SharedPreferencesUtils.getMachineCode(this)); txtMachineCode.setText(SharedPreferencesUtils.getMachineCode(this));
txtScreenNo.setText(SharedPreferencesUtils.getScreenNo(this));
txtPresentation.setText(SharedPreferencesUtils.getPresentation(this)); PresentState state = PresentState.get(SharedPreferencesUtils.getScreenNo(this));
txtScreenNo.setText(state.toString());
butnLogcat.setChecked(SharedPreferencesUtils.getShowLogcat(this)); butnLogcat.setChecked(SharedPreferencesUtils.getShowLogcat(this));
layoutTest.setOnClickListener(v -> Utils.showTest(SettingsActivity.this)); layoutTest.setOnClickListener(v -> Utils.showTest(SettingsActivity.this));
...@@ -69,29 +65,17 @@ public class SettingsActivity extends Activity { ...@@ -69,29 +65,17 @@ public class SettingsActivity extends Activity {
butnClose.setOnClickListener(v -> finish()); butnClose.setOnClickListener(v -> finish());
layoutScreen.setOnClickListener(v -> showEditScreen()); layoutScreen.setOnClickListener(v -> showEditScreen());
layoutMachineCode.setOnClickListener(v -> showMachineCode()); layoutMachineCode.setOnClickListener(v -> showMachineCode());
layoutPresentation.setOnClickListener(v -> showEditPresentation());
layoutSysSettings.setOnClickListener(v -> Utils.openSystemSettings(getApplicationContext())); layoutSysSettings.setOnClickListener(v -> Utils.openSystemSettings(getApplicationContext()));
} }
private void showEditScreen() { private void showEditScreen() {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("修改点单屏编码"); builder.setTitle("修改点单屏编码");
String[] items = new String[]{"1", "2"}; String[] items = new String[]{PresentState.NONE.toString(), PresentState.KDS.toString(), PresentState.INTERACTION.toString()};
builder.setSingleChoiceItems(items, StringUtils.indexOf(items, SharedPreferencesUtils.getScreenNo(SettingsActivity.this)), (dialog, which) -> { builder.setSingleChoiceItems(items, SharedPreferencesUtils.getScreenNo(this), (dialog, which) -> {
SharedPreferencesUtils.setScreenNo(SettingsActivity.this, items[which]); PresentState stateRslt = PresentState.get(which);
txtScreenNo.setText(SharedPreferencesUtils.getScreenNo(SettingsActivity.this)); SharedPreferencesUtils.setScreenNo(SettingsActivity.this, stateRslt.getCode());
dialog.dismiss(); txtScreenNo.setText(stateRslt.toString());
});
builder.create().show();
}
private void showEditPresentation() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("修改副屏内容");
String[] items = new String[]{PresentState.NONE.getName(), PresentState.KDS.getName(), PresentState.INTERACTION.getName()};
builder.setSingleChoiceItems(items, StringUtils.indexOf(items, SharedPreferencesUtils.getPresentation(SettingsActivity.this)), (dialog, which) -> {
SharedPreferencesUtils.setPresentation(SettingsActivity.this, items[which]);
txtPresentation.setText(SharedPreferencesUtils.getPresentation(SettingsActivity.this));
dialog.dismiss(); dialog.dismiss();
Utils.fastBroadcast(SettingsActivity.this, Base.BROADCAST_ACTION_PRESENT_CHANGED); Utils.fastBroadcast(SettingsActivity.this, Base.BROADCAST_ACTION_PRESENT_CHANGED);
}); });
......
...@@ -11,6 +11,7 @@ import android.widget.ImageView; ...@@ -11,6 +11,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.ToggleButton; import android.widget.ToggleButton;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.ihaoin.hooloo.device.HLApplication; import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.data.TrolleyGoods; import com.ihaoin.hooloo.device.data.TrolleyGoods;
...@@ -90,7 +91,7 @@ public class TrolleyAdapter extends BaseAdapter { ...@@ -90,7 +91,7 @@ public class TrolleyAdapter extends BaseAdapter {
txtCount.setText(trolleyGoods.getCount().toString()); txtCount.setText(trolleyGoods.getCount().toString());
butnSubtract.setOnClickListener(v -> trolleyView.subtractGoods(position)); butnSubtract.setOnClickListener(v -> trolleyView.subtractGoods(position));
butnAdd.setOnClickListener(v -> trolleyView.addGoods(position)); butnAdd.setOnClickListener(v -> trolleyView.addGoods(position));
Utils.getGlide(mContext).load(Utils.getThumbnailUrl(goods.getPics().getThumbnail())).into(imgThumbnail); Utils.getGlide(mContext).load(Utils.getThumbnailUrl(goods.getPics().getThumbnail())).diskCacheStrategy(DiskCacheStrategy.ALL).into(imgThumbnail);
ViewGroup layoutItem = convertView.findViewById(R.id.layout_item); ViewGroup layoutItem = convertView.findViewById(R.id.layout_item);
Utils.setTouchDelegate(layoutItem, Arrays.asList(butnAdd, butnSubtract)); Utils.setTouchDelegate(layoutItem, Arrays.asList(butnAdd, butnSubtract));
......
package com.ihaoin.hooloo.device.update; package com.ihaoin.hooloo.device.update;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
...@@ -9,10 +10,12 @@ import android.os.Message; ...@@ -9,10 +10,12 @@ import android.os.Message;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.ihaoin.hooloo.device.HLApplication; import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.network.NetworkHandler; import com.ihaoin.hooloo.device.base.AppConfig;
import com.ihaoin.hooloo.device.data.vo.CheckUpdateVo; import com.ihaoin.hooloo.device.data.vo.CheckUpdateVo;
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.util.ApkUtils; import com.ihaoin.hooloo.device.util.ApkUtils;
import com.ihaoin.hooloo.device.util.JsonUtils;
import com.ihaoin.hooloo.device.util.StringUtils; import com.ihaoin.hooloo.device.util.StringUtils;
import com.ihaoin.hooloo.device.util.Utils; import com.ihaoin.hooloo.device.util.Utils;
...@@ -20,6 +23,11 @@ import java.io.File; ...@@ -20,6 +23,11 @@ import java.io.File;
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
public class UpdateService extends Thread { public class UpdateService extends Thread {
private Context mContext;
public UpdateService(Context context) {
this.mContext = context;
}
// @Nullable // @Nullable
// @Override // @Override
// public IBinder onBind(Intent intent) { // public IBinder onBind(Intent intent) {
...@@ -29,7 +37,7 @@ public class UpdateService extends Thread { ...@@ -29,7 +37,7 @@ public class UpdateService extends Thread {
@Override @Override
public void run() { public void run() {
checkUpdate(); HttpUtil.checkUpdate(checkUpdateHandler);
// while (true) { // while (true) {
// try { // try {
...@@ -45,61 +53,57 @@ public class UpdateService extends Thread { ...@@ -45,61 +53,57 @@ public class UpdateService extends Thread {
// } // }
} }
private void checkUpdate() {
HttpUtil.checkUpdate(checkUpdateHandler);
}
private CheckUpdateHandler checkUpdateHandler = new CheckUpdateHandler(); private CheckUpdateHandler checkUpdateHandler = new CheckUpdateHandler();
private class CheckUpdateHandler extends NetworkHandler { private class CheckUpdateHandler extends NetworkHandler {
@Override @Override
public void handleMessage(@NonNull Message msg) { public void handleMessage(@NonNull Message msg) {
try { try {
CheckUpdateVo updateVo = new CheckUpdateVo(); // CheckUpdateVo updateVo = new CheckUpdateVo();
updateVo.setUrl("https://testapi.pecktoy.com/files/upload_test/signed-v10.apk"); // updateVo.setUrl("https://testapi.pecktoy.com/files/upload_test/signed-v10.apk");
updateVo.setVersion("1.0.10"); // updateVo.setVersion("1.0.10");
updateVo.setVersionCode(10); // updateVo.setVersionCode(10);
// Object obj = msg.obj; Object obj = msg.obj;
// if (msg.what == 0 || obj == null) { if (msg.what == 0 || obj == null) {
// Utils.i("check update error"); Utils.i(AppConfig.TAG_UPDATE, "检查更新返回¬失败");
// return; return;
// } }
// CheckUpdateVo updateVo = JsonUtils.readValue(obj, CheckUpdateVo.class); CheckUpdateVo updateVo = JsonUtils.readValue(obj, CheckUpdateVo.class);
if (updateVo.getVersionCode() == null || updateVo.getVersionCode() <= 0) { if (updateVo.getVersionCode() == null || updateVo.getVersionCode() <= 0) {
Utils.i("version code is null"); Utils.i(AppConfig.TAG_UPDATE, "version code 为空");
return; return;
} }
if (StringUtils.isEmpty(updateVo.getUrl())) { if (StringUtils.isEmpty(updateVo.getUrl())) {
Utils.i("url is null"); Utils.i(AppConfig.TAG_UPDATE, "url 为空");
return; return;
} }
if (StringUtils.isEmpty(updateVo.getVersion())) { if (StringUtils.isEmpty(updateVo.getVersion())) {
Utils.i("version name is null"); Utils.i(AppConfig.TAG_UPDATE, "version 为空");
return; return;
} }
PackageInfo packageInfo = Utils.getPackageInfo(); PackageInfo packageInfo = Utils.getPackageInfo();
if (updateVo.getVersionCode() <= packageInfo.versionCode) { if (updateVo.getVersionCode() <= packageInfo.versionCode) {
Utils.i(String.format("do not update, current: %s, update: %s", packageInfo.versionCode, updateVo.getVersionCode())); Utils.i(AppConfig.TAG_UPDATE, String.format("不需要更新, current: %s, update: %s", packageInfo.versionCode, updateVo.getVersionCode()));
return; return;
} }
startDownload(updateVo); startDownload(updateVo);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Utils.i("check update error"); Utils.i(AppConfig.TAG_UPDATE, "检查更新失败");
} }
} }
} }
private void startDownload(CheckUpdateVo updateVo) { private void startDownload(CheckUpdateVo updateVo) {
String filename = "hooloo-device_" + updateVo.getVersion() + "_" + updateVo.getVersionCode() + ".apk"; String filename = "hooloo-device_" + updateVo.getVersion() + "_" + updateVo.getVersionCode() + "_" + System.currentTimeMillis() + ".apk";
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/hooloo"; String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/hooloo";
if (!new File(path).exists()) { if (!new File(path).exists()) {
new File(path).mkdirs(); new File(path).mkdirs();
} }
String file = path + "/" + filename; String file = path + "/" + filename;
Utils.i(String.format("start download url: %s, file: %s", updateVo.getUrl(), file)); Utils.i(AppConfig.TAG_UPDATE, String.format("开始下载文件 url: %s, file: %s", updateVo.getUrl(), file));
HttpUtil.download(updateVo.getUrl(), file, downloadHandler); HttpUtil.download(updateVo.getUrl(), file, downloadHandler);
} }
...@@ -109,14 +113,17 @@ public class UpdateService extends Thread { ...@@ -109,14 +113,17 @@ public class UpdateService extends Thread {
try { try {
Object obj = msg.obj; Object obj = msg.obj;
if (msg.what == 0 || obj == null) { if (msg.what == 0 || obj == null) {
Utils.i("download file error"); Utils.i(AppConfig.TAG_UPDATE, "download file error");
return; return;
} }
if (AppConfig.DEBUG) {
return; // 测试不实际升级
}
ApkUtils.install(HLApplication.SELF, obj.toString()); ApkUtils.install(HLApplication.SELF, obj.toString());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Utils.i("download file error"); Utils.i(AppConfig.TAG_UPDATE, "下载文件错误");
} }
} }
}; };
......
...@@ -3,6 +3,7 @@ package com.ihaoin.hooloo.device.update; ...@@ -3,6 +3,7 @@ package com.ihaoin.hooloo.device.update;
import android.content.Context; import android.content.Context;
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.Base; import com.ihaoin.hooloo.device.base.Base;
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;
...@@ -38,26 +39,26 @@ public class UpdateSocket extends Thread { ...@@ -38,26 +39,26 @@ public class UpdateSocket extends Thread {
mSocket.on("disconnect", onDisconnect); mSocket.on("disconnect", onDisconnect);
mSocket.on("upgrade", onUpgrade); mSocket.on("upgrade", onUpgrade);
} catch (Exception e) { } catch (Exception e) {
Utils.i("连接server失败,错误原因:" + e.getMessage()); Utils.i(AppConfig.TAG_UPDATE, "连接server失败,错误原因:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
Emitter.Listener onConnect = args -> { private Emitter.Listener onConnect = args -> {
Utils.i("update socket connected"); Utils.i(AppConfig.TAG_UPDATE, "update socket connected");
mSocket.emit("state", "", (Ack) ack -> process("state", ack)); mSocket.emit("state", "", (Ack) ack -> process("state", ack));
}; };
Emitter.Listener onDisconnect = args -> Utils.i("update socket disconnected"); private Emitter.Listener onDisconnect = args -> Utils.i(AppConfig.TAG_UPDATE, "update socket disconnected");
Emitter.Listener onUpgrade = args -> { private Emitter.Listener onUpgrade = args -> {
Utils.i("update socket upgrade"); Utils.i(AppConfig.TAG_UPDATE, "update socket upgrade");
process("upgrade", args); process("upgrade", args);
}; };
public void close() { public void close() {
try { try {
Utils.i("close update socket"); Utils.i(AppConfig.TAG_UPDATE, "close update socket");
if (mSocket != null) { if (mSocket != null) {
mSocket.disconnect(); mSocket.disconnect();
mSocket.off("connect", onConnect); mSocket.off("connect", onConnect);
...@@ -67,29 +68,29 @@ public class UpdateSocket extends Thread { ...@@ -67,29 +68,29 @@ public class UpdateSocket extends Thread {
// mSocket = null; // mSocket = null;
} }
} catch (Exception e) { } catch (Exception e) {
Utils.i("close失败,错误原因:" + e.getMessage()); Utils.i(AppConfig.TAG_UPDATE, "close失败,错误原因:" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
private void process(String func, Object[] args) { private void process(String func, Object[] args) {
if (CollectionUtils.isEmpty(args)) { if (CollectionUtils.isEmpty(args)) {
Utils.i(func + " args empty"); Utils.i(AppConfig.TAG_UPDATE, func + " args empty");
return; return;
} }
String content = args[0].toString(); String content = args[0].toString();
if (StringUtils.isEmpty(content)) { if (StringUtils.isEmpty(content)) {
Utils.i(func + " content empty"); Utils.i(AppConfig.TAG_UPDATE, func + " content empty");
return; return;
} }
try { try {
JsonNode node = JsonUtils.getMapper().readValue(content, JsonNode.class); JsonNode node = JsonUtils.getMapper().readValue(content, JsonNode.class);
if (node == null) { if (node == null) {
Utils.i(func + " msg empty"); Utils.i(AppConfig.TAG_UPDATE, func + " msg empty");
return; return;
} }
if (node.get("upgrade") != null && node.get("upgrade").asBoolean()) { if (node.get("upgrade") != null && node.get("upgrade").asBoolean()) {
new UpdateService().start(); new UpdateService(mContext).start();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -13,6 +13,7 @@ import androidx.annotation.RequiresPermission; ...@@ -13,6 +13,7 @@ import androidx.annotation.RequiresPermission;
import com.blankj.utilcode.util.AppUtils; import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.DeviceUtils; import com.blankj.utilcode.util.DeviceUtils;
import com.blankj.utilcode.util.ShellUtils; import com.blankj.utilcode.util.ShellUtils;
import com.ihaoin.hooloo.device.base.AppConfig;
import java.io.File; import java.io.File;
import java.util.Locale; import java.util.Locale;
...@@ -34,14 +35,14 @@ public class ApkUtils { ...@@ -34,14 +35,14 @@ public class ApkUtils {
@SuppressLint("PackageManagerGetSignatures") @SuppressLint("PackageManagerGetSignatures")
@RequiresPermission(Manifest.permission.INSTALL_PACKAGES) @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
public static synchronized boolean install(Context context, String apkFile) { public static synchronized boolean install(Context context, String apkFile) {
Utils.i("start install: " + apkFile); Utils.i(AppConfig.TAG_UPDATE, "start install: " + apkFile);
File file; File file;
if (TextUtils.isEmpty(apkFile) || !(file = new File(apkFile)).exists()) if (TextUtils.isEmpty(apkFile) || !(file = new File(apkFile)).exists())
return false; return false;
//加上apk合法性判断 //加上apk合法性判断
AppUtils.AppInfo apkInfo = AppUtils.getApkInfo(file); AppUtils.AppInfo apkInfo = AppUtils.getApkInfo(file);
if (apkInfo == null || TextUtils.isEmpty(apkInfo.getPackageName())) { if (apkInfo == null || TextUtils.isEmpty(apkInfo.getPackageName())) {
Utils.i("apk info is null, the file maybe damaged: " + file.getAbsolutePath()); Utils.i(AppConfig.TAG_UPDATE, "apk info is null, the file maybe damaged: " + file.getAbsolutePath());
return false; return false;
} }
...@@ -71,7 +72,7 @@ public class ApkUtils { ...@@ -71,7 +72,7 @@ public class ApkUtils {
if (appPackageInfo != null && apkPackageInfo != null && if (appPackageInfo != null && apkPackageInfo != null &&
!compareSharedUserId(appPackageInfo.sharedUserId, apkPackageInfo.sharedUserId)) { !compareSharedUserId(appPackageInfo.sharedUserId, apkPackageInfo.sharedUserId)) {
Utils.i("Apk sharedUserId is not match, app shellUid: " + appPackageInfo.sharedUserId + ", apk shellUid: " + apkPackageInfo.sharedUserId); Utils.i(AppConfig.TAG_UPDATE, "Apk sharedUserId is not match, app shellUid: " + appPackageInfo.sharedUserId + ", apk shellUid: " + apkPackageInfo.sharedUserId);
return false; return false;
} }
} catch (Throwable ignored) { } catch (Throwable ignored) {
...@@ -105,10 +106,10 @@ public class ApkUtils { ...@@ -105,10 +106,10 @@ public class ApkUtils {
if (installByShell(file, DeviceUtils.isDeviceRooted())) { if (installByShell(file, DeviceUtils.isDeviceRooted())) {
// if (sPreferences != null) // if (sPreferences != null)
// sPreferences.edit().putBoolean(apkInfo.getPackageName(), true).apply(); // sPreferences.edit().putBoolean(apkInfo.getPackageName(), true).apply();
Utils.i("Install Success[Shell]: " + file.getPath()); Utils.i(AppConfig.TAG_UPDATE, "Install Success[Shell]: " + file.getPath());
return true; return true;
} }
Utils.i("Install Failure: " + file.getAbsolutePath()); Utils.i(AppConfig.TAG_UPDATE, "Install Failure: " + file.getAbsolutePath());
return false; return false;
} }
...@@ -181,9 +182,9 @@ public class ApkUtils { ...@@ -181,9 +182,9 @@ public class ApkUtils {
// } // }
private static boolean executeShell(String cmd, boolean isRoot) { private static boolean executeShell(String cmd, boolean isRoot) {
Utils.i("ShellCommand: " + cmd + ", isRoot: " + isRoot); Utils.i(AppConfig.TAG_UPDATE, "ShellCommand: " + cmd + ", isRoot: " + isRoot);
ShellUtils.CommandResult result = ShellUtils.execCmd(cmd, isRoot); ShellUtils.CommandResult result = ShellUtils.execCmd(cmd, isRoot);
Utils.i("ShellCommand Result: " + result.toString()); Utils.i(AppConfig.TAG_UPDATE, "ShellCommand Result: " + result.toString());
return result.successMsg != null && result.successMsg.toLowerCase(Locale.US).contains("success"); return result.successMsg != null && result.successMsg.toLowerCase(Locale.US).contains("success");
} }
......
...@@ -12,17 +12,20 @@ public class SharedPreferencesUtils { ...@@ -12,17 +12,20 @@ public class SharedPreferencesUtils {
private final static String KEY_SHOW_LOGCAT = "SHOW_LOGCAT"; private final static String KEY_SHOW_LOGCAT = "SHOW_LOGCAT";
private final static String KEY_MACHINE_CODE = "MACHINE_CODE"; private final static String KEY_MACHINE_CODE = "MACHINE_CODE";
public static String getScreenNo(Context context) { public static Integer getScreenNo(Context context) {
SharedPreferences sp = getSharedPreferences(context); SharedPreferences sp = getSharedPreferences(context);
return sp.getString(KEY_SCREEN_NO, AppConfig.DEFAULT_SCREEN_NO); return sp.getInt(KEY_SCREEN_NO, AppConfig.DEFAULT_SCREEN_NO);
} }
public static void setScreenNo(Context context, String val) { public static void setScreenNo(Context context, Integer val) {
SharedPreferences sp = getSharedPreferences(context); SharedPreferences sp = getSharedPreferences(context);
sp.edit().putString(KEY_SCREEN_NO, val).commit(); sp.edit().putInt(KEY_SCREEN_NO, val).commit();
} }
public static String getMachineCode(Context context) { public static String getMachineCode(Context context) {
if (AppConfig.DEBUG) {
return "SN0091290001";
}
SharedPreferences sp = getSharedPreferences(context); SharedPreferences sp = getSharedPreferences(context);
return sp.getString(KEY_MACHINE_CODE, ""); return sp.getString(KEY_MACHINE_CODE, "");
} }
...@@ -32,16 +35,6 @@ public class SharedPreferencesUtils { ...@@ -32,16 +35,6 @@ public class SharedPreferencesUtils {
sp.edit().putString(KEY_MACHINE_CODE, val).commit(); sp.edit().putString(KEY_MACHINE_CODE, val).commit();
} }
public static String getPresentation(Context context) {
SharedPreferences sp = getSharedPreferences(context);
return sp.getString(KEY_PRESENTATION, AppConfig.DEFAULT_PRESENT);
}
public static void setPresentation(Context context, String val) {
SharedPreferences sp = getSharedPreferences(context);
sp.edit().putString(KEY_PRESENTATION, val).commit();
}
public static Boolean getShowLogcat(Context context) { public static Boolean getShowLogcat(Context context) {
SharedPreferences sp = getSharedPreferences(context); SharedPreferences sp = getSharedPreferences(context);
return sp.getBoolean(KEY_SHOW_LOGCAT, false); return sp.getBoolean(KEY_SHOW_LOGCAT, false);
......
...@@ -33,7 +33,6 @@ import com.ihaoin.hooloo.device.base.Base; ...@@ -33,7 +33,6 @@ import com.ihaoin.hooloo.device.base.Base;
import com.ihaoin.hooloo.device.component.TouchDelegateComposite; import com.ihaoin.hooloo.device.component.TouchDelegateComposite;
import com.ihaoin.hooloo.device.data.TrolleyGoods; import com.ihaoin.hooloo.device.data.TrolleyGoods;
import com.ihaoin.hooloo.device.data.enums.SkuState; import com.ihaoin.hooloo.device.data.enums.SkuState;
import com.ihaoin.hooloo.device.data.vo.Category;
import com.ihaoin.hooloo.device.data.vo.Goods; import com.ihaoin.hooloo.device.data.vo.Goods;
import com.ihaoin.hooloo.device.data.vo.InteractionMsg; import com.ihaoin.hooloo.device.data.vo.InteractionMsg;
import com.ihaoin.hooloo.device.data.vo.KDSMsg; import com.ihaoin.hooloo.device.data.vo.KDSMsg;
...@@ -58,29 +57,6 @@ import java.util.List; ...@@ -58,29 +57,6 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
public class Utils { public class Utils {
public static Goods getGoods(Integer goodsId) {
if (goodsId == null || goodsId <= 0) {
return null;
}
if (HLApplication.getMainData() == null || CollectionUtils.isEmpty(HLApplication.getMainData().getCategorys())) {
return null;
}
for (Category category : HLApplication.getMainData().getCategorys()) {
if (category == null || CollectionUtils.isEmpty(category.getGoods())) {
continue;
}
for (Goods goods : category.getGoods()) {
if (goods == null || goods.getGoodsId() == null) {
continue;
}
if (goods.getGoodsId().equals(goodsId)) {
return goods;
}
}
}
return null;
}
public static List<Sentence> getSents(String... strs) { public static List<Sentence> getSents(String... strs) {
if (CollectionUtils.isEmpty(strs)) { if (CollectionUtils.isEmpty(strs)) {
return null; return null;
...@@ -90,6 +66,7 @@ public class Utils { ...@@ -90,6 +66,7 @@ public class Utils {
Sentence sent = new Sentence(); Sentence sent = new Sentence();
sent.setSentence(s); sent.setSentence(s);
sent.setFontSize(80); sent.setFontSize(80);
sent.setMarginTop(-120);
list.add(sent); list.add(sent);
} }
return list; return list;
...@@ -325,11 +302,15 @@ public class Utils { ...@@ -325,11 +302,15 @@ public class Utils {
} }
public static void showToast(Context context, String text) { public static void showToast(Context context, String text) {
showToast(context, text, Toast.LENGTH_SHORT);
}
public static void showToast(Context context, String text, int t) {
View view = LayoutInflater.from(context).inflate(R.layout.view_toast, null); View view = LayoutInflater.from(context).inflate(R.layout.view_toast, null);
TextView textView = view.findViewById(R.id.txt_toast); TextView textView = view.findViewById(R.id.txt_toast);
textView.setText(text); textView.setText(text);
Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT); Toast toast = Toast.makeText(context, text, t);
toast.setGravity(Gravity.CENTER, 0, 0); toast.setGravity(Gravity.CENTER, 0, 0);
toast.setView(view); toast.setView(view);
toast.show(); toast.show();
...@@ -343,6 +324,10 @@ public class Utils { ...@@ -343,6 +324,10 @@ public class Utils {
return url; return url;
} }
public static Typeface getInteractionFont(Context context) {
return Typeface.createFromAsset(context.getAssets(), "fonts/SourceHanSansCN-Bold.otf");
}
public static Typeface getAmountFont(Context context) { public static Typeface getAmountFont(Context context) {
return Typeface.createFromAsset(context.getAssets(), "fonts/futura_regular.ttf"); return Typeface.createFromAsset(context.getAssets(), "fonts/futura_regular.ttf");
} }
......
...@@ -94,18 +94,36 @@ ...@@ -94,18 +94,36 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="hoo感谢" /> android:text="hoo感谢" />
<!-- <Button-->
<!-- android:id="@+id/butn_2"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:text="hoo感谢2" />-->
<Button <Button
android:id="@+id/butn_2" android:id="@+id/butn_3"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="hoo感谢2" /> android:text="hoo接待1" />
<Button <Button
android:id="@+id/butn_3" android:id="@+id/butn_4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="hoo接待2" />
<Button
android:id="@+id/butn_41"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="hoo接待3" />
<Button
android:id="@+id/butn_5"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="hoo接待" /> android:text="hoo接待4" />
<Button <Button
android:id="@+id/butn_6" android:id="@+id/butn_6"
android:layout_width="0dp" android:layout_width="0dp"
......
...@@ -145,36 +145,6 @@ ...@@ -145,36 +145,6 @@
</LinearLayout> </LinearLayout>
<include layout="@layout/view_line" /> <include layout="@layout/view_line" />
<LinearLayout <LinearLayout
android:id="@+id/layout_presentation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="@null"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="@dimen/padding10"
android:text="副屏内容"
android:textColor="@color/textPrimary"
android:textSize="@dimen/ts_setting_name" />
<TextView
android:id="@+id/txt_presentation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/padding10"
android:text="不显示"
android:textColor="@color/textDisable"
android:textSize="@dimen/ts_setting_desc" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/padding10"
android:src="@drawable/ic_baseline_chevron_right_24_grey" />
</LinearLayout>
<include layout="@layout/view_line" />
<LinearLayout
android:id="@+id/layout_logcat" android:id="@+id/layout_logcat"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true" />
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
android:id="@+id/layout_lines" android:id="@+id/layout_lines"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="75px"
android:layout_marginTop="75px"
android:orientation="vertical"> android:orientation="vertical">
<com.ihaoin.hooloo.device.component.WarpLinearLayout <com.ihaoin.hooloo.device.component.WarpLinearLayout
android:id="@+id/layout_line_1" android:id="@+id/layout_line_1"
...@@ -32,7 +34,7 @@ ...@@ -32,7 +34,7 @@
app:grivate="left" app:grivate="left"
app:horizontal_Space="10px" app:horizontal_Space="10px"
app:isFull="false" app:isFull="false"
app:vertical_Space="5px" /> app:vertical_Space="0px" />
<com.ihaoin.hooloo.device.component.WarpLinearLayout <com.ihaoin.hooloo.device.component.WarpLinearLayout
android:id="@+id/layout_line_2" android:id="@+id/layout_line_2"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -41,7 +43,7 @@ ...@@ -41,7 +43,7 @@
app:grivate="left" app:grivate="left"
app:horizontal_Space="10px" app:horizontal_Space="10px"
app:isFull="false" app:isFull="false"
app:vertical_Space="5px" /> app:vertical_Space="0px" />
<com.ihaoin.hooloo.device.component.WarpLinearLayout <com.ihaoin.hooloo.device.component.WarpLinearLayout
android:id="@+id/layout_line_3" android:id="@+id/layout_line_3"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -50,7 +52,7 @@ ...@@ -50,7 +52,7 @@
app:grivate="left" app:grivate="left"
app:horizontal_Space="10px" app:horizontal_Space="10px"
app:isFull="false" app:isFull="false"
app:vertical_Space="5px" /> app:vertical_Space="0px" />
<com.ihaoin.hooloo.device.component.WarpLinearLayout <com.ihaoin.hooloo.device.component.WarpLinearLayout
android:id="@+id/layout_line_4" android:id="@+id/layout_line_4"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -59,7 +61,7 @@ ...@@ -59,7 +61,7 @@
app:grivate="left" app:grivate="left"
app:horizontal_Space="10px" app:horizontal_Space="10px"
app:isFull="false" app:isFull="false"
app:vertical_Space="5px" /> app:vertical_Space="0px" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
...@@ -87,27 +89,73 @@ ...@@ -87,27 +89,73 @@
android:layout_height="@dimen/interaction_goods_icon_height" android:layout_height="@dimen/interaction_goods_icon_height"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />
</LinearLayout> </LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/layout_recommend"
android:layout_alignBottom="@+id/layout_recommend"
android:layout_marginTop="-40px"
android:layout_marginBottom="-40px">
<ImageView
android:id="@+id/light1"
android:layout_width="300px"
android:layout_height="300px"
android:layout_alignParentLeft="true"
android:src="@mipmap/light1"
android:visibility="invisible" />
<ImageView
android:id="@+id/light2"
android:layout_width="300px"
android:layout_height="300px"
android:layout_alignParentRight="true"
android:src="@mipmap/light2"
android:visibility="invisible" />
</RelativeLayout>
<ImageView <ImageView
android:id="@+id/view_start" android:id="@+id/view_start"
android:layout_width="180px" android:layout_width="180px"
android:layout_height="50px" android:layout_height="50px"
android:layout_marginLeft="500px" android:layout_marginLeft="500px"
android:layout_marginTop="1005px" android:layout_marginTop="1005px" />
android:background="#55FF0000" />
<AbsoluteLayout <AbsoluteLayout
android:id="@+id/layout_chars_fly" android:id="@+id/layout_chars_fly"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<!-- <TextView--> <!-- <TextView-->
<!-- android:layout_width="wrap_content"--> <!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"--> <!-- android:layout_height="wrap_content"-->
<!-- android:layout_x="520px"--> <!-- android:layout_x="520px"-->
<!-- android:layout_y="1030px"--> <!-- android:layout_y="1030px"-->
<!-- android:text="中国人s"--> <!-- android:text="中国人s"-->
<!-- android:textColor="@android:color/white"--> <!-- android:textColor="@android:color/white"-->
<!-- android:textSize="40px" />--> <!-- android:textSize="40px" />-->
</AbsoluteLayout> </AbsoluteLayout>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:orientation="vertical">-->
<!-- <TextView-->
<!-- android:id="@+id/test1"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:background="@color/black"-->
<!-- android:text="12345"-->
<!-- android:textColor="@android:color/holo_red_dark"-->
<!-- android:textSize="60px" />-->
<!-- <TextView-->
<!-- android:id="@+id/test2"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="40px"-->
<!-- android:background="@color/black"-->
<!-- android:text="12345"-->
<!-- android:textColor="@android:color/holo_red_dark"-->
<!-- android:textSize="120px" />-->
<!-- </LinearLayout>-->
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
<dimen name="ts_interaction_line1">260px</dimen> <dimen name="ts_interaction_line1">260px</dimen>
<dimen name="ts_interaction_line2">100px</dimen> <dimen name="ts_interaction_line2">100px</dimen>
<dimen name="ts_interaction_line3">100px</dimen> <dimen name="ts_interaction_line3">100px</dimen>
<dimen name="ts_interaction_recommend_small">40px</dimen> <dimen name="ts_interaction_recommend_small">50px</dimen>
<dimen name="ts_interaction_recommend_big">60px</dimen> <dimen name="ts_interaction_recommend_big">60px</dimen>
<dimen name="ic_recommend">17px</dimen> <dimen name="ic_recommend">17px</dimen>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<color name="textGrayF0">#FFF0F0F0</color> <color name="textGrayF0">#FFF0F0F0</color>
<color name="textGrayF6">#FFF6F6F6</color> <color name="textGrayF6">#FFF6F6F6</color>
<color name="textGrayD8">#FFD8D8D8</color> <color name="textGrayD8">#FFD8D8D8</color>
<color name="textGray11">#FF111111</color>
<color name="line">#FFECECEC</color> <color name="line">#FFECECEC</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
...@@ -19,4 +20,12 @@ ...@@ -19,4 +20,12 @@
<color name="menu_order_bg">#FF4A71FF</color> <color name="menu_order_bg">#FF4A71FF</color>
<color name="menu_state_bg">#FFDEF0FF</color> <color name="menu_state_bg">#FFDEF0FF</color>
<color name="menu_state_text">#FF006ECF</color> <color name="menu_state_text">#FF006ECF</color>
<color name="fly_text1">#FF006ECF</color>
<color name="fly_text2">#FF0000</color>
<color name="fly_text3">#FF7F00</color>
<color name="fly_text4">#FFFF00</color>
<color name="fly_text5">#00FF00</color>
<color name="fly_text6">#00FFFF</color>
<color name="fly_text7">#0000FF</color>
<color name="fly_text8">#8B00FF</color>
</resources> </resources>
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
<dimen name="ts_interaction_line1">260px</dimen> <dimen name="ts_interaction_line1">260px</dimen>
<dimen name="ts_interaction_line2">100px</dimen> <dimen name="ts_interaction_line2">100px</dimen>
<dimen name="ts_interaction_line3">100px</dimen> <dimen name="ts_interaction_line3">100px</dimen>
<dimen name="ts_interaction_recommend_small">40px</dimen> <dimen name="ts_interaction_recommend_small">50px</dimen>
<dimen name="ts_interaction_recommend_big">60px</dimen> <dimen name="ts_interaction_recommend_big">60px</dimen>
<dimen name="ic_recommend">17px</dimen> <dimen name="ic_recommend">17px</dimen>
......
## 未解决事项 TODO ## 未解决事项
***** 1、update socket联调
\ No newline at end of file 2、App静默升级验证
\ 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