Commit 8097f831 by wjg

init

parent daa586fa
...@@ -24,8 +24,6 @@ import com.ihaoin.hooloo.device.util.StringUtils; ...@@ -24,8 +24,6 @@ import com.ihaoin.hooloo.device.util.StringUtils;
import com.ihaoin.hooloo.device.util.Utils; import com.ihaoin.hooloo.device.util.Utils;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.Optional;
public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHolder> { public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHolder> {
private Context mContext; private Context mContext;
...@@ -74,16 +72,16 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -74,16 +72,16 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
Glide.with(mContext).load(goods.getPics().getThumbnail()).apply(options).into(imgThumbnail); Glide.with(mContext).load(goods.getPics().getThumbnail()).apply(options).into(imgThumbnail);
} }
Sku sku = getDefaultSku(goods.getSkus()); Sku sku = Utils.getDefaultSku(goods.getSkus());
if (sku == null) { if (sku == null) {
helper.setText(R.id.txt_price, String.valueOf(goods.getPrice())); helper.setText(R.id.txt_price, Utils.toString(goods.getPrice()));
helper.setText(R.id.txt_discount, String.valueOf(goods.getDiscount())); helper.setText(R.id.txt_discount, Utils.toString(goods.getDiscount()));
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);
} else { } else {
helper.setText(R.id.txt_price, String.valueOf(sku.getPrice())); helper.setText(R.id.txt_price, Utils.toString(sku.getPrice()));
helper.setText(R.id.txt_discount, String.valueOf(sku.getDiscount())); helper.setText(R.id.txt_discount, Utils.toString(sku.getDiscount()));
if (Base.TRUE.equals(sku.getState())) { if (Base.TRUE.equals(sku.getState())) {
helper.setGone(R.id.txt_sellout, false); helper.setGone(R.id.txt_sellout, false);
...@@ -105,10 +103,10 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -105,10 +103,10 @@ 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 icoPrice = helper.getView(R.id.ico_price);
TextView txtDiscount = helper.getView(R.id.txt_discount); TextView txtPrice = helper.getView(R.id.txt_price);
icoDiscount.setPaintFlags(icoDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); icoPrice.setPaintFlags(icoPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtDiscount.setPaintFlags(txtDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); txtPrice.setPaintFlags(txtPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
View layoutItem = helper.getView(R.id.layout_item); View layoutItem = helper.getView(R.id.layout_item);
layoutItem.setOnClickListener(v -> Utils.showGoodsDetail(mContext, goods)); layoutItem.setOnClickListener(v -> Utils.showGoodsDetail(mContext, goods));
...@@ -123,22 +121,6 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo ...@@ -123,22 +121,6 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
} }
} }
/** 获取SKU,优选获取默认的SKU */
private Sku getDefaultSku(List<Sku> skus) {
if (CollectionUtils.isEmpty(skus)) {
return null;
}
Optional<Sku> optional = skus.stream().filter(x -> Base.TRUE.equals(x.getIsDefault()) && Base.TRUE.equals(x.getState())).findAny();
if (optional.isPresent()) {
return optional.get();
}
optional = skus.stream().filter(x -> Base.TRUE.equals(x.getState())).findAny();
if (optional.isPresent()) {
return optional.get();
}
return skus.get(0);
}
private boolean trolleyState = false; private boolean trolleyState = false;
public boolean isTrolleyState() { public boolean isTrolleyState() {
......
...@@ -38,9 +38,9 @@ public class TrolleyAdapter extends BaseAdapter { ...@@ -38,9 +38,9 @@ public class TrolleyAdapter extends BaseAdapter {
ImageView imgThumbnail = convertView.findViewById(R.id.img_thumbnail); ImageView imgThumbnail = convertView.findViewById(R.id.img_thumbnail);
TextView txtName = convertView.findViewById(R.id.txt_name); TextView txtName = convertView.findViewById(R.id.txt_name);
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 txtPrice = convertView.findViewById(R.id.txt_price); TextView txtPrice = convertView.findViewById(R.id.txt_price);
TextView txtDiscount = convertView.findViewById(R.id.txt_discount); TextView txtDiscount = convertView.findViewById(R.id.txt_discount);
TextView icoDiscount = convertView.findViewById(R.id.ico_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);
View butnAdd = convertView.findViewById(R.id.butn_add); View butnAdd = convertView.findViewById(R.id.butn_add);
...@@ -67,11 +67,11 @@ public class TrolleyAdapter extends BaseAdapter { ...@@ -67,11 +67,11 @@ public class TrolleyAdapter extends BaseAdapter {
txtOptions.setVisibility(View.GONE); txtOptions.setVisibility(View.GONE);
} }
txtPrice.setText(goods.getPrice().toString()); txtPrice.setText(Utils.toString(goods.getPrice()));
txtDiscount.setText(goods.getDiscount().toString()); txtDiscount.setText(Utils.toString(goods.getDiscount()));
icoDiscount.setPaintFlags(icoDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); icoPrice.setPaintFlags(icoPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtDiscount.setPaintFlags(txtDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); txtPrice.setPaintFlags(txtPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtCount.setText(goods.getCount().toString()); txtCount.setText(goods.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));
......
package com.ihaoin.hooloo.device.component;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.ihaoin.hooloo.device.util.CollectionUtils;
import java.util.List;
public class IntroViewPager extends ViewPager {
public IntroViewPager(@NonNull Context context) {
super(context);
}
public IntroViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (getAdapter() == null) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
int index = getCurrentItem();
int height = 0;
View v = getView(index);
if (v != null) {
v.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
height = v.getMeasuredHeight();
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
private List<View> introViews;
public void setIntroViews(List<View> introViews) {
this.introViews = introViews;
this.setAdapter(pagerAdapter);
}
public View getView(int index) {
if (CollectionUtils.isEmpty(introViews)) {
return null;
}
return introViews.get(index);
}
public int getCount() {
if (pagerAdapter == null) {
return 0;
}
return pagerAdapter.getCount();
}
private PagerAdapter pagerAdapter = new PagerAdapter() {
@Override
public int getCount() {
return CollectionUtils.isEmpty(introViews) ? 0 : introViews.size();
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
View view = introViews.get(position);
container.removeView(view);
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
if (CollectionUtils.isEmpty(introViews)) {
return null;
}
View view = introViews.get(position);
container.addView(view);
return view;
}
};
}
...@@ -8,6 +8,7 @@ import android.util.DisplayMetrics; ...@@ -8,6 +8,7 @@ import android.util.DisplayMetrics;
import android.view.TouchDelegate; import android.view.TouchDelegate;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.RadioGroup;
import androidx.coordinatorlayout.widget.ViewGroupUtils; import androidx.coordinatorlayout.widget.ViewGroupUtils;
...@@ -22,7 +23,10 @@ import com.ihaoin.hooloo.device.view.GoodsDetailDialog; ...@@ -22,7 +23,10 @@ import com.ihaoin.hooloo.device.view.GoodsDetailDialog;
import com.ihaoin.hooloo.device.view.SettingsActivity; import com.ihaoin.hooloo.device.view.SettingsActivity;
import com.ihaoin.hooloo.device.view.TipsDialog; import com.ihaoin.hooloo.device.view.TipsDialog;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.List; import java.util.List;
import java.util.Optional;
public class Utils { public class Utils {
...@@ -123,4 +127,39 @@ public class Utils { ...@@ -123,4 +127,39 @@ public class Utils {
})); }));
group.setTouchDelegate(composite); group.setTouchDelegate(composite);
} }
public static String toString(BigDecimal num) {
DecimalFormat df = new DecimalFormat("#.00");
return df.format(num);
}
/** 获取SKU,优选获取默认的SKU */
public static Sku getDefaultSku(List<Sku> skus) {
if (CollectionUtils.isEmpty(skus)) {
return null;
}
Optional<Sku> optional = skus.stream().filter(x -> Base.TRUE.equals(x.getIsDefault()) && Base.TRUE.equals(x.getState())).findAny();
if (optional.isPresent()) {
return optional.get();
}
optional = skus.stream().filter(x -> Base.TRUE.equals(x.getState())).findAny();
if (optional.isPresent()) {
return optional.get();
}
return skus.get(0);
}
public static void check(RadioGroup group, int position) {
if (group == null) {
return;
}
if (group.getChildCount() < position) {
return;
}
View v = group.getChildAt(position);
if (v == null) {
return;
}
group.check(v.getId());
}
} }
...@@ -4,20 +4,26 @@ import android.app.Dialog; ...@@ -4,20 +4,26 @@ import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
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.IntroViewPager;
import com.ihaoin.hooloo.device.config.Base; import com.ihaoin.hooloo.device.config.Base;
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;
...@@ -37,12 +43,13 @@ public class GoodsDetailDialog extends Dialog { ...@@ -37,12 +43,13 @@ public class GoodsDetailDialog extends Dialog {
private Goods goods; private Goods goods;
private Sku checkSku; private Sku checkSku;
private View butnClose; private View butnClose;
private ImageView imgIntro; private IntroViewPager introPager;
private RadioGroup introIndicator;
private TextView txtName; private TextView txtName;
private LinearLayout layoutSpecs; private LinearLayout layoutSpecs;
private LinearLayout layoutImages; private LinearLayout layoutImages;
private TextView txtPrice; private TextView txtPrice;
private TextView icoDiscount; private TextView icoPirce;
private TextView txtDiscount; private TextView txtDiscount;
private Button butnSubtract; private Button butnSubtract;
private TextView txtCount; private TextView txtCount;
...@@ -54,6 +61,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -54,6 +61,7 @@ public class GoodsDetailDialog extends Dialog {
private View txtSellout; private View txtSellout;
private Integer count = 1; private Integer count = 1;
private List<View> introViews;
public GoodsDetailDialog(@NonNull Context context, Goods goods) { public GoodsDetailDialog(@NonNull Context context, Goods goods) {
super(context); super(context);
...@@ -72,12 +80,13 @@ public class GoodsDetailDialog extends Dialog { ...@@ -72,12 +80,13 @@ public class GoodsDetailDialog extends Dialog {
layoutOperate = findViewById(R.id.layout_operate); layoutOperate = findViewById(R.id.layout_operate);
txtSellout = findViewById(R.id.txt_sellout); txtSellout = findViewById(R.id.txt_sellout);
butnClose = findViewById(R.id.butn_close); butnClose = findViewById(R.id.butn_close);
imgIntro = findViewById(R.id.img_intro); introPager = findViewById(R.id.intro_pager);
introIndicator = findViewById(R.id.intro_indicator);
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);
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);
...@@ -87,20 +96,50 @@ public class GoodsDetailDialog extends Dialog { ...@@ -87,20 +96,50 @@ public class GoodsDetailDialog extends Dialog {
butnClose.setOnClickListener(x -> dismiss()); butnClose.setOnClickListener(x -> dismiss());
if (goods.getPics() == null) { introViews = new ArrayList<>();
imgIntro.setImageDrawable(null); if (goods.getPics() != null && !CollectionUtils.isEmpty(goods.getPics().getIntroImages())) {
} else { // goods.getPics().getIntroImages().addAll(goods.getPics().getIntroImages()); // TODO TEST
Glide.with(getContext()).load(goods.getPics().getIntroImages().get(0)).into(imgIntro);
for (int i = 0; i < goods.getPics().getIntroImages().size(); i++) {
String url = goods.getPics().getIntroImages().get(i);
View imgIntro = getIntroImage(url);
View btnIntro = getIntroButton(i);
introViews.add(imgIntro);
introIndicator.addView(btnIntro);
}
introPager.setIntroViews(introViews);
Utils.check(introIndicator, 0);
// introIndicator.check(0);
if (introIndicator.getChildCount() > 1) {
introIndicator.setVisibility(View.VISIBLE);
startPageThread();
introPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
Utils.check(introIndicator, position);
} }
txtName.setText(goods.getName());
txtPrice.setText(String.valueOf(goods.getPrice())); @Override
txtDiscount.setText(String.valueOf(goods.getDiscount())); public void onPageScrollStateChanged(int state) {
}
});
}
}
txtName.setText(goods.getName());
txtPrice.setText(Utils.toString(goods.getPrice()));
txtDiscount.setText(Utils.toString(goods.getDiscount()));
butnSubtract.setOnClickListener(v -> subtractGoods()); butnSubtract.setOnClickListener(v -> subtractGoods());
butnAdd.setOnClickListener(v -> addGoods()); butnAdd.setOnClickListener(v -> addGoods());
icoDiscount.setPaintFlags(icoDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); icoPirce.setPaintFlags(icoPirce.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtDiscount.setPaintFlags(txtDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); txtPrice.setPaintFlags(txtPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
butnBuy.setOnClickListener(v -> buyNow()); butnBuy.setOnClickListener(v -> buyNow());
butnTrolley.setOnClickListener(v -> addTrolley()); butnTrolley.setOnClickListener(v -> addTrolley());
...@@ -115,6 +154,75 @@ public class GoodsDetailDialog extends Dialog { ...@@ -115,6 +154,75 @@ public class GoodsDetailDialog extends Dialog {
buildDetails(); buildDetails();
Utils.setTouchDelegate(findViewById(R.id.layout_root), Arrays.asList(butnClose)); Utils.setTouchDelegate(findViewById(R.id.layout_root), Arrays.asList(butnClose));
setOnDismissListener(dialog -> {
if (pagerHandler != null) {
pagerHandler.removeCallbacksAndMessages(null);
pagerHandler = null;
}
});
}
private void startPageThread() {
pagerHandler = new PagerHandler();
pagerThread = new PagerThread();
pagerThread.start();
}
private PagerThread pagerThread;
private PagerHandler pagerHandler;
private class PagerThread extends Thread {
@Override
public void run() {
try {
while (true) {
Thread.sleep(1000 * 2);
pagerHandler.sendEmptyMessage(1);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private class PagerHandler extends Handler {
@Override
public void handleMessage(@NonNull Message msg) {
int index = introPager.getCurrentItem();
int count = introPager.getCount();
if (index + 1 >= count) {
index = 0;
} else {
index++;
}
introPager.setCurrentItem(index, true);
}
}
private View getIntroButton(int id) {
Integer width = Utils.getDimens(getContext(), R.dimen.padding5);
Integer height = Utils.getDimens(getContext(), R.dimen.padding5);
RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(width, height);
layoutParams.rightMargin = Utils.getDimens(getContext(), R.dimen.padding3);
RadioButton button = new RadioButton(getContext());
button.setLayoutParams(layoutParams);
button.setButtonDrawable(null);
button.setBackgroundResource(R.drawable.sel_intro_indicator);
button.setText("");
button.setId(id);
return button;
}
private ImageView getIntroImage(String url) {
RequestOptions options = new RequestOptions().placeholder(R.drawable.bg_image_placeholder);
ImageView imgIntro = new ImageView(getContext());
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
imgIntro.setLayoutParams(layoutParams);
imgIntro.setAdjustViewBounds(true);
Glide.with(getContext()).setDefaultRequestOptions(options).load(url).into(imgIntro);
return imgIntro;
} }
private void buyNow() { private void buyNow() {
...@@ -175,22 +283,24 @@ public class GoodsDetailDialog extends Dialog { ...@@ -175,22 +283,24 @@ public class GoodsDetailDialog extends Dialog {
TextView button = ruleView.findViewById(R.id.butn_rule); TextView button = ruleView.findViewById(R.id.butn_rule);
button.setId(rule.getRuleId()); button.setId(rule.getRuleId());
button.setText(rule.getRuleName()); button.setText(rule.getRuleName());
if (Base.TRUE.equals(rule.getIsRecommend())) {
ruleView.findViewById(R.id.txt_recommend).setVisibility(View.VISIBLE);
}
if (!Base.TRUE.equals(rule.getState())) { if (!Base.TRUE.equals(rule.getState())) {
button.setEnabled(false); button.setEnabled(false);
} else if (Base.TRUE.equals(rule.getIsDefault())) { } else {
if (Base.TRUE.equals(rule.getIsDefault())) {
button.setSelected(true); button.setSelected(true);
ruleView.setSelected(true); ruleView.setSelected(true);
} }
if (Base.TRUE.equals(rule.getIsRecommend())) {
ruleView.findViewById(R.id.txt_recommend).setVisibility(View.VISIBLE);
}
layoutRules.addView(ruleView, layoutParams);
ruleView.setOnClickListener(v -> { ruleView.setOnClickListener(v -> {
clearSelected(layoutRules); clearSelected(layoutRules);
ruleView.setSelected(true); ruleView.setSelected(true);
button.setSelected(true); button.setSelected(true);
changeSkuWithRule(); changeSkuWithRule();
}); });
}
layoutRules.addView(ruleView, layoutParams);
}); });
layoutSpecs.addView(specView); layoutSpecs.addView(specView);
// layoutRules.setOnCheckedChangeListener((group, checkedId) -> changeSkuWithRule()); // layoutRules.setOnCheckedChangeListener((group, checkedId) -> changeSkuWithRule());
...@@ -218,7 +328,7 @@ public class GoodsDetailDialog extends Dialog { ...@@ -218,7 +328,7 @@ public class GoodsDetailDialog extends Dialog {
List<GoodsRule> rules = new ArrayList<>(); List<GoodsRule> rules = new ArrayList<>();
for (int i = 0; i < layoutSpecs.getChildCount(); i++) { for (int i = 0; i < layoutSpecs.getChildCount(); i++) {
View v = layoutSpecs.getChildAt(i); View v = layoutSpecs.getChildAt(i);
LinearLayout layoutRules = (LinearLayout) v.findViewById(R.id.layout_rules); LinearLayout layoutRules = v.findViewById(R.id.layout_rules);
View view = getSelectedView(layoutRules); View view = getSelectedView(layoutRules);
if (view == null) { if (view == null) {
continue; continue;
...@@ -227,11 +337,11 @@ public class GoodsDetailDialog extends Dialog { ...@@ -227,11 +337,11 @@ public class GoodsDetailDialog extends Dialog {
} }
checkSku = matchSku(rules); checkSku = matchSku(rules);
if (checkSku == null) { if (checkSku == null) {
Toast.makeText(getContext(), R.string.not_found_goods, Toast.LENGTH_SHORT).show(); // Toast.makeText(getContext(), R.string.not_found_goods, Toast.LENGTH_SHORT).show();
return; return;
} }
txtPrice.setText(String.valueOf(checkSku.getPrice())); txtPrice.setText(Utils.toString(checkSku.getPrice()));
txtDiscount.setText(String.valueOf(checkSku.getDiscount())); txtDiscount.setText(Utils.toString(checkSku.getDiscount()));
} }
private View getSelectedView(LinearLayout layoutRules) { private View getSelectedView(LinearLayout layoutRules) {
......
...@@ -73,13 +73,12 @@ public class LauncherActivity extends Activity { ...@@ -73,13 +73,12 @@ public class LauncherActivity extends Activity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(AppConfig.DEBUG_TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher); setContentView(R.layout.activity_launcher);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
mContext = this; mContext = this;
setMachineCode();
requestPermissions(); requestPermissions();
trolleyView = findViewById(R.id.view_trolley); trolleyView = findViewById(R.id.view_trolley);
...@@ -87,7 +86,6 @@ public class LauncherActivity extends Activity { ...@@ -87,7 +86,6 @@ public class LauncherActivity extends Activity {
recGoods = findViewById(R.id.rec_right); recGoods = findViewById(R.id.rec_right);
recRecommends = findViewById(R.id.rec_recommend); recRecommends = findViewById(R.id.rec_recommend);
initRecommends(); initRecommends();
setRecommendsData(); setRecommendsData();
...@@ -347,15 +345,28 @@ public class LauncherActivity extends Activity { ...@@ -347,15 +345,28 @@ public class LauncherActivity extends Activity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Log.d(AppConfig.DEBUG_TAG, "onDestroy");
super.onDestroy(); super.onDestroy();
exit();
}
private void exit() {
Log.d(AppConfig.DEBUG_TAG, "exit");
this.unregistTrolleyGoodsChangedReceiver(); this.unregistTrolleyGoodsChangedReceiver();
this.unregistTrolleyStateChangedReceiver(); this.unregistTrolleyStateChangedReceiver();
this.unregistSettingChangedReceiver(); this.unregistSettingChangedReceiver();
System.exit(0); System.exit(0);
} }
@Override
public void onBackPressed() {
super.onBackPressed();
exit();
}
private TrolleyGoodsChangedReceiver trolleyGoodsChangedReceiver = null; private TrolleyGoodsChangedReceiver trolleyGoodsChangedReceiver = null;
private TrolleyStateChangedReceiver trolleyStateChangedReceiver = null; private TrolleyStateChangedReceiver trolleyStateChangedReceiver = null;
private SettingChangedReceiver settingChangedReceiver;
/** 注册购物车广播 */ /** 注册购物车广播 */
private void registTrolleyGoodsChangedReceiver() { private void registTrolleyGoodsChangedReceiver() {
...@@ -426,9 +437,6 @@ public class LauncherActivity extends Activity { ...@@ -426,9 +437,6 @@ public class LauncherActivity extends Activity {
} }
} }
private SettingChangedReceiver settingChangedReceiver;
private void registSettingChangedReceiver() { private void registSettingChangedReceiver() {
settingChangedReceiver = new SettingChangedReceiver(); settingChangedReceiver = new SettingChangedReceiver();
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
......
...@@ -174,7 +174,7 @@ public class TrolleyView extends RelativeLayout { ...@@ -174,7 +174,7 @@ public class TrolleyView extends RelativeLayout {
public void goodsChanged() { public void goodsChanged() {
this.trolleyAdapter.notifyDataSetChanged(); this.trolleyAdapter.notifyDataSetChanged();
this.txtCount.setText(getCheckedCount().toString()); this.txtCount.setText(getCheckedCount().toString());
this.txtTotal.setText(getCheckedTotal().toString()); this.txtTotal.setText(Utils.toString(getCheckedTotal()));
this.setView(); this.setView();
this.measureListHeight(); this.measureListHeight();
} }
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<!-- <corners android:radius="2dp" />-->
<solid
android:width="1dp"
android:color="@color/textSecondPrimary" />
</shape>
</item>
<!-- <item-->
<!-- android:bottom="10dp"-->
<!-- android:left="10dp"-->
<!-- android:right="10dp"-->
<!-- android:top="10dp">-->
<!-- <bitmap-->
<!-- android:gravity="center"-->
<!-- android:src="@mipmap/jiahao_2x" />-->
<!-- </item>-->
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="@color/textDisable" />
<size
android:width="30dp"
android:height="30dp" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<item android:drawable="@drawable/ic_dot" android:state_checked="true" />
<item android:drawable="@drawable/ic_dot_unchecked" />
</selector>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding3"> android:layout_marginTop="@dimen/padding3">
<TextView <TextView
android:id="@+id/ico_price" android:id="@+id/ico_discount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
...@@ -72,32 +72,32 @@ ...@@ -72,32 +72,32 @@
android:textColor="@color/textRed" android:textColor="@color/textRed"
android:textSize="@dimen/ts_goods_item_price" /> android:textSize="@dimen/ts_goods_item_price" />
<TextView <TextView
android:id="@+id/txt_price" android:id="@+id/txt_discount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_toRightOf="@id/ico_price" android:layout_toRightOf="@id/ico_discount"
android:text="19.9" android:text="19.9"
android:textColor="@color/textRed" android:textColor="@color/textRed"
android:textSize="@dimen/ts_goods_item_price" android:textSize="@dimen/ts_goods_item_price"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/ico_discount" android:id="@+id/ico_price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_marginStart="@dimen/padding5" android:layout_marginStart="@dimen/padding5"
android:layout_toEndOf="@id/txt_price" android:layout_toEndOf="@id/txt_discount"
android:text="¥" android:text="¥"
android:textColor="@color/textSecondPrimary" android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_goods_item_discount" /> android:textSize="@dimen/ts_goods_item_discount" />
<TextView <TextView
android:id="@+id/txt_discount" android:id="@+id/txt_price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_toEndOf="@id/ico_discount" android:layout_toEndOf="@id/ico_price"
android:text="29.9" android:text="29.9"
android:textColor="@color/textSecondPrimary" android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_goods_item_discount" /> android:textSize="@dimen/ts_goods_item_discount" />
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_item" android:id="@+id/layout_item"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
...@@ -8,25 +9,32 @@ ...@@ -8,25 +9,32 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="centerCrop" /> android:scaleType="centerCrop"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/txt_name" android:id="@+id/txt_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/padding20" android:layout_marginStart="@dimen/padding20"
android:layout_marginTop="@dimen/padding20"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/ts_recommend_name" android:textSize="@dimen/ts_recommend_name"
android:textStyle="bold" /> android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/txt_intro" android:id="@+id/txt_intro"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/txt_name" android:layout_below="@+id/txt_name"
android:layout_marginStart="@dimen/padding20" android:layout_marginStart="@dimen/padding20"
android:layout_marginTop="@dimen/padding10" android:layout_marginBottom="@dimen/padding15"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/ts_recommend_desc" android:textSize="@dimen/ts_recommend_desc"
android:textStyle="bold" /> android:textStyle="bold"
</RelativeLayout> app:layout_constraintBottom_toBottomOf="parent"
\ No newline at end of file app:layout_constraintLeft_toLeftOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/txt_recommend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_spec_recommend"
android:paddingHorizontal="@dimen/padding5"
android:paddingVertical="@dimen/padding3"
android:text="推荐"
android:textColor="@color/white"
android:textSize="@dimen/ts_detail_spec_rec" />
...@@ -50,14 +50,14 @@ ...@@ -50,14 +50,14 @@
android:gravity="bottom" android:gravity="bottom"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/ico_price" android:id="@+id/ico_discount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="¥" android:text="¥"
android:textColor="@color/textRed" android:textColor="@color/textRed"
android:textSize="@dimen/ts_goods_item_price" /> android:textSize="@dimen/ts_goods_item_price" />
<TextView <TextView
android:id="@+id/txt_price" android:id="@+id/txt_discount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="19.9" android:text="19.9"
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
android:textSize="@dimen/ts_goods_item_price" android:textSize="@dimen/ts_goods_item_price"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/ico_discount" android:id="@+id/ico_price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/padding5" android:layout_marginStart="@dimen/padding5"
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
android:textColor="@color/textSecondPrimary" android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_goods_item_discount" /> android:textSize="@dimen/ts_goods_item_discount" />
<TextView <TextView
android:id="@+id/txt_discount" android:id="@+id/txt_price"
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"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_root" android:id="@+id/layout_root"
android:layout_width="@dimen/dialog_detail_width" android:layout_width="@dimen/dialog_detail_width"
android:layout_height="match_parent"> android:layout_height="match_parent">
...@@ -17,13 +18,27 @@ ...@@ -17,13 +18,27 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="@dimen/padding10"> android:padding="@dimen/padding10">
<ImageView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/img_intro"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/padding10" android:layout_margin="@dimen/padding10"
android:layout_weight="1" android:layout_weight="1">
android:adjustViewBounds="true" /> <com.ihaoin.hooloo.device.component.IntroViewPager
android:id="@+id/intro_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<RadioGroup
android:id="@+id/intro_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/padding10"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -43,6 +58,14 @@ ...@@ -43,6 +58,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" /> android:orientation="vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding10"
android:text="商品详细"
android:textColor="@color/textPrimary"
android:textSize="@dimen/ts_detail_spec"
android:textStyle="bold" />
<LinearLayout <LinearLayout
android:id="@+id/layout_images" android:id="@+id/layout_images"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -72,14 +95,14 @@ ...@@ -72,14 +95,14 @@
android:gravity="bottom" android:gravity="bottom"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/ico_price" android:id="@+id/ico_discount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="¥" android:text="¥"
android:textColor="@color/textRed" android:textColor="@color/textRed"
android:textSize="@dimen/ts_detail_price" /> android:textSize="@dimen/ts_detail_price" />
<TextView <TextView
android:id="@+id/txt_price" android:id="@+id/txt_discount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
...@@ -89,7 +112,7 @@ ...@@ -89,7 +112,7 @@
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/ico_discount" android:id="@+id/ico_price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/padding5" android:layout_marginStart="@dimen/padding5"
...@@ -97,7 +120,7 @@ ...@@ -97,7 +120,7 @@
android:textColor="@color/textSecondPrimary" android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_detail_discount" /> android:textSize="@dimen/ts_detail_discount" />
<TextView <TextView
android:id="@+id/txt_discount" android:id="@+id/txt_price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
......
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