Commit c08b2d1c by wjg

init

parent cac7a74f
...@@ -61,6 +61,7 @@ dependencies { ...@@ -61,6 +61,7 @@ dependencies {
implementation 'com.aliyun.alink.linksdk:iot-linkkit:1.7.2' implementation 'com.aliyun.alink.linksdk:iot-linkkit:1.7.2'
implementation 'com.aliyun.alink.linksdk:public-channel-core:0.7.7.1' implementation 'com.aliyun.alink.linksdk:public-channel-core:0.7.7.1'
implementation 'com.aliyun.alink.linksdk:iot-device-manager:1.7.5.0' implementation 'com.aliyun.alink.linksdk:iot-device-manager:1.7.5.0'
implementation 'com.google.zxing:core:3.3.0'
// 引入极光 SDK // 引入极光 SDK
implementation project(':library_jiguang') implementation project(':library_jiguang')
......
package com.ihaoin.hooloo.device; package com.ihaoin.hooloo.device;
import android.app.Application; import android.app.Application;
import android.util.Log;
import com.ihaoin.hooloo.device.config.AppConfig; import com.ihaoin.hooloo.device.config.AppConfig;
import com.ihaoin.hooloo.device.data.MainData;
import com.ihaoin.hooloo.device.network.HttpUtil; import com.ihaoin.hooloo.device.network.HttpUtil;
import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushInterface;
public class HLApplication extends Application { public class HLApplication extends Application {
private static MainData mainData = new MainData();
public static MainData getMainData() {
return mainData;
}
public static void setMainData(MainData data) {
mainData = data;
}
@Override @Override
public void onCreate() { public void onCreate() {
...@@ -18,6 +29,8 @@ public class HLApplication extends Application { ...@@ -18,6 +29,8 @@ public class HLApplication extends Application {
JPushInterface.setDebugMode(true); JPushInterface.setDebugMode(true);
JPushInterface.init(this); JPushInterface.init(this);
Log.d("PushMessageReceiver", JPushInterface.getRegistrationID(this));
// HttpUtil.postRegistrationId(JPushInterface.getRegistrationID(this), null);
} }
@Override @Override
......
...@@ -64,14 +64,16 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -64,14 +64,16 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
}); });
} }
ImageView imgThumbnail = helper.getView(R.id.img_thumbnail); ImageView imgThumbnail = helper.getView(R.id.img_thumbnail);
RoundedCorners roundedCorners = new RoundedCorners(5); RoundedCorners roundedCorners = new RoundedCorners(5);
RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
Glide.with(mContext).load(goods.getPics().getThumbnail()).apply(options).into(imgThumbnail); if (goods.getPics() == null) {
imgThumbnail.setImageDrawable(null);
} else {
Glide.with(mContext).load(goods.getPics().getThumbnail()).apply(options).into(imgThumbnail);
}
Sku sku = getSku(goods.getSkus()); Sku sku = getSku(goods.getSkus());
if (sku == null) { if (sku == null) {
helper.setGone(R.id.txt_sellout, true); helper.setGone(R.id.txt_sellout, true);
helper.setGone(R.id.butn_add, false); helper.setGone(R.id.butn_add, false);
...@@ -83,15 +85,6 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -83,15 +85,6 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
ViewGroup layoutItem = helper.getView(R.id.layout_item); ViewGroup layoutItem = helper.getView(R.id.layout_item);
Utils.setTouchDelegate(layoutItem, Arrays.asList(butnAdd), 15); Utils.setTouchDelegate(layoutItem, Arrays.asList(butnAdd), 15);
// butnAdd.post(() -> {
// Rect bounds = new Rect();
// ViewGroupUtils.getDescendantRect(layoutItem, butnAdd, bounds);
// bounds.top -= Utils.dpToPx(mContext, 15);
// bounds.left -= Utils.dpToPx(mContext, 15);
// bounds.bottom += Utils.dpToPx(mContext, 15);
// bounds.right += Utils.dpToPx(mContext, 15);
// layoutItem.setTouchDelegate(new TouchDelegate(bounds, butnAdd));
// });
} }
View layoutItem = helper.getView(R.id.layout_item); View layoutItem = helper.getView(R.id.layout_item);
......
...@@ -34,13 +34,13 @@ public class RecommendAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseVi ...@@ -34,13 +34,13 @@ public class RecommendAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseVi
protected void convert(BaseViewHolder helper, ScrollBean item) { protected void convert(BaseViewHolder helper, ScrollBean item) {
ScrollBean.ScrollItemBean t = item.t; ScrollBean.ScrollItemBean t = item.t;
Recommend recommend = (Recommend) t.getObject(); Recommend recommend = (Recommend) t.getObject();
helper.setText(R.id.txt_name, recommend.getTitle()); helper.setText(R.id.txt_name, recommend.getGoodsName());
helper.setText(R.id.txt_intro, recommend.getDesc()); helper.setText(R.id.txt_intro, recommend.getDesc());
ImageView imgRecommend = helper.getView(R.id.img_recommend); ImageView imgRecommend = helper.getView(R.id.img_recommend);
RoundedCorners roundedCorners = new RoundedCorners(5); RoundedCorners roundedCorners = new RoundedCorners(5);
RequestOptions options = RequestOptions.bitmapTransform(roundedCorners); RequestOptions options = RequestOptions.bitmapTransform(roundedCorners);
Glide.with(mContext).load(recommend.getBackground()).apply(options).into(imgRecommend); Glide.with(mContext).load(recommend.getPic()).apply(options).into(imgRecommend);
View layoutItem = helper.getView(R.id.layout_item); View layoutItem = helper.getView(R.id.layout_item);
layoutItem.setOnClickListener(v -> Utils.showGoodsDetail(mContext, recommend.getGoods())); layoutItem.setOnClickListener(v -> Utils.showGoodsDetail(mContext, recommend.getGoods()));
......
...@@ -29,7 +29,7 @@ public class PushMessageReceiver extends JPushMessageReceiver { ...@@ -29,7 +29,7 @@ public class PushMessageReceiver extends JPushMessageReceiver {
subscribers.put(key, handler); subscribers.put(key, handler);
} }
public static void unsubscribe(String key, Handler handler) { public static void unsubscribe(String key) {
subscribers.remove(key); subscribers.remove(key);
} }
......
...@@ -5,5 +5,7 @@ public class AppConfig { ...@@ -5,5 +5,7 @@ public class AppConfig {
public static Boolean DEBUG = true; public static Boolean DEBUG = true;
/** 机器编码 */ /** 机器编码 */
public static String MACHINE_CODE = ""; public static String MACHINE_CODE = "";
/** 打开微信网址 */
public static String WX_URL = "https://www.bjjsycloud.com/?id=%s";
} }
...@@ -5,6 +5,7 @@ public class Base { ...@@ -5,6 +5,7 @@ public class Base {
public static final Integer FALSE = 0; public static final Integer FALSE = 0;
public static final String NOTIFY_ACTION_ORDER_STATE_CHANGED = "ORDER_STATE_CHANGED"; public static final String NOTIFY_ACTION_ORDER_STATE_CHANGED = "ORDER_STATE_CHANGED";
public static final String NOTIFY_ACTION_SKU_STATE_CHANGED = "SKU_STATE_CHANGED";
public static final String NOTIFY_ACTION_QRCODE_VISITED = "QRCODE_VISITED"; public static final String NOTIFY_ACTION_QRCODE_VISITED = "QRCODE_VISITED";
public static final String ADD_GOODS_ACTION = "ADD_GOODS_ACTION"; public static final String ADD_GOODS_ACTION = "ADD_GOODS_ACTION";
......
package com.ihaoin.hooloo.device.data;
import com.ihaoin.hooloo.device.data.vo.Category;
import com.ihaoin.hooloo.device.data.vo.Recommend;
import com.ihaoin.hooloo.device.data.vo.RightImage;
import java.util.List;
public class Datas {
public static Integer COUNT_OF_ORDER = 9;
public static String tips = "http://www.baidu.com";
public static Integer SHOP_STATE = 1;
public static List<String> leftImages;
public static List<RightImage> rightImages;
public static List<Recommend> recommends;
public static List<Category> categorys;
}
package com.ihaoin.hooloo.device.data;
import com.ihaoin.hooloo.device.data.vo.Category;
import com.ihaoin.hooloo.device.data.vo.Images;
import com.ihaoin.hooloo.device.data.vo.Recommend;
import java.util.List;
public class MainData {
private Integer countOfOrder = 9;
private String tips = "http://www.baidu.com";
private Integer shopState = 1;
private Images images;
private List<Recommend> recommends;
private List<Category> categorys;
public Integer getCountOfOrder() {
return countOfOrder;
}
public void setCountOfOrder(Integer countOfOrder) {
this.countOfOrder = countOfOrder;
}
public String getTips() {
return tips;
}
public void setTips(String tips) {
this.tips = tips;
}
public Integer getShopState() {
return shopState;
}
public void setShopState(Integer shopState) {
this.shopState = shopState;
}
public Images getImages() {
return images;
}
public void setImages(Images images) {
this.images = images;
}
public List<Recommend> getRecommends() {
return recommends;
}
public void setRecommends(List<Recommend> recommends) {
this.recommends = recommends;
}
public List<Category> getCategorys() {
return categorys;
}
public void setCategorys(List<Category> categorys) {
this.categorys = categorys;
}
}
package com.ihaoin.hooloo.device.data.enums; package com.ihaoin.hooloo.device.data.enums;
public enum ImageState { public enum ImageState {
CLOSED(0, "歇业"), CLOSED("closeDown", "歇业"),
COOKING(1, "制作中"), COOKING("inProduction", "制作中"),
COMPLETED(2, "有待取餐"), COMPLETED("thereAOrder", "有待取餐"),
NOT_COMPLETED(3, "无待取餐"); NOT_COMPLETED("noOrder", "无待取餐");
private Integer code; private String code;
private String name; private String name;
ImageState(Integer code, String name) { ImageState(String code, String name) {
this.code = code; this.code = code;
this.name = name; this.name = name;
} }
public static ImageState get(Integer code) { public static ImageState get(String code) {
for (ImageState state : ImageState.values()) { for (ImageState state : ImageState.values()) {
if (state.getCode().equals(code)) { if (state.getCode().equals(code)) {
return state; return state;
...@@ -23,7 +23,7 @@ public enum ImageState { ...@@ -23,7 +23,7 @@ public enum ImageState {
return null; return null;
} }
public Integer getCode() { public String getCode() {
return code; return code;
} }
......
...@@ -45,12 +45,6 @@ public class Category implements Serializable { ...@@ -45,12 +45,6 @@ public class Category implements Serializable {
this.goods = goods; this.goods = goods;
} }
public Category(Integer id, String name, List<Goods> goods) {
this.setId(id);
this.setName(name);
this.setGoods(goods);
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null) { if (o == null) {
......
...@@ -6,7 +6,7 @@ import java.util.List; ...@@ -6,7 +6,7 @@ import java.util.List;
public class Goods implements Serializable { public class Goods implements Serializable {
/** 商品id */ /** 商品id */
private Integer goodId; private Integer goodsId;
/** 名称 */ /** 名称 */
private String name; private String name;
/** 原价 */ /** 原价 */
...@@ -16,7 +16,7 @@ public class Goods implements Serializable { ...@@ -16,7 +16,7 @@ public class Goods implements Serializable {
/** 介绍 */ /** 介绍 */
private String desc; private String desc;
/** 备注 */ /** 备注 */
private String remark; private String remarks;
/** 图片信息 */ /** 图片信息 */
private Pics pics; private Pics pics;
/** 规格 */ /** 规格 */
...@@ -26,21 +26,12 @@ public class Goods implements Serializable { ...@@ -26,21 +26,12 @@ public class Goods implements Serializable {
/** SKU */ /** SKU */
private List<Sku> skus; private List<Sku> skus;
// public Goods(Integer id, String name, Pics pics){ public Integer getGoodsId() {
// this.setGoodId(id); return goodsId;
// this.setName(name);
// this.setPics(pics);
// }
//
// public Goods(){
// }
public Integer getGoodId() {
return goodId;
} }
public void setGoodId(Integer goodId) { public void setGoodsId(Integer goodsId) {
this.goodId = goodId; this.goodsId = goodsId;
} }
public String getName() { public String getName() {
...@@ -75,12 +66,12 @@ public class Goods implements Serializable { ...@@ -75,12 +66,12 @@ public class Goods implements Serializable {
this.desc = desc; this.desc = desc;
} }
public String getRemark() { public String getRemarks() {
return remark; return remarks;
} }
public void setRemark(String remark) { public void setRemarks(String remarks) {
this.remark = remark; this.remarks = remarks;
} }
public Pics getPics() { public Pics getPics() {
......
...@@ -20,6 +20,10 @@ public class GoodsRule implements Serializable { ...@@ -20,6 +20,10 @@ public class GoodsRule implements Serializable {
*/ */
private Integer isDefault; private Integer isDefault;
/** /**
* 是否推荐
*/
private Integer isRecommend;
/**
* 状态,1-可售、0-不可售 * 状态,1-可售、0-不可售
*/ */
private Integer state = Base.TRUE; private Integer state = Base.TRUE;
...@@ -67,4 +71,12 @@ public class GoodsRule implements Serializable { ...@@ -67,4 +71,12 @@ public class GoodsRule implements Serializable {
public void setState(Integer state) { public void setState(Integer state) {
this.state = state; this.state = state;
} }
public Integer getIsRecommend() {
return isRecommend;
}
public void setIsRecommend(Integer isRecommend) {
this.isRecommend = isRecommend;
}
} }
package com.ihaoin.hooloo.device.data.vo;
import java.io.Serializable;
import java.util.Map;
public class Images implements Serializable {
private String left;
private Map<String, String> right;
public String getLeft() {
return left;
}
public void setLeft(String left) {
this.left = left;
}
public Map<String, String> getRight() {
return right;
}
public void setRight(Map<String, String> right) {
this.right = right;
}
}
...@@ -6,7 +6,7 @@ public class Recommend implements Serializable { ...@@ -6,7 +6,7 @@ public class Recommend implements Serializable {
/** /**
* 推荐标题 * 推荐标题
*/ */
private String title; private String goodsName;
/** /**
* 推荐介绍 * 推荐介绍
...@@ -16,26 +16,19 @@ public class Recommend implements Serializable { ...@@ -16,26 +16,19 @@ public class Recommend implements Serializable {
/** /**
* 推荐背景图 * 推荐背景图
*/ */
private String background; private String pic;
/** /**
* 商品信息 * 商品信息
*/ */
private Goods goods; private Goods goods;
public Recommend(String title, String desc, String background, Goods goods) { public String getGoodsName() {
this.setTitle(title); return goodsName;
this.setDesc(desc);
this.setBackground(background);
this.setGoods(goods);
} }
public String getTitle() { public void setGoodsName(String goodsName) {
return title; this.goodsName = goodsName;
}
public void setTitle(String title) {
this.title = title;
} }
public String getDesc() { public String getDesc() {
...@@ -46,12 +39,12 @@ public class Recommend implements Serializable { ...@@ -46,12 +39,12 @@ public class Recommend implements Serializable {
this.desc = desc; this.desc = desc;
} }
public String getBackground() { public String getPic() {
return background; return pic;
} }
public void setBackground(String background) { public void setPic(String pic) {
this.background = background; this.pic = pic;
} }
public Goods getGoods() { public Goods getGoods() {
......
package com.ihaoin.hooloo.device.data.vo;
import java.io.Serializable;
public class ResultVo<T> implements Serializable {
private Integer code;
private String msg;
private T data;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
package com.ihaoin.hooloo.device.data.vo;
import java.io.Serializable;
public class RightImage implements Serializable {
/**
* 状态
*/
private Integer state;
/**
* 网址
*/
private String url;
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public RightImage(Integer state, String url) {
this.state = state;
this.url = url;
}
}
package com.ihaoin.hooloo.device.data.vo; package com.ihaoin.hooloo.device.data.vo;
import com.alibaba.fastjson.annotation.JSONField;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
...@@ -15,6 +17,7 @@ public class Sku implements Serializable { ...@@ -15,6 +17,7 @@ public class Sku implements Serializable {
/** 原价 */ /** 原价 */
private BigDecimal price; private BigDecimal price;
/** 折扣价 */ /** 折扣价 */
@JSONField(name = "disCount")
private BigDecimal discount; private BigDecimal discount;
/** SKU规格 */ /** SKU规格 */
private List<SkuRule> rules; private List<SkuRule> rules;
......
package com.ihaoin.hooloo.device.network;
public class BizException extends RuntimeException {
public BizException(String msg) {
super(msg);
}
}
\ No newline at end of file
package com.ihaoin.hooloo.device.network; package com.ihaoin.hooloo.device.network;
public class BaseParams { public class HttpParams {
private static final String HOST = "http://114.115.234.81:8080"; private static final String HOST = "http://114.115.234.81:8080";
/** 首页获取数据 */
public static final String GET_MAIN_DATA = HOST + "/application/getOrderTaking?machineCode=%s"; public static final String GET_MAIN_DATA = HOST + "/application/getOrderTaking?machineCode=%s";
/** 获取订单信息 */
public static final String GET_ORDERS = HOST + "/application/getOrderInfo?machineCode=%s"; public static final String GET_ORDERS = HOST + "/application/getOrderInfo?machineCode=%s";
/** 校验SKU状态 */
public static final String CHECK_SKU = HOST + "/application/checkSku?machineCode=%s&skuId=%s";
/** 保存购物车数据 */
public static final String POST_CONFIRM_ORDER = HOST + "/application/saveData?machineCode=%s"; public static final String POST_CONFIRM_ORDER = HOST + "/application/saveData?machineCode=%s";
/** 保存推送ID */
public static final String POST_REGISTRATION_ID = HOST + "/application/jgRegister?machineCode=%s&registerId=%s"; public static final String POST_REGISTRATION_ID = HOST + "/application/jgRegister?machineCode=%s&registerId=%s";
public static final String GET_CHECK_SKU = HOST + "/application/checkSku?machineCode=%s&skuId=%s";
} }
...@@ -4,6 +4,10 @@ import android.os.Handler; ...@@ -4,6 +4,10 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ihaoin.hooloo.device.config.AppConfig;
import java.io.IOException; import java.io.IOException;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.util.Collections; import java.util.Collections;
...@@ -21,70 +25,104 @@ public class HttpUtil { ...@@ -21,70 +25,104 @@ public class HttpUtil {
private static final String TAG = "Network"; private static final String TAG = "Network";
public static void post(String url, String body, Handler handler) { public static void post(String url, String body, Handler handler) {
if (body == null) {
body = "";
}
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), body); RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), body);
Request request = new Request.Builder().url(url).post(requestBody).build(); Request request = new Request.Builder().url(url).post(requestBody).build();
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, IOException e) { public void onFailure(Call call, IOException e) {
HttpUtil.onFailure(handler, e); HttpUtil.onFailure(handler, call, e);
}
@Override
public void onResponse(Call call, Response response) {
HttpUtil.onResponse(handler, call, response);
}
});
}
public static void get(String url, Handler handler) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).get().build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
HttpUtil.onFailure(handler, call, e);
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(Call call, Response response) {
HttpUtil.onResponse(handler, response); HttpUtil.onResponse(handler, call, response);
} }
}); });
} }
private static void onFailure(Handler handler, Exception e) { private static void onFailure(Handler handler, Call call, Exception e) {
if (AppConfig.DEBUG) {
String msgText = String.format("返回状态:%s, 请求:%s, 返回内容:%s", 0, call.request().url(), e.getMessage());
Log.e(TAG, msgText);
}
if (handler == null) { if (handler == null) {
String msgText = String.format("返回状态:%s, 返回内容:%s", 0, e.getMessage());
Log.d(TAG, msgText);
return; return;
} }
try { try {
Thread.sleep(3000); Thread.sleep(3000);
} catch (InterruptedException e3) { } catch (Exception e3) {
e3.printStackTrace(); e3.printStackTrace();
} }
Message msg = handler.obtainMessage(0, e); Message msg = handler.obtainMessage(0, e);
handler.sendMessage(msg); handler.sendMessage(msg);
} }
private static void onResponse(Handler handler, Response response) throws IOException { private static void onResponse(Handler handler, Call call, Response response) {
if (handler == null) {
String msgText = String.format("返回状态:%s, 返回内容:%s", 1, response.body() == null ? "" : response.body().string());
Log.d(TAG, msgText);
return;
}
try { try {
Thread.sleep(3000); String responseBody = response.body().string();
} catch (InterruptedException e) { if (AppConfig.DEBUG) {
e.printStackTrace(); String msgText = String.format("返回状态:%s, 请求:%s, 返回内容:%s", 1, call.request().url(), responseBody);
Log.i(TAG, msgText);
}
if (handler == null) {
return;
}
// Thread.sleep(3000);
JSONObject jsonObject = JSON.parseObject(responseBody);
if (jsonObject == null || jsonObject.getInteger("code") == null || jsonObject.getInteger("code") != 200) {
onFailure(handler, call, new BizException("返回状态错误"));
return;
}
Message msg = handler.obtainMessage(1, jsonObject.get("data") == null ? "" : jsonObject.get("data").toString());
handler.sendMessage(msg);
} catch (Exception e) {
onFailure(handler, call, e);
} }
Message msg = handler.obtainMessage(1, response.body() == null ? "" : response.body().string());
handler.sendMessage(msg);
} }
public static void getMainDatas(String body, Handler handler) { public static void getMainDatas(Handler handler) {
post(BaseParams.GET_MAIN_DATA, body, handler); String url = String.format(HttpParams.GET_MAIN_DATA, AppConfig.MACHINE_CODE);
get(url, handler);
} }
public static void getOrders(String body, Handler handler) { public static void getOrders(Handler handler) {
post(BaseParams.GET_ORDERS, body, handler); String url = String.format(HttpParams.GET_ORDERS, AppConfig.MACHINE_CODE);
get(url, handler);
} }
public static void postConfirmOrder(String body, Handler handler) { public static void postConfirmOrder(String body, Handler handler) {
post(BaseParams.POST_CONFIRM_ORDER, body, handler); String url = String.format(HttpParams.POST_CONFIRM_ORDER, AppConfig.MACHINE_CODE);
post(url, body, handler);
} }
public static void postRegistrationId(String body, Handler handler) { public static void postRegistrationId(String registrationId, Handler handler) {
post(BaseParams.POST_REGISTRATION_ID, body, handler); String url = String.format(HttpParams.POST_REGISTRATION_ID, AppConfig.MACHINE_CODE, registrationId);
get(url, handler);
} }
public static void checkSku(String body, Handler handler) { public static void checkSku(Integer skuId, Handler handler) {
post(BaseParams.GET_CHECK_SKU, body, handler); String url = String.format(HttpParams.CHECK_SKU, AppConfig.MACHINE_CODE, skuId);
get(url, handler);
} }
public static String getMacAddress() { public static String getMacAddress() {
......
...@@ -4,6 +4,14 @@ import java.util.Collection; ...@@ -4,6 +4,14 @@ import java.util.Collection;
import java.util.Map; import java.util.Map;
public class CollectionUtils { public class CollectionUtils {
public static <T> T lastItem(Collection<T> collection) {
if (isEmpty(collection)) {
return null;
}
return (T) collection.toArray()[collection.size() - 1];
}
public static Boolean isEmpty(Object[] collection) { public static Boolean isEmpty(Object[] collection) {
if (collection == null || collection.length == 0) { if (collection == null || collection.length == 0) {
return true; return true;
......
...@@ -7,4 +7,14 @@ public class StringUtils { ...@@ -7,4 +7,14 @@ public class StringUtils {
} }
return false; return false;
} }
public static int indexOf(Object[] items, Object obj) {
for (int i = 0; i < items.length; i++) {
Object item = items[i];
if (item.equals(obj)) {
return i;
}
}
return 0;
}
} }
...@@ -73,12 +73,13 @@ public class Utils { ...@@ -73,12 +73,13 @@ public class Utils {
public static void openSystemSettings(Context context) { public static void openSystemSettings(Context context) {
Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS); Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent); // 打开系统设置界面 context.startActivity(intent); // 打开系统设置界面
} }
public static void openAppSettings(Context context) { public static void openAppSettings(Context context) {
Intent intent = new Intent(context, SettingsActivity.class); Intent intent = new Intent(context, SettingsActivity.class);
context.startActivity(intent); // 打开系统设置界面 context.startActivity(intent);
} }
/** /**
...@@ -124,7 +125,7 @@ public class Utils { ...@@ -124,7 +125,7 @@ public class Utils {
return null; return null;
} }
ConfirmGoods g = new ConfirmGoods(); ConfirmGoods g = new ConfirmGoods();
g.setGoodsId(goods.getGoodId()); g.setGoodsId(goods.getGoodsId());
g.setSkuId(sku.getSkuId()); g.setSkuId(sku.getSkuId());
g.setCount(count); g.setCount(count);
return Arrays.asList(g); return Arrays.asList(g);
......
...@@ -16,9 +16,9 @@ import android.widget.Toast; ...@@ -16,9 +16,9 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.config.Base; import com.ihaoin.hooloo.device.config.Base;
import com.ihaoin.hooloo.device.data.Datas;
import com.ihaoin.hooloo.device.data.vo.Goods; import com.ihaoin.hooloo.device.data.vo.Goods;
import com.ihaoin.hooloo.device.data.vo.GoodsRule; import com.ihaoin.hooloo.device.data.vo.GoodsRule;
import com.ihaoin.hooloo.device.data.vo.Sku; import com.ihaoin.hooloo.device.data.vo.Sku;
...@@ -48,15 +48,15 @@ public class GoodsDetailDialog extends Dialog { ...@@ -48,15 +48,15 @@ public class GoodsDetailDialog extends Dialog {
private Button butnAdd; private Button butnAdd;
private Button butnBuy; private Button butnBuy;
private Button butnTrolley; private Button butnTrolley;
private View layoutOperate;
private View layoutButns;
private View txtSellout;
private Integer count = 1; private Integer count = 1;
public GoodsDetailDialog(@NonNull Context context, Goods goods) { public GoodsDetailDialog(@NonNull Context context, Goods goods) {
super(context); super(context);
this.goods = goods; this.goods = goods;
// 处理售罄的SKU和规格选项
processSpecRules();
} }
@Override @Override
...@@ -67,6 +67,9 @@ public class GoodsDetailDialog extends Dialog { ...@@ -67,6 +67,9 @@ public class GoodsDetailDialog extends Dialog {
} }
private void initViews() { private void initViews() {
layoutButns = findViewById(R.id.layout_butns);
layoutOperate = findViewById(R.id.layout_operate);
txtSellout = findViewById(R.id.txt_sellout);
butnClose = findViewById(R.id.butn_close); butnClose = findViewById(R.id.butn_close);
imgIntro = findViewById(R.id.img_intro); imgIntro = findViewById(R.id.img_intro);
txtName = findViewById(R.id.txt_name); txtName = findViewById(R.id.txt_name);
...@@ -82,7 +85,11 @@ public class GoodsDetailDialog extends Dialog { ...@@ -82,7 +85,11 @@ public class GoodsDetailDialog extends Dialog {
butnClose.setOnClickListener(x -> dismiss()); butnClose.setOnClickListener(x -> dismiss());
Glide.with(getContext()).load(goods.getPics().getIntroImages().get(0)).into(imgIntro); if (goods.getPics() == null) {
imgIntro.setImageDrawable(null);
} else {
Glide.with(getContext()).load(goods.getPics().getIntroImages().get(0)).into(imgIntro);
}
txtName.setText(goods.getName()); txtName.setText(goods.getName());
butnSubtract.setOnClickListener(v -> subtractGoods()); butnSubtract.setOnClickListener(v -> subtractGoods());
...@@ -94,6 +101,9 @@ public class GoodsDetailDialog extends Dialog { ...@@ -94,6 +101,9 @@ public class GoodsDetailDialog extends Dialog {
ViewGroup layoutItem = findViewById(R.id.layout_item); ViewGroup layoutItem = findViewById(R.id.layout_item);
Utils.setTouchDelegate(layoutItem, Arrays.asList(butnAdd, butnSubtract), 15); Utils.setTouchDelegate(layoutItem, Arrays.asList(butnAdd, butnSubtract), 15);
// 处理售罄的SKU和规格选项
processSpecRules();
buildSpecs(); buildSpecs();
buildDetails(); buildDetails();
} }
...@@ -117,8 +127,8 @@ public class GoodsDetailDialog extends Dialog { ...@@ -117,8 +127,8 @@ public class GoodsDetailDialog extends Dialog {
} }
private void addGoods() { private void addGoods() {
if (count >= Datas.COUNT_OF_ORDER) { if (count >= HLApplication.getMainData().getCountOfOrder()) {
Toast.makeText(this.getContext(), getContext().getString(R.string.count_limit, Datas.COUNT_OF_ORDER.toString()), Toast.LENGTH_SHORT).show(); Toast.makeText(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getMainData().getCountOfOrder().toString()), Toast.LENGTH_SHORT).show();
return; return;
} }
count++; count++;
...@@ -222,7 +232,8 @@ public class GoodsDetailDialog extends Dialog { ...@@ -222,7 +232,8 @@ public class GoodsDetailDialog extends Dialog {
} }
private void processSpecRules() { private void processSpecRules() {
if (goods == null || CollectionUtils.isEmpty(goods.getSpecs())) { if (goods == null || CollectionUtils.isEmpty(goods.getSpecs()) || CollectionUtils.isEmpty(goods.getSkus())) {
showSelloutViews();
return; return;
} }
// 将售罄和未售罄的SKU分组 // 将售罄和未售罄的SKU分组
...@@ -233,6 +244,10 @@ public class GoodsDetailDialog extends Dialog { ...@@ -233,6 +244,10 @@ public class GoodsDetailDialog extends Dialog {
// 售罄SKU列表 // 售罄SKU列表
List<Sku> sellOuts = map.get(Base.FALSE); List<Sku> sellOuts = map.get(Base.FALSE);
List<Sku> sellIns = map.get(Base.TRUE); List<Sku> sellIns = map.get(Base.TRUE);
if (CollectionUtils.isEmpty(sellIns)) {
showSelloutViews();
return;
}
if (CollectionUtils.isEmpty(sellOuts)) { if (CollectionUtils.isEmpty(sellOuts)) {
return; return;
} }
...@@ -248,6 +263,12 @@ public class GoodsDetailDialog extends Dialog { ...@@ -248,6 +263,12 @@ public class GoodsDetailDialog extends Dialog {
}); });
} }
private void showSelloutViews() {
layoutOperate.setVisibility(View.GONE);
layoutButns.setVisibility(View.GONE);
txtSellout.setVisibility(View.VISIBLE);
}
private void setRuleState(SkuRule skuRule, Integer ruleState) { private void setRuleState(SkuRule skuRule, Integer ruleState) {
if (goods == null || CollectionUtils.isEmpty(goods.getSpecs())) { if (goods == null || CollectionUtils.isEmpty(goods.getSpecs())) {
return; return;
......
...@@ -14,19 +14,19 @@ import androidx.annotation.NonNull; ...@@ -14,19 +14,19 @@ import androidx.annotation.NonNull;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.adapter.OrderAdapter; import com.ihaoin.hooloo.device.adapter.OrderAdapter;
import com.ihaoin.hooloo.device.component.NetworkHandler; import com.ihaoin.hooloo.device.component.NetworkHandler;
import com.ihaoin.hooloo.device.component.PushMessageReceiver; import com.ihaoin.hooloo.device.component.PushMessageReceiver;
import com.ihaoin.hooloo.device.config.Base; import com.ihaoin.hooloo.device.config.Base;
import com.ihaoin.hooloo.device.data.Datas;
import com.ihaoin.hooloo.device.data.enums.ImageState; import com.ihaoin.hooloo.device.data.enums.ImageState;
import com.ihaoin.hooloo.device.data.enums.OrderState; import com.ihaoin.hooloo.device.data.enums.OrderState;
import com.ihaoin.hooloo.device.data.vo.Order; import com.ihaoin.hooloo.device.data.vo.Order;
import com.ihaoin.hooloo.device.data.vo.OrderPkg; import com.ihaoin.hooloo.device.data.vo.OrderPkg;
import com.ihaoin.hooloo.device.data.vo.RightImage;
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;
import com.ihaoin.hooloo.device.util.StringUtils;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -82,38 +82,42 @@ public class MenuPresentation extends Presentation { ...@@ -82,38 +82,42 @@ public class MenuPresentation extends Presentation {
gridCompleted.setAdapter(completedAdapter); gridCompleted.setAdapter(completedAdapter);
} }
private String getImage(Integer state) { private String getRightImage(String state) {
if (CollectionUtils.isEmpty(Datas.rightImages)) { if (HLApplication.getMainData() == null || HLApplication.getMainData().getImages() == null) {
return null; return null;
} }
for (RightImage image : Datas.rightImages) { if (CollectionUtils.isEmpty(HLApplication.getMainData().getImages().getRight())) {
if (image.getState().equals(state)) { return null;
return image.getUrl();
}
} }
return null; return HLApplication.getMainData().getImages().getRight().get(state);
} }
private void showImages() { private void showImages() {
if (!CollectionUtils.isEmpty(Datas.leftImages)) { if (HLApplication.getMainData() == null || HLApplication.getMainData().getImages() == null) {
Glide.with(getContext()).load(Datas.leftImages.get(0)).into(imgLeft); return;
}
if (!StringUtils.isEmpty(HLApplication.getMainData().getImages().getLeft())) {
Glide.with(getContext()).load(HLApplication.getMainData().getImages().getLeft()).into(imgLeft);
} }
if (Datas.SHOP_STATE.equals(0)) { if (HLApplication.getMainData().getShopState().equals(0)) {
Glide.with(getContext()).load(getImage(ImageState.CLOSED.getCode())).into(imgRight); Glide.with(getContext()).load(getRightImage(ImageState.CLOSED.getCode())).into(imgRight);
} else if (!CollectionUtils.isEmpty(cookingOrders)) { } else if (!CollectionUtils.isEmpty(cookingOrders)) {
Glide.with(getContext()).load(getImage(ImageState.COOKING.getCode())).into(imgRight); Glide.with(getContext()).load(getRightImage(ImageState.COOKING.getCode())).into(imgRight);
} else if (!CollectionUtils.isEmpty(completedOrders)) { } else if (!CollectionUtils.isEmpty(completedOrders)) {
Glide.with(getContext()).load(getImage(ImageState.COMPLETED.getCode())).into(imgRight); Glide.with(getContext()).load(getRightImage(ImageState.COMPLETED.getCode())).into(imgRight);
} else { } else {
Glide.with(getContext()).load(getImage(ImageState.NOT_COMPLETED.getCode())).into(imgRight); Glide.with(getContext()).load(getRightImage(ImageState.NOT_COMPLETED.getCode())).into(imgRight);
} }
} }
public void mainDataChanged() {
showImages();
}
private void loadDatas() { private void loadDatas() {
loadOrdersHandler = new LoadOrdersHandler(getContext()); loadOrdersHandler = new LoadOrdersHandler(getContext());
String requestParams = ""; HttpUtil.getOrders(loadOrdersHandler);
HttpUtil.getOrders(requestParams, loadOrdersHandler);
} }
private void setDatas(String json) { private void setDatas(String json) {
...@@ -132,10 +136,10 @@ public class MenuPresentation extends Presentation { ...@@ -132,10 +136,10 @@ public class MenuPresentation extends Presentation {
completedAdapter.notifyDataSetChanged(); completedAdapter.notifyDataSetChanged();
showImages(); showImages();
regsiterOrderChangeListener(); regsitOrderChangeListener();
} }
private void regsiterOrderChangeListener() { private void regsitOrderChangeListener() {
orderStateChangeHandler = new OrderStateChangeHandler(); orderStateChangeHandler = new OrderStateChangeHandler();
PushMessageReceiver.subscribe(Base.NOTIFY_ACTION_ORDER_STATE_CHANGED, orderStateChangeHandler); PushMessageReceiver.subscribe(Base.NOTIFY_ACTION_ORDER_STATE_CHANGED, orderStateChangeHandler);
} }
......
...@@ -6,13 +6,14 @@ import android.content.pm.PackageInfo; ...@@ -6,13 +6,14 @@ import android.content.pm.PackageInfo;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.ToggleButton; import android.widget.ToggleButton;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.config.AppConfig; import com.ihaoin.hooloo.device.config.AppConfig;
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;
public class SettingsActivity extends Activity { public class SettingsActivity extends Activity {
...@@ -51,19 +52,18 @@ public class SettingsActivity extends Activity { ...@@ -51,19 +52,18 @@ public class SettingsActivity extends Activity {
butnClose.setOnClickListener(v -> finish()); butnClose.setOnClickListener(v -> finish());
layoutScreen.setOnClickListener(v -> showEditScreen()); layoutScreen.setOnClickListener(v -> showEditScreen());
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("修改点单屏编码");
EditText editText = new EditText(getApplicationContext()); String[] items = new String[]{"A", "B"};
editText.setText(SharedPreferencesUtils.getScreenNo(SettingsActivity.this)); builder.setSingleChoiceItems(items, StringUtils.indexOf(items, SharedPreferencesUtils.getScreenNo(SettingsActivity.this)), (dialog, which) -> {
builder.setView(editText); SharedPreferencesUtils.setScreenNo(SettingsActivity.this, items[which]);
builder.setPositiveButton("确定", (dialog, which) -> {
SharedPreferencesUtils.setScreenNo(SettingsActivity.this, editText.getText().toString());
txtScreenNo.setText(SharedPreferencesUtils.getScreenNo(SettingsActivity.this)); txtScreenNo.setText(SharedPreferencesUtils.getScreenNo(SettingsActivity.this));
dialog.dismiss();
}); });
builder.setNegativeButton("取消", null);
builder.create().show(); builder.create().show();
} }
......
...@@ -10,8 +10,9 @@ import android.webkit.WebViewClient; ...@@ -10,8 +10,9 @@ import android.webkit.WebViewClient;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.data.Datas; import com.ihaoin.hooloo.device.util.StringUtils;
public class TipsDialog extends Dialog { public class TipsDialog extends Dialog {
private View butnClose; private View butnClose;
...@@ -25,6 +26,10 @@ public class TipsDialog extends Dialog { ...@@ -25,6 +26,10 @@ public class TipsDialog extends Dialog {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
this.setContentView(R.layout.view_tips); this.setContentView(R.layout.view_tips);
if (HLApplication.getMainData() == null || StringUtils.isEmpty(HLApplication.getMainData().getTips())) {
dismiss();
return;
}
initViews(); initViews();
} }
...@@ -38,7 +43,7 @@ public class TipsDialog extends Dialog { ...@@ -38,7 +43,7 @@ public class TipsDialog extends Dialog {
return false; return false;
} }
}); });
webView.loadUrl(Datas.tips); webView.loadUrl(HLApplication.getMainData().getTips());
butnClose.setOnClickListener(x -> dismiss()); butnClose.setOnClickListener(x -> dismiss());
} }
} }
package com.ihaoin.hooloo.device.view; package com.ihaoin.hooloo.device.view;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -12,12 +14,14 @@ import android.widget.RelativeLayout; ...@@ -12,12 +14,14 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.adapter.TrolleyAdapter; import com.ihaoin.hooloo.device.adapter.TrolleyAdapter;
import com.ihaoin.hooloo.device.data.Datas; import com.ihaoin.hooloo.device.data.TrolleyGoods;
import com.ihaoin.hooloo.device.data.vo.Goods; import com.ihaoin.hooloo.device.data.vo.Goods;
import com.ihaoin.hooloo.device.data.vo.Sku; import com.ihaoin.hooloo.device.data.vo.Sku;
import com.ihaoin.hooloo.device.data.TrolleyGoods;
import com.ihaoin.hooloo.device.util.RandomUtils; import com.ihaoin.hooloo.device.util.RandomUtils;
import com.ihaoin.hooloo.device.util.Utils; import com.ihaoin.hooloo.device.util.Utils;
...@@ -67,11 +71,15 @@ public class TrolleyView extends RelativeLayout { ...@@ -67,11 +71,15 @@ public class TrolleyView extends RelativeLayout {
} }
public void addGoods(Goods goods, Sku sku, Integer count) { public void addGoods(Goods goods, Sku sku, Integer count) {
if (getCount() >= Datas.COUNT_OF_ORDER) { if (!checkSkuState(sku.getSkuId())) {
Toast.makeText(this.getContext(), getContext().getString(R.string.count_limit, Datas.COUNT_OF_ORDER.toString()), Toast.LENGTH_SHORT).show(); Toast.makeText(this.getContext(), R.string.error_sku_state, Toast.LENGTH_SHORT).show();
return; return;
} }
Optional<TrolleyGoods> optional = this.trolleyGoods.stream().filter(x -> x.getGoodId().equals(goods.getGoodId()) && x.getSkuId().equals(sku.getSkuId())).findAny(); if (getCount() >= HLApplication.getMainData().getCountOfOrder()) {
Toast.makeText(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getMainData().getCountOfOrder().toString()), Toast.LENGTH_SHORT).show();
return;
}
Optional<TrolleyGoods> optional = this.trolleyGoods.stream().filter(x -> x.getGoodId().equals(goods.getGoodsId()) && x.getSkuId().equals(sku.getSkuId())).findAny();
// 判断是否在购物车里存在同样规格的产品 // 判断是否在购物车里存在同样规格的产品
if (optional.isPresent()) { if (optional.isPresent()) {
TrolleyGoods g = optional.get(); TrolleyGoods g = optional.get();
...@@ -80,7 +88,7 @@ public class TrolleyView extends RelativeLayout { ...@@ -80,7 +88,7 @@ public class TrolleyView extends RelativeLayout {
TrolleyGoods g = new TrolleyGoods(); TrolleyGoods g = new TrolleyGoods();
g.setId(RandomUtils.nextLong(trolleyGoods.stream().map(TrolleyGoods::getId).collect(Collectors.toList()))); g.setId(RandomUtils.nextLong(trolleyGoods.stream().map(TrolleyGoods::getId).collect(Collectors.toList())));
g.setChecked(true); g.setChecked(true);
g.setGoodId(goods.getGoodId()); g.setGoodId(goods.getGoodsId());
g.setName(goods.getName()); g.setName(goods.getName());
g.setDesc(goods.getDesc()); g.setDesc(goods.getDesc());
g.setPics(goods.getPics()); g.setPics(goods.getPics());
...@@ -99,15 +107,23 @@ public class TrolleyView extends RelativeLayout { ...@@ -99,15 +107,23 @@ public class TrolleyView extends RelativeLayout {
} }
public void addGoods(Integer position) { public void addGoods(Integer position) {
if (getCount() >= Datas.COUNT_OF_ORDER) { if (getCount() >= HLApplication.getMainData().getCountOfOrder()) {
Toast.makeText(this.getContext(), getContext().getString(R.string.count_limit, Datas.COUNT_OF_ORDER.toString()), Toast.LENGTH_SHORT).show(); Toast.makeText(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getMainData().getCountOfOrder().toString()), Toast.LENGTH_SHORT).show();
return; return;
} }
TrolleyGoods goods = this.trolleyGoods.get(position); TrolleyGoods goods = this.trolleyGoods.get(position);
if (!checkSkuState(goods.getSkuId())) {
Toast.makeText(this.getContext(), R.string.error_sku_state, Toast.LENGTH_SHORT).show();
return;
}
goods.setCount(goods.getCount() + 1); goods.setCount(goods.getCount() + 1);
this.goodsChanged(); this.goodsChanged();
} }
private boolean checkSkuState(Integer skuId) {
return true;
}
public void subtractGoods(Integer position) { public void subtractGoods(Integer position) {
TrolleyGoods goods = this.trolleyGoods.get(position); TrolleyGoods goods = this.trolleyGoods.get(position);
if (goods.getCount() <= 1) { if (goods.getCount() <= 1) {
...@@ -127,8 +143,8 @@ public class TrolleyView extends RelativeLayout { ...@@ -127,8 +143,8 @@ public class TrolleyView extends RelativeLayout {
} }
public Boolean checkGoodsCount() { public Boolean checkGoodsCount() {
if (getCount() > Datas.COUNT_OF_ORDER) { if (getCount() > HLApplication.getMainData().getCountOfOrder()) {
Toast.makeText(this.getContext(), getContext().getString(R.string.count_limit, Datas.COUNT_OF_ORDER.toString()), Toast.LENGTH_SHORT).show(); Toast.makeText(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getMainData().getCountOfOrder().toString()), Toast.LENGTH_SHORT).show();
return false; return false;
} }
return true; return true;
...@@ -254,6 +270,13 @@ public class TrolleyView extends RelativeLayout { ...@@ -254,6 +270,13 @@ public class TrolleyView extends RelativeLayout {
Utils.showConfirmOrder(getContext(), trolleyGoods); Utils.showConfirmOrder(getContext(), trolleyGoods);
} }
class CheckSkuStateHandler extends Handler {
@Override
public void handleMessage(@NonNull Message msg) {
}
}
public TrolleyView(Context context) { public TrolleyView(Context context) {
super(context); super(context);
init(); init();
......
...@@ -42,4 +42,5 @@ ...@@ -42,4 +42,5 @@
android:id="@+id/view_trolley" android:id="@+id/view_trolley"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
android:id="@+id/img_left" android:id="@+id/img_left"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1.3"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />
<LinearLayout <LinearLayout
......
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
android:textSize="12sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/layout_operate"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
...@@ -125,8 +126,18 @@ ...@@ -125,8 +126,18 @@
android:layout_height="20dp" android:layout_height="20dp"
android:background="@drawable/ic_add" /> android:background="@drawable/ic_add" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/txt_sellout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="已售罄"
android:textColor="@color/textRed"
android:textSize="12sp"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/layout_butns"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
......
...@@ -8,4 +8,6 @@ ...@@ -8,4 +8,6 @@
<string name="error_choose_spec">请选择规格</string> <string name="error_choose_spec">请选择规格</string>
<string name="error_choose_goods">请选择商品</string> <string name="error_choose_goods">请选择商品</string>
<string name="error_price">商品金额错误</string> <string name="error_price">商品金额错误</string>
<string name="error_sku_state">本商品已售罄或已经下架</string>
<string name="error_load_main_data">获取数据失败</string>
</resources> </resources>
package com.chad.library.adapter.base.animation package com.chad.library.adapter.base.animation
import android.animation.Animator import android.animation.Animator
......
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