Commit daa586fa by wjg

init

parent 4b8660af
package com.ihaoin.hooloo.device.adapter;
import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -84,10 +85,7 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
helper.setText(R.id.txt_price, String.valueOf(sku.getPrice()));
helper.setText(R.id.txt_discount, String.valueOf(sku.getDiscount()));
if (Base.FALSE.equals(sku.getState())) {
helper.setGone(R.id.txt_sellout, true);
helper.setGone(R.id.butn_add, false);
} else {
if (Base.TRUE.equals(sku.getState())) {
helper.setGone(R.id.txt_sellout, false);
helper.setGone(R.id.butn_add, true);
View butnAdd = helper.getView(R.id.butn_add);
......@@ -95,9 +93,23 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
ViewGroup layoutItem = helper.getView(R.id.layout_item);
Utils.setTouchDelegate(layoutItem, Arrays.asList(butnAdd));
} else {
helper.setGone(R.id.txt_sellout, true);
helper.setGone(R.id.butn_add, false);
}
}
if (Base.TRUE.equals(goods.getIsRecommend())) {
helper.setVisible(R.id.img_recommend, true);
} else {
helper.setGone(R.id.img_recommend, false);
}
TextView icoDiscount = helper.getView(R.id.ico_discount);
TextView txtDiscount = helper.getView(R.id.txt_discount);
icoDiscount.setPaintFlags(icoDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtDiscount.setPaintFlags(txtDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
View layoutItem = helper.getView(R.id.layout_item);
layoutItem.setOnClickListener(v -> Utils.showGoodsDetail(mContext, goods));
......
package com.ihaoin.hooloo.device.adapter;
import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -39,6 +40,7 @@ public class TrolleyAdapter extends BaseAdapter {
TextView txtOptions = convertView.findViewById(R.id.txt_options);
TextView txtPrice = convertView.findViewById(R.id.txt_price);
TextView txtDiscount = convertView.findViewById(R.id.txt_discount);
TextView icoDiscount = convertView.findViewById(R.id.ico_discount);
View butnSubtract = convertView.findViewById(R.id.butn_subtract);
TextView txtCount = convertView.findViewById(R.id.txt_count);
View butnAdd = convertView.findViewById(R.id.butn_add);
......@@ -67,6 +69,9 @@ public class TrolleyAdapter extends BaseAdapter {
txtPrice.setText(goods.getPrice().toString());
txtDiscount.setText(goods.getDiscount().toString());
icoDiscount.setPaintFlags(icoDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtDiscount.setPaintFlags(txtDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtCount.setText(goods.getCount().toString());
butnSubtract.setOnClickListener(v -> trolleyView.subtractGoods(position));
butnAdd.setOnClickListener(v -> trolleyView.addGoods(position));
......
......@@ -2,13 +2,13 @@ package com.ihaoin.hooloo.device.view;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
......@@ -42,6 +42,7 @@ public class GoodsDetailDialog extends Dialog {
private LinearLayout layoutSpecs;
private LinearLayout layoutImages;
private TextView txtPrice;
private TextView icoDiscount;
private TextView txtDiscount;
private Button butnSubtract;
private TextView txtCount;
......@@ -76,6 +77,7 @@ public class GoodsDetailDialog extends Dialog {
layoutSpecs = findViewById(R.id.layout_specs);
layoutImages = findViewById(R.id.layout_images);
txtPrice = findViewById(R.id.txt_price);
icoDiscount = findViewById(R.id.ico_discount);
txtDiscount = findViewById(R.id.txt_discount);
butnSubtract = findViewById(R.id.butn_subtract);
txtCount = findViewById(R.id.txt_count);
......@@ -97,6 +99,9 @@ public class GoodsDetailDialog extends Dialog {
butnSubtract.setOnClickListener(v -> subtractGoods());
butnAdd.setOnClickListener(v -> addGoods());
icoDiscount.setPaintFlags(icoDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
txtDiscount.setPaintFlags(txtDiscount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
butnBuy.setOnClickListener(v -> buyNow());
butnTrolley.setOnClickListener(v -> addTrolley());
......@@ -157,29 +162,55 @@ public class GoodsDetailDialog extends Dialog {
}
View specView = getLayoutInflater().inflate(R.layout.item_spec, null);
TextView txtName = specView.findViewById(R.id.txt_name);
RadioGroup specGroup = specView.findViewById(R.id.group_spec);
LinearLayout layoutRules = specView.findViewById(R.id.layout_rules);
txtName.setText(spec.getSpecName());
spec.getRules().forEach(rule -> {
RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
layoutParams.rightMargin = Utils.getDimens(getContext(), R.dimen.padding5);
RadioButton button = (RadioButton) getLayoutInflater().inflate(R.layout.item_spec_rule, null);
View ruleView = getLayoutInflater().inflate(R.layout.item_spec_rule, null);
ruleView.setTag(rule);
TextView button = ruleView.findViewById(R.id.butn_rule);
button.setId(rule.getRuleId());
button.setText(rule.getRuleName());
button.setTag(rule);
if (!Base.TRUE.equals(rule.getState())) {
button.setEnabled(false);
} else if (Base.TRUE.equals(rule.getIsDefault())) {
button.setChecked(true);
button.setSelected(true);
ruleView.setSelected(true);
}
specGroup.addView(button, layoutParams);
if (Base.TRUE.equals(rule.getIsRecommend())) {
ruleView.findViewById(R.id.txt_recommend).setVisibility(View.VISIBLE);
}
layoutRules.addView(ruleView, layoutParams);
ruleView.setOnClickListener(v -> {
clearSelected(layoutRules);
ruleView.setSelected(true);
button.setSelected(true);
changeSkuWithRule();
});
});
layoutSpecs.addView(specView);
specGroup.setOnCheckedChangeListener((group, checkedId) -> changeSkuWithRule());
// layoutRules.setOnCheckedChangeListener((group, checkedId) -> changeSkuWithRule());
});
changeSkuWithRule();
}
private void clearSelected(ViewGroup group) {
if (group.getChildCount() <= 0) {
return;
}
for (int i = 0; i < group.getChildCount(); i++) {
View v = group.getChildAt(i);
v.setSelected(false);
if (v instanceof ViewGroup) {
clearSelected((ViewGroup) v);
}
}
}
private void changeSkuWithRule() {
if (layoutSpecs.getChildCount() <= 0) {
return;
......@@ -187,12 +218,12 @@ public class GoodsDetailDialog extends Dialog {
List<GoodsRule> rules = new ArrayList<>();
for (int i = 0; i < layoutSpecs.getChildCount(); i++) {
View v = layoutSpecs.getChildAt(i);
RadioGroup group = v.findViewById(R.id.group_spec);
RadioButton button = group.findViewById(group.getCheckedRadioButtonId());
if (button == null) {
LinearLayout layoutRules = (LinearLayout) v.findViewById(R.id.layout_rules);
View view = getSelectedView(layoutRules);
if (view == null) {
continue;
}
rules.add((GoodsRule) button.getTag());
rules.add((GoodsRule) view.getTag());
}
checkSku = matchSku(rules);
if (checkSku == null) {
......@@ -203,6 +234,19 @@ public class GoodsDetailDialog extends Dialog {
txtDiscount.setText(String.valueOf(checkSku.getDiscount()));
}
private View getSelectedView(LinearLayout layoutRules) {
if (layoutRules.getChildCount() <= 0) {
return null;
}
for (int i = 0; i < layoutRules.getChildCount(); i++) {
View v = layoutRules.getChildAt(i);
if (v.isSelected()) {
return v;
}
}
return null;
}
private Sku matchSku(List<GoodsRule> rules) {
if (CollectionUtils.isEmpty(rules)) {
return null;
......
<?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="@dimen/rule_recommend_corners" />
<solid
android:width="1dp"
android:color="@color/colorPink" />
</shape>
</item>
</layer-list>
<vector android:height="18dp" android:tint="#999999"
android:viewportHeight="24" android:viewportWidth="24"
android:width="18dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8,9h8v10L8,19L8,9zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>
</vector>
......@@ -2,5 +2,5 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<item android:drawable="@mipmap/duigou_2x" android:state_checked="true" />
<item android:drawable="@mipmap/duigou_2x" android:state_selected="true" />
<item android:drawable="@mipmap/duigou_2x" />
<item android:drawable="@mipmap/weixuanzhong_2x" />
</selector>
......@@ -11,21 +11,24 @@
android:id="@+id/rec_recommend"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7" />
android:layout_weight="7"
android:descendantFocusability="afterDescendants" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/padding10"
android:layout_weight="4.5">
<androidx.recyclerview.widget.RecyclerView
android:paddingTop="@dimen/padding20"
android:id="@+id/rec_right"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants"
android:paddingTop="@dimen/padding20" />
</FrameLayout>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants"
android:scrollbars="none">
<RadioGroup
android:id="@+id/group_category"
......
......@@ -8,6 +8,7 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
......
......@@ -22,7 +22,8 @@
android:layout_height="@dimen/ic_recommend"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/padding5"
android:src="@mipmap/aixin_2x" />
android:src="@mipmap/aixin_2x"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:id="@+id/layout_right"
......@@ -61,37 +62,42 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding3">
<ImageView
android:id="@+id/img_price"
android:layout_width="@dimen/ic_price"
android:layout_height="@dimen/ic_price"
<TextView
android:id="@+id/ico_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:src="@drawable/ms__arrow" />
android:src="@drawable/ms__arrow"
android:text="¥"
android:textColor="@color/textRed"
android:textSize="@dimen/ts_goods_item_price" />
<TextView
android:id="@+id/txt_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@id/img_price"
android:layout_toRightOf="@id/ico_price"
android:text="19.9"
android:textColor="@color/textRed"
android:textSize="@dimen/ts_goods_item_price"
android:textStyle="bold" />
<ImageView
android:id="@+id/img_discount"
android:layout_width="@dimen/ic_discount"
android:layout_height="@dimen/ic_discount"
<TextView
android:id="@+id/ico_discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginStart="@dimen/padding5"
android:layout_toEndOf="@id/txt_price"
android:src="@drawable/ms__arrow" />
android:text="¥"
android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_goods_item_discount" />
<TextView
android:id="@+id/txt_discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@id/img_discount"
android:layout_toEndOf="@id/ico_discount"
android:text="29.9"
android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_goods_item_discount" />
......
......@@ -12,8 +12,8 @@
android:textColor="@color/textPrimary"
android:textSize="@dimen/ts_detail_spec"
android:textStyle="bold" />
<RadioGroup
android:id="@+id/group_spec"
<LinearLayout
android:id="@+id/layout_rules"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spec_rule_margin"
......
<?xml version="1.0" encoding="utf-8"?>
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/butn_rule"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/padding10"
android:background="@drawable/sel_spec_bg"
android:button="@null"
android:paddingHorizontal="@dimen/padding10"
android:paddingVertical="@dimen/rule_vertical_padding"
android:singleLine="true"
android:textColor="@drawable/sel_spec_color"
android:textSize="@dimen/ts_detail_rule" />
android:layout_height="wrap_content">
<TextView
android:id="@+id/butn_rule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding5"
android:layout_marginEnd="@dimen/padding10"
android:background="@drawable/sel_spec_bg"
android:paddingHorizontal="@dimen/padding10"
android:paddingVertical="@dimen/rule_vertical_padding"
android:singleLine="true"
android:text="加糖"
android:textColor="@drawable/sel_spec_color"
android:textSize="@dimen/ts_detail_rule"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
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"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="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" />
......@@ -49,10 +49,13 @@
android:layout_marginTop="@dimen/padding5"
android:gravity="bottom"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/ic_price"
android:layout_height="@dimen/ic_price"
android:src="@drawable/ms__arrow" />
<TextView
android:id="@+id/ico_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥"
android:textColor="@color/textRed"
android:textSize="@dimen/ts_goods_item_price" />
<TextView
android:id="@+id/txt_price"
android:layout_width="wrap_content"
......@@ -61,12 +64,14 @@
android:textColor="@color/textRed"
android:textSize="@dimen/ts_goods_item_price"
android:textStyle="bold" />
<ImageView
android:layout_width="@dimen/ic_discount"
android:layout_height="@dimen/ic_discount"
<TextView
android:id="@+id/ico_discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/padding5"
android:src="@drawable/ms__arrow" />
android:text="¥"
android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_goods_item_discount" />
<TextView
android:id="@+id/txt_discount"
android:layout_width="0dp"
......
......@@ -71,10 +71,13 @@
android:layout_weight="1"
android:gravity="bottom"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/ic_detail_price"
android:layout_height="@dimen/ic_detail_price"
android:src="@drawable/ms__arrow" />
<TextView
android:id="@+id/ico_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥"
android:textColor="@color/textRed"
android:textSize="@dimen/ts_detail_price" />
<TextView
android:id="@+id/txt_price"
android:layout_width="wrap_content"
......@@ -85,11 +88,14 @@
android:textSize="@dimen/ts_detail_price"
android:textStyle="bold" />
<ImageView
android:layout_width="@dimen/ic_detail_discount"
android:layout_height="@dimen/ic_detail_discount"
<TextView
android:id="@+id/ico_discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/padding5"
android:src="@drawable/ms__arrow" />
android:text="¥"
android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_detail_discount" />
<TextView
android:id="@+id/txt_discount"
android:layout_width="wrap_content"
......
......@@ -21,8 +21,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/padding10"
android:orientation="horizontal">
android:orientation="horizontal"
android:padding="@dimen/padding10">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
......@@ -36,7 +36,7 @@
android:layout_width="@dimen/ic_clear_size"
android:layout_height="@dimen/ic_clear_size"
android:layout_marginStart="@dimen/padding5"
android:src="@drawable/ic_baseline_delete_outline_24" />
android:src="@mipmap/lajitong_2x" />
<Button
android:id="@+id/butn_clear"
android:layout_width="wrap_content"
......@@ -55,6 +55,7 @@
android:id="@+id/list_trolley"
android:layout_width="match_parent"
android:layout_height="@dimen/trolley_item_height"
android:descendantFocusability="afterDescendants"
android:divider="@null" />
<ImageView
android:layout_width="match_parent"
......@@ -84,8 +85,8 @@
android:layout_width="@dimen/trolley_count_size"
android:layout_height="@dimen/trolley_count_size"
android:layout_alignParentEnd="true"
android:background="@drawable/ic_dot"
android:layout_margin="@dimen/padding7"
android:background="@drawable/ic_dot"
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/ts_trolley_count"
......@@ -97,10 +98,13 @@
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/ic_trolley_price"
android:layout_height="@dimen/ic_trolley_price"
android:src="@drawable/ms__menu_down" />
<TextView
android:id="@+id/ico_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥"
android:textColor="@color/textPrimary"
android:textSize="@dimen/ts_trolley_total" />
<TextView
android:id="@+id/txt_total"
android:layout_width="wrap_content"
......
......@@ -27,6 +27,7 @@
<dimen name="trolley_ic_size">80dp</dimen>
<dimen name="trolley_ic_border_size">120dp</dimen>
<dimen name="trolley_count_size">30dp</dimen>
<dimen name="rule_recommend_corners">5dp</dimen>
<dimen name="ic_recommend">20dp</dimen>
<dimen name="ic_clear_size">30dp</dimen>
......@@ -64,6 +65,7 @@
<dimen name="ts_tips">18sp</dimen>
<dimen name="ts_detail_name">30sp</dimen>
<dimen name="ts_detail_spec">24sp</dimen>
<dimen name="ts_detail_spec_rec">12sp</dimen>
<dimen name="ts_detail_rule">22sp</dimen>
<dimen name="ts_detail_count">24sp</dimen>
<dimen name="ts_detail_price">24sp</dimen>
......
......@@ -10,6 +10,7 @@
<color name="textRed">#FFFF001D</color>
<color name="white">#FFFFFFFF</color>
<color name="black">#FF000000</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="colorPrimaryDark">#FF00574B</color>
<color name="colorAccent">#FFD81B60</color>
<color name="colorPink">#FFFF72C1</color>
</resources>
......@@ -27,6 +27,7 @@
<dimen name="trolley_ic_size">40dp</dimen>
<dimen name="trolley_ic_border_size">50dp</dimen>
<dimen name="trolley_count_size">20dp</dimen>
<dimen name="rule_recommend_corners">3dp</dimen>
<dimen name="ic_recommend">10dp</dimen>
<dimen name="ic_clear_size">15dp</dimen>
......@@ -40,7 +41,7 @@
<dimen name="ic_detail_subtract_size">20dp</dimen>
<dimen name="ic_detail_price">15dp</dimen>
<dimen name="ic_detail_discount">10dp</dimen>
<dimen name="ic_dialog_close">30dp</dimen>
<dimen name="ic_dialog_close">20dp</dimen>
<dimen name="ic_trolley_price">30dp</dimen>
<dimen name="ic_scan_succ">40dp</dimen>
<dimen name="ic_scan_wx">20dp</dimen>
......@@ -64,6 +65,7 @@
<dimen name="ts_tips">9sp</dimen>
<dimen name="ts_detail_name">20sp</dimen>
<dimen name="ts_detail_spec">14sp</dimen>
<dimen name="ts_detail_spec_rec">6sp</dimen>
<dimen name="ts_detail_rule">12sp</dimen>
<dimen name="ts_detail_count">14sp</dimen>
<dimen name="ts_detail_price">14sp</dimen>
......
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