Commit de720882 by wjg

优化字体

parent 163e8e9e
package com.ihaoin.hooloo.device; package com.ihaoin.hooloo.device;
import android.app.Application; import android.app.Application;
import android.graphics.Typeface;
import android.util.Log; import android.util.Log;
import com.ihaoin.hooloo.device.config.AppConfig; import com.ihaoin.hooloo.device.config.AppConfig;
...@@ -11,6 +12,7 @@ import com.ihaoin.hooloo.device.util.SharedPreferencesUtils; ...@@ -11,6 +12,7 @@ import com.ihaoin.hooloo.device.util.SharedPreferencesUtils;
import com.ihaoin.hooloo.device.util.StringUtils; import com.ihaoin.hooloo.device.util.StringUtils;
import com.umeng.commonsdk.UMConfigure; import com.umeng.commonsdk.UMConfigure;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -21,6 +23,7 @@ public class HLApplication extends Application { ...@@ -21,6 +23,7 @@ public class HLApplication extends Application {
public static HLApplication SELF = null; public static HLApplication SELF = null;
private static MainData mainData = new MainData(); private static MainData mainData = new MainData();
private static List<TrolleyGoods> TROLLEY_GOODS = new ArrayList<>(); private static List<TrolleyGoods> TROLLEY_GOODS = new ArrayList<>();
public static MainData getMainData() { public static MainData getMainData() {
return mainData; return mainData;
} }
...@@ -40,6 +43,15 @@ public class HLApplication extends Application { ...@@ -40,6 +43,15 @@ public class HLApplication extends Application {
UMConfigure.preInit(this, AppConfig.UMENG_APPKEY, AppConfig.UMENG_CHANNEL); UMConfigure.preInit(this, AppConfig.UMENG_APPKEY, AppConfig.UMENG_CHANNEL);
UMConfigure.init(this, AppConfig.UMENG_APPKEY, AppConfig.UMENG_CHANNEL, 0, null); UMConfigure.init(this, AppConfig.UMENG_APPKEY, AppConfig.UMENG_CHANNEL, 0, null);
try {
Typeface typefaceMonospace = Typeface.createFromAsset(getAssets(), "fonts/pingfang_jianti_regular.ttf");
Field monospace = Typeface.class.getDeclaredField("MONOSPACE");
monospace.setAccessible(true);
monospace.set(null, typefaceMonospace);
} catch (Exception e) {
e.printStackTrace();
}
AppConfig.MACHINE_CODE = SharedPreferencesUtils.getMachineCode(this); AppConfig.MACHINE_CODE = SharedPreferencesUtils.getMachineCode(this);
JPushInterface.setDebugMode(true); JPushInterface.setDebugMode(true);
......
...@@ -2,6 +2,7 @@ package com.ihaoin.hooloo.device.adapter; ...@@ -2,6 +2,7 @@ package com.ihaoin.hooloo.device.adapter;
import android.content.Context; import android.content.Context;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Typeface;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -9,8 +10,6 @@ import android.widget.ImageView; ...@@ -9,8 +10,6 @@ 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.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
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;
...@@ -54,6 +53,10 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -54,6 +53,10 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
LinearLayout layoutTag = helper.getView(R.id.layout_tags); LinearLayout layoutTag = helper.getView(R.id.layout_tags);
layoutTag.removeAllViews(); layoutTag.removeAllViews();
// TODO delete
goods.setTags(Arrays.asList("一二", "一二三四", "一二三四五六七"));
if (CollectionUtils.isEmpty(goods.getTags())) { if (CollectionUtils.isEmpty(goods.getTags())) {
helper.setVisible(R.id.layout_tags, false); helper.setVisible(R.id.layout_tags, false);
View tagView = LayoutInflater.from(mContext).inflate(R.layout.item_tag, null); View tagView = LayoutInflater.from(mContext).inflate(R.layout.item_tag, null);
...@@ -68,12 +71,13 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -68,12 +71,13 @@ 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);
if (goods.getPics() == null) { if (goods.getPics() == null) {
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);
} }
Sku sku = Utils.getDefaultSku(goods.getSkus()); Sku sku = Utils.getDefaultSku(goods.getSkus());
...@@ -127,6 +131,8 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -127,6 +131,8 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
helper.setGone(R.id.img_recommend, false); helper.setGone(R.id.img_recommend, false);
} }
TextView icoDiscount = helper.getView(R.id.ico_discount);
TextView txtDiscount = helper.getView(R.id.txt_discount);
TextView icoPrice = helper.getView(R.id.ico_price); TextView icoPrice = helper.getView(R.id.ico_price);
TextView txtPrice = helper.getView(R.id.txt_price); TextView txtPrice = helper.getView(R.id.txt_price);
icoPrice.setPaintFlags(icoPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); icoPrice.setPaintFlags(icoPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
...@@ -143,6 +149,15 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -143,6 +149,15 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
} else { } else {
layoutItem.setPadding(0, verPadding, 0, verPadding); layoutItem.setPadding(0, verPadding, 0, verPadding);
} }
Typeface tfAmount = Utils.getAmountFont(mContext);
icoDiscount.setTypeface(tfAmount);
txtDiscount.setTypeface(tfAmount);
icoPrice.setTypeface(tfAmount);
txtPrice.setTypeface(tfAmount);
icoDiscount.getPaint().setFakeBoldText(true);
txtDiscount.getPaint().setFakeBoldText(true);
} }
private boolean trolleyState = false; private boolean trolleyState = false;
......
...@@ -4,8 +4,6 @@ import android.content.Context; ...@@ -4,8 +4,6 @@ import android.content.Context;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
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;
...@@ -31,9 +29,9 @@ public class RecommendAdapter extends BaseQuickAdapter<ScrollBean, BaseViewHolde ...@@ -31,9 +29,9 @@ public class RecommendAdapter extends BaseQuickAdapter<ScrollBean, BaseViewHolde
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);
Utils.getGlide(mContext).load(recommend.getPic()).apply(options).into(imgRecommend); Utils.getGlide(mContext).load(recommend.getPic()).into(imgRecommend);
View layoutItem = helper.getView(R.id.layout_item); View layoutItem = helper.getView(R.id.layout_item);
layoutItem.setOnClickListener(v -> { layoutItem.setOnClickListener(v -> {
......
...@@ -2,6 +2,7 @@ package com.ihaoin.hooloo.device.adapter; ...@@ -2,6 +2,7 @@ package com.ihaoin.hooloo.device.adapter;
import android.content.Context; import android.content.Context;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Typeface;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -45,6 +46,7 @@ public class TrolleyAdapter extends BaseAdapter { ...@@ -45,6 +46,7 @@ public class TrolleyAdapter extends BaseAdapter {
TextView txtOptions = convertView.findViewById(R.id.txt_options); TextView txtOptions = convertView.findViewById(R.id.txt_options);
TextView icoPrice = convertView.findViewById(R.id.ico_price); TextView icoPrice = convertView.findViewById(R.id.ico_price);
TextView txtPrice = convertView.findViewById(R.id.txt_price); TextView txtPrice = convertView.findViewById(R.id.txt_price);
TextView icoDiscount = convertView.findViewById(R.id.ico_discount);
TextView txtDiscount = convertView.findViewById(R.id.txt_discount); TextView txtDiscount = convertView.findViewById(R.id.txt_discount);
View butnSubtract = convertView.findViewById(R.id.butn_subtract); View butnSubtract = convertView.findViewById(R.id.butn_subtract);
TextView txtCount = convertView.findViewById(R.id.txt_count); TextView txtCount = convertView.findViewById(R.id.txt_count);
...@@ -93,6 +95,19 @@ public class TrolleyAdapter extends BaseAdapter { ...@@ -93,6 +95,19 @@ public class TrolleyAdapter extends BaseAdapter {
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));
Typeface tfAmount = Utils.getAmountFont(mContext);
icoDiscount.setTypeface(tfAmount);
txtDiscount.setTypeface(tfAmount);
icoPrice.setTypeface(tfAmount);
txtPrice.setTypeface(tfAmount);
icoDiscount.getPaint().setFakeBoldText(true);
txtDiscount.getPaint().setFakeBoldText(true);
Typeface tfHalf = Utils.getHalfFont(mContext);
txtCount.setTypeface(tfHalf);
txtCount.getPaint().setFakeBoldText(true);
return convertView; return convertView;
} }
......
...@@ -130,7 +130,8 @@ public class HttpUtil { ...@@ -130,7 +130,8 @@ public class HttpUtil {
public static String getMacAddress() { public static String getMacAddress() {
try { try {
if (AppConfig.DEBUG) {
if (AppConfig.DEBUG) { // TODO delete
return "SN0091290001"; return "SN0091290001";
} }
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces()); List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
......
...@@ -11,4 +11,15 @@ public class JsonUtils { ...@@ -11,4 +11,15 @@ public class JsonUtils {
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper; return objectMapper;
} }
public static <T> T readValue(Object obj, Class<T> cls) {
try {
if (obj == null) {
return null;
}
return JsonUtils.getMapper().readValue(obj.toString(), cls);
} catch (Exception e) {
return null;
}
}
} }
...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint; ...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Typeface;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -201,4 +202,14 @@ public class Utils { ...@@ -201,4 +202,14 @@ public class Utils {
} }
return url + "?x-oss-process=image/resize,m_fill,h_100,w_100"; return url + "?x-oss-process=image/resize,m_fill,h_100,w_100";
} }
public static Typeface getAmountFont(Context context) {
return Typeface.createFromAsset(context.getAssets(), "fonts/futura_regular.ttf");
}
public static Typeface getHalfFont(Context context) {
return Typeface.createFromAsset(context.getAssets(), "fonts/vnarial.ttf");
}
} }
...@@ -273,7 +273,7 @@ public class ConfirmOrderDialog extends Dialog { ...@@ -273,7 +273,7 @@ public class ConfirmOrderDialog extends Dialog {
} }
String id = obj.toString(); String id = obj.toString();
id = AppConfig.MACHINE_CODE; // id = AppConfig.MACHINE_CODE;
Bitmap bitmap = genQRCode(id); Bitmap bitmap = genQRCode(id);
imgQRCode.setImageBitmap(bitmap); imgQRCode.setImageBitmap(bitmap);
startExpireThread(); startExpireThread();
......
...@@ -4,6 +4,7 @@ import android.app.Dialog; ...@@ -4,6 +4,7 @@ import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.Paint; import android.graphics.Paint;
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;
...@@ -19,6 +20,7 @@ import android.widget.TextView; ...@@ -19,6 +20,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.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;
import com.ihaoin.hooloo.device.component.AutoWrapLayout; import com.ihaoin.hooloo.device.component.AutoWrapLayout;
...@@ -32,6 +34,7 @@ import com.ihaoin.hooloo.device.data.vo.Sku; ...@@ -32,6 +34,7 @@ import com.ihaoin.hooloo.device.data.vo.Sku;
import com.ihaoin.hooloo.device.data.vo.SkuRule; import com.ihaoin.hooloo.device.data.vo.SkuRule;
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.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;
...@@ -54,8 +57,9 @@ public class GoodsDetailDialog extends Dialog { ...@@ -54,8 +57,9 @@ public class GoodsDetailDialog extends Dialog {
private TextView txtName; private TextView txtName;
private LinearLayout layoutSpecs; private LinearLayout layoutSpecs;
private LinearLayout layoutImages; private LinearLayout layoutImages;
private TextView icoPrice;
private TextView txtPrice; private TextView txtPrice;
private TextView icoPirce; private TextView icoDiscount;
private TextView txtDiscount; private TextView txtDiscount;
private Button butnSubtract; private Button butnSubtract;
private TextView txtCount; private TextView txtCount;
...@@ -88,8 +92,9 @@ public class GoodsDetailDialog extends Dialog { ...@@ -88,8 +92,9 @@ public class GoodsDetailDialog extends Dialog {
txtName = findViewById(R.id.txt_name); txtName = findViewById(R.id.txt_name);
layoutSpecs = findViewById(R.id.layout_specs); layoutSpecs = findViewById(R.id.layout_specs);
layoutImages = findViewById(R.id.layout_images); layoutImages = findViewById(R.id.layout_images);
icoPirce = findViewById(R.id.ico_price); icoPrice = findViewById(R.id.ico_price);
txtPrice = findViewById(R.id.txt_price); txtPrice = findViewById(R.id.txt_price);
icoDiscount = findViewById(R.id.ico_discount);
txtDiscount = findViewById(R.id.txt_discount); txtDiscount = findViewById(R.id.txt_discount);
butnSubtract = findViewById(R.id.butn_subtract); butnSubtract = findViewById(R.id.butn_subtract);
txtCount = findViewById(R.id.txt_count); txtCount = findViewById(R.id.txt_count);
...@@ -97,6 +102,19 @@ public class GoodsDetailDialog extends Dialog { ...@@ -97,6 +102,19 @@ public class GoodsDetailDialog extends Dialog {
butnBuy = findViewById(R.id.butn_buy); butnBuy = findViewById(R.id.butn_buy);
butnTrolley = findViewById(R.id.butn_trolley); butnTrolley = findViewById(R.id.butn_trolley);
Typeface tfAmount = Utils.getAmountFont(getContext());
icoDiscount.setTypeface(tfAmount);
txtDiscount.setTypeface(tfAmount);
icoPrice.setTypeface(tfAmount);
txtPrice.setTypeface(tfAmount);
icoDiscount.getPaint().setFakeBoldText(true);
txtDiscount.getPaint().setFakeBoldText(true);
Typeface tfHalf = Utils.getHalfFont(getContext());
txtCount.setTypeface(tfHalf);
txtCount.getPaint().setFakeBoldText(true);
butnClose.setOnClickListener(x -> dismiss()); butnClose.setOnClickListener(x -> dismiss());
introViews = new ArrayList<>(); introViews = new ArrayList<>();
...@@ -158,7 +176,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -158,7 +176,7 @@ public class GoodsDetailDialog extends Dialog {
butnSubtract.setOnClickListener(v -> subtractCount()); butnSubtract.setOnClickListener(v -> subtractCount());
butnAdd.setOnClickListener(v -> addCount()); butnAdd.setOnClickListener(v -> addCount());
icoPirce.setPaintFlags(icoPirce.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); icoPrice.setPaintFlags(icoPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtPrice.setPaintFlags(txtPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); txtPrice.setPaintFlags(txtPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
butnBuy.setOnClickListener(v -> prepareBuyNow()); butnBuy.setOnClickListener(v -> prepareBuyNow());
...@@ -270,18 +288,49 @@ public class GoodsDetailDialog extends Dialog { ...@@ -270,18 +288,49 @@ public class GoodsDetailDialog extends Dialog {
@Override @Override
public void handleMessage(@NonNull Message msg) { public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg); super.handleMessage(msg);
if (msg.what != 1) { Object obj = msg.obj;
if (msg.what != 1 || obj == null) {
Utils.showToast(getContext(), R.string.error_check_sku_wrong);
return;
}
JsonNode rsp = JsonUtils.readValue(obj, JsonNode.class);
Goods rspGoods = JsonUtils.readValue(rsp.get("goods").toString(), Goods.class);
if (rspGoods == null) {
Utils.showToast(getContext(), R.string.error_check_sku); Utils.showToast(getContext(), R.string.error_check_sku);
showSelloutViews();
return; return;
} }
// for (int i = 0; i < rspGoods.getSkus().size(); i++) {
// Sku s = rspGoods.getSkus().get(i);
// if (s.getSkuId().equals(2111) || s.getSkuId().equals(2112)) {
// continue;
// }
// s.setState(2);
// }
// if (true) {
if (!SkuState.SELLIN.getCode().equals(rsp.get("state").asInt())) {
Utils.showToast(getContext(), R.string.error_check_sku);
setGoods(rspGoods);
return;
}
if (this.type == 1) { if (this.type == 1) {
buyNow(goods, sku, count); buyNow(goods, sku, count);
} else { } else {
addTrolley(goods, sku, count); addTrolley(goods, sku, count);
} }
setGoods(rspGoods);
} }
} }
private void setGoods(Goods rspGoods) {
this.mGoods = rspGoods;
processSpecRules();
buildSpecs();
}
public void prepareBuyNow() { public void prepareBuyNow() {
if (mSku == null) { if (mSku == null) {
Utils.showToast(getContext(), R.string.not_found_goods); Utils.showToast(getContext(), R.string.not_found_goods);
...@@ -296,7 +345,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -296,7 +345,7 @@ public class GoodsDetailDialog extends Dialog {
Utils.showToast(getContext(), R.string.not_found_goods); Utils.showToast(getContext(), R.string.not_found_goods);
return; return;
} }
if (mCount + HLApplication.getGoodsCount() >= HLApplication.getCountOfOrder()) { if (mCount + HLApplication.getGoodsCount() > HLApplication.getCountOfOrder()) {
Utils.showToast(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getCountOfOrder().toString())); Utils.showToast(this.getContext(), getContext().getString(R.string.count_limit, HLApplication.getCountOfOrder().toString()));
return; return;
} }
...@@ -332,6 +381,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -332,6 +381,7 @@ public class GoodsDetailDialog extends Dialog {
} }
private void buildSpecs() { private void buildSpecs() {
layoutSpecs.removeAllViews();
if (CollectionUtils.isEmpty(mGoods.getSpecs())) { if (CollectionUtils.isEmpty(mGoods.getSpecs())) {
return; return;
} }
......
...@@ -227,14 +227,15 @@ public class LauncherActivity extends Activity { ...@@ -227,14 +227,15 @@ public class LauncherActivity extends Activity {
int nextPosition = firstPosition + 1; // 当前显示的下一个索引 int nextPosition = firstPosition + 1; // 当前显示的下一个索引
if (nextPosition < scrollGoods.size()) { // 已经是最后一个item if (nextPosition < scrollGoods.size()) { // 已经是最后一个item
if (scrollGoods.get(nextPosition).isHeader) { // 下一个是否是标题 if (scrollGoods.get(nextPosition).isHeader) { // 下一个是否是标题
int paddingTop = Utils.getDimens(mContext, R.dimen.goods_padding_top);
View nextView = goodsLayoutManager.findViewByPosition(nextPosition); // 下一个view View nextView = goodsLayoutManager.findViewByPosition(nextPosition); // 下一个view
int[] location = new int[2]; int[] location = new int[2];
nextView.getLocationInWindow(location); nextView.getLocationInWindow(location);
int topMargin = location[1]; int topMargin = location[1] -paddingTop;
int height = nextView.getHeight(); int height = nextView.getHeight();
// Log.d(AppConfig.TAG, String.format("c:%s, n:%s, 0:%s, 1:%s", firstPosition, nextPosition, rect[0], rect[1])); // Log.d(AppConfig.TAG, String.format("c:%s, n:%s, 0:%s, 1:%s", firstPosition, nextPosition, rect[0], rect[1]));
if (topMargin < height) { if (topMargin < height) {
lp.setMargins(0, -(height - topMargin), 0, 0); lp.setMargins(0, -(height - topMargin ), 0, 0);
} }
} }
} }
......
package com.ihaoin.hooloo.device.view; package com.ihaoin.hooloo.device.view;
import android.content.Context; import android.content.Context;
import android.graphics.Typeface;
import android.os.Message; import android.os.Message;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -14,15 +15,18 @@ import android.widget.TextView; ...@@ -14,15 +15,18 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
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;
import com.ihaoin.hooloo.device.adapter.TrolleyAdapter; import com.ihaoin.hooloo.device.adapter.TrolleyAdapter;
import com.ihaoin.hooloo.device.component.NetworkHandler; import com.ihaoin.hooloo.device.component.NetworkHandler;
import com.ihaoin.hooloo.device.config.Base; import com.ihaoin.hooloo.device.config.Base;
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.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.network.HttpUtil; import com.ihaoin.hooloo.device.network.HttpUtil;
import com.ihaoin.hooloo.device.util.JsonUtils;
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;
...@@ -66,6 +70,12 @@ public class TrolleyView extends RelativeLayout { ...@@ -66,6 +70,12 @@ public class TrolleyView extends RelativeLayout {
viewBackground.setOnClickListener(v -> closeTrolley()); viewBackground.setOnClickListener(v -> closeTrolley());
butnPay.setOnClickListener(v -> showPayDialog()); butnPay.setOnClickListener(v -> showPayDialog());
Typeface tfHalf = Utils.getHalfFont(getContext());
txtCount.setTypeface(tfHalf);
txtTotal.setTypeface(tfHalf);
txtCount.getPaint().setFakeBoldText(true);
txtTotal.getPaint().setFakeBoldText(true);
} }
public void prepareAddGoods(Goods goods, Sku sku, Integer count) { public void prepareAddGoods(Goods goods, Sku sku, Integer count) {
...@@ -88,7 +98,14 @@ public class TrolleyView extends RelativeLayout { ...@@ -88,7 +98,14 @@ public class TrolleyView extends RelativeLayout {
@Override @Override
public void handleMessage(@NonNull Message msg) { public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg); super.handleMessage(msg);
if (msg.what != 1) { Object obj = msg.obj;
if (msg.what != 1 || obj == null) {
Utils.showToast(getContext(), R.string.error_check_sku_wrong);
return;
}
JsonNode rsp = JsonUtils.readValue(obj, JsonNode.class);
if (!SkuState.SELLIN.getCode().equals(rsp.get("state").asInt())) {
Utils.showToast(getContext(), R.string.error_check_sku); Utils.showToast(getContext(), R.string.error_check_sku);
return; return;
} }
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
<FrameLayout <FrameLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.30833"> android:layout_weight="0.30833"
android:paddingTop="@dimen/goods_padding_top">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rec_right" android:id="@+id/rec_right"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<dimen name="recommend_desc_margin_top">18px</dimen> <dimen name="recommend_desc_margin_top">18px</dimen>
<dimen name="recommend_desc_margin_left">68px</dimen> <dimen name="recommend_desc_margin_left">68px</dimen>
<dimen name="goods_padding_top">30px</dimen>
<dimen name="goods_padding_ver">30px</dimen> <dimen name="goods_padding_ver">30px</dimen>
<dimen name="goods_padding_right">38px</dimen> <dimen name="goods_padding_right">38px</dimen>
<dimen name="goods_last_padding_bottom">300px</dimen> <dimen name="goods_last_padding_bottom">300px</dimen>
...@@ -23,9 +24,9 @@ ...@@ -23,9 +24,9 @@
<dimen name="goods_recommend_margin">30px</dimen> <dimen name="goods_recommend_margin">30px</dimen>
<dimen name="goods_category_margin_top">13px</dimen> <dimen name="goods_category_margin_top">13px</dimen>
<dimen name="goods_tag_margin_top">13px</dimen> <dimen name="goods_tag_margin_top">13px</dimen>
<dimen name="goods_tag_padding_ver">3px</dimen> <dimen name="goods_tag_padding_ver">0px</dimen>
<dimen name="goods_tag_padding_hor">9px</dimen> <dimen name="goods_tag_padding_hor">5px</dimen>
<dimen name="goods_tag_margin_right">16px</dimen> <dimen name="goods_tag_margin_right">15px</dimen>
<dimen name="goods_desc_margin_top">26px</dimen> <dimen name="goods_desc_margin_top">26px</dimen>
<dimen name="goods_butns_margin_top">25px</dimen> <dimen name="goods_butns_margin_top">25px</dimen>
<dimen name="goods_price_margin">5px</dimen> <dimen name="goods_price_margin">5px</dimen>
...@@ -54,7 +55,7 @@ ...@@ -54,7 +55,7 @@
<dimen name="goods_detail_rule_width">148px</dimen> <dimen name="goods_detail_rule_width">148px</dimen>
<dimen name="goods_detail_rule_margin_top">16px</dimen> <dimen name="goods_detail_rule_margin_top">16px</dimen>
<dimen name="goods_detail_rule_margin_right">28px</dimen> <dimen name="goods_detail_rule_margin_right">28px</dimen>
<dimen name="goods_detail_rule_padding_hor">60px</dimen> <dimen name="goods_detail_rule_padding_hor">30px</dimen>
<dimen name="goods_detail_rule_padding_ver">10px</dimen> <dimen name="goods_detail_rule_padding_ver">10px</dimen>
<dimen name="goods_detail_layout_rule_margin_top">17px</dimen> <dimen name="goods_detail_layout_rule_margin_top">17px</dimen>
<dimen name="goods_detail_rec_padding_hor">12px</dimen> <dimen name="goods_detail_rec_padding_hor">12px</dimen>
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<dimen name="recommend_desc_margin_top">30px</dimen> <dimen name="recommend_desc_margin_top">30px</dimen>
<dimen name="recommend_desc_margin_left">68px</dimen> <dimen name="recommend_desc_margin_left">68px</dimen>
<dimen name="goods_padding_top">60px</dimen>
<dimen name="goods_padding_ver">30px</dimen> <dimen name="goods_padding_ver">30px</dimen>
<dimen name="goods_padding_right">38px</dimen> <dimen name="goods_padding_right">38px</dimen>
<dimen name="goods_last_padding_bottom">400px</dimen> <dimen name="goods_last_padding_bottom">400px</dimen>
...@@ -23,8 +24,8 @@ ...@@ -23,8 +24,8 @@
<dimen name="goods_recommend_margin">5dp</dimen> <dimen name="goods_recommend_margin">5dp</dimen>
<dimen name="goods_category_margin_top">10dp</dimen> <dimen name="goods_category_margin_top">10dp</dimen>
<dimen name="goods_tag_margin_top">3dp</dimen> <dimen name="goods_tag_margin_top">3dp</dimen>
<dimen name="goods_tag_padding_ver">3px</dimen> <dimen name="goods_tag_padding_ver">2px</dimen>
<dimen name="goods_tag_padding_hor">9px</dimen> <dimen name="goods_tag_padding_hor">10px</dimen>
<dimen name="goods_tag_margin_right">16px</dimen> <dimen name="goods_tag_margin_right">16px</dimen>
<dimen name="goods_desc_margin_top">26px</dimen> <dimen name="goods_desc_margin_top">26px</dimen>
<dimen name="goods_butns_margin_top">25px</dimen> <dimen name="goods_butns_margin_top">25px</dimen>
......
...@@ -12,5 +12,6 @@ ...@@ -12,5 +12,6 @@
<string name="error_price">商品金额错误</string> <string name="error_price">商品金额错误</string>
<string name="error_sku_state">本商品已售罄或已经下架</string> <string name="error_sku_state">本商品已售罄或已经下架</string>
<string name="error_load_main_data">获取数据失败</string> <string name="error_load_main_data">获取数据失败</string>
<string name="error_check_sku_wrong">商品状态错误</string>
<string name="error_check_sku">商品已售罄</string> <string name="error_check_sku">商品已售罄</string>
</resources> </resources>
<resources> <resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:typeface">monospace</item>
</style> </style>
<style name="button_style" parent="Widget.AppCompat.Button.Borderless"> <style name="button_style" parent="Widget.AppCompat.Button.Borderless">
</style> </style>
......
## 未解决事项 TODO ## 未解决事项 TODO
***** *****
1、设置字体 购物袋总数量,购物袋item数量,商品详情数量
2、设置字体 购物袋总金额
\ 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