Commit 163e8e9e by wjg

添加分类动画

parent d1e3b347
......@@ -134,14 +134,14 @@ public class GoodsAdapter extends BaseSectionQuickAdapter<ScrollBean, BaseViewHo
// layoutItem.setPadding(padding, padding, padding, padding);
int verPadding = Utils.getDimens(mContext, R.dimen.goods_padding_ver);
// 最后一个商品 并且购物条已经显示
if (getData().indexOf(item) == getItemCount() - 1) {
// int padding = Utils.getDimens(mContext, R.dimen.padding10);
int bottomPadding = Utils.getDimens(mContext, R.dimen.trolley_bar_goods_margin);
layoutItem.setPadding(0, 0, 0, bottomPadding);
int bottomPadding = Utils.getDimens(mContext, R.dimen.goods_last_padding_bottom);
layoutItem.setPadding(0, verPadding, 0, bottomPadding);
} else {
int bottomPadding = Utils.getDimens(mContext, R.dimen.goods_padding_bottom);
layoutItem.setPadding(0, 0, 0, bottomPadding);
layoutItem.setPadding(0, verPadding, 0, verPadding);
}
}
......
package com.ihaoin.hooloo.device.component;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class AutoWrapLayout extends FrameLayout {
private int paddingRight = 0;
private int paddingTop = 0;
private int paddingLeft = 0;
private int paddingBottom = 0;
public AutoWrapLayout(@NonNull Context context) {
super(context);
}
public AutoWrapLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
int childleft = 0;
int childtop = paddingTop;
for (int i = 0; i < getChildCount(); i++) {
View view = getChildAt(i);
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
int viewWidth = view.getMeasuredWidth() + layoutParams.leftMargin + layoutParams.rightMargin;
int viewHeight = view.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
if (childleft + viewWidth > right - paddingRight) {
//换行
childtop += viewHeight;
childleft = 0;
}
if (childleft == 0) childleft += paddingLeft;
view.layout(childleft, childtop, childleft + viewWidth, childtop + viewHeight);
childleft += viewWidth;
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int right = 0;
int height = paddingTop + paddingBottom;
int lineMaxHeight = 0;
for (int i = 0; i < getChildCount(); i++) {
View view = getChildAt(i);
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
int viewWidth = view.getMeasuredWidth() + layoutParams.leftMargin + layoutParams.rightMargin;
int viewHeight = view.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
if (right + viewWidth > width) {
//换行
height += lineMaxHeight;
right = 0;
lineMaxHeight = 0;
}
if (right == 0) right = paddingLeft + paddingRight;
right += viewWidth;
if (lineMaxHeight < viewHeight) lineMaxHeight = viewHeight;
if (i == getChildCount() - 1) height += lineMaxHeight;
}
setMeasuredDimension(width, height);
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ import androidx.viewpager.widget.ViewPager;
import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.component.AutoWrapLayout;
import com.ihaoin.hooloo.device.component.IntroViewPager;
import com.ihaoin.hooloo.device.component.NetworkHandler;
import com.ihaoin.hooloo.device.config.Base;
......@@ -338,13 +339,42 @@ public class GoodsDetailDialog extends Dialog {
if (CollectionUtils.isEmpty(spec.getRules())) {
return;
}
// GoodsRule r1 = new GoodsRule();
// GoodsRule r2 = new GoodsRule();
// GoodsRule r3 = new GoodsRule();
// r1.setRuleId(101);
// r1.setRuleName("101");
// r1.setIsDefault(0);
// r1.setIsRecommend(0);
// r1.setState(1);
// r1.setPrice(new BigDecimal("1"));
//
// r2.setRuleId(102);
// r2.setRuleName("102");
// r2.setIsDefault(0);
// r2.setIsRecommend(0);
// r2.setState(1);
// r2.setPrice(new BigDecimal("2"));
//
// r3.setRuleId(103);
// r3.setRuleName("103");
// r3.setIsDefault(0);
// r3.setIsRecommend(0);
// r3.setState(1);
// r3.setPrice(new BigDecimal("3"));
//
// spec.getRules().add(r1);
// spec.getRules().add(r2);
// spec.getRules().add(r3);
View specView = getLayoutInflater().inflate(R.layout.item_spec, null);
TextView txtName = specView.findViewById(R.id.txt_name);
LinearLayout layoutRules = specView.findViewById(R.id.layout_rules);
AutoWrapLayout layoutRules = specView.findViewById(R.id.layout_rules);
txtName.setText(spec.getSpecName());
spec.getRules().forEach(rule -> {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
AutoWrapLayout.LayoutParams layoutParams = new AutoWrapLayout.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
layoutParams.rightMargin = Utils.getDimens(getContext(), R.dimen.padding5);
View ruleView = getLayoutInflater().inflate(R.layout.item_spec_rule, null);
......@@ -398,7 +428,7 @@ public class GoodsDetailDialog extends Dialog {
List<GoodsRule> rules = new ArrayList<>();
for (int i = 0; i < layoutSpecs.getChildCount(); i++) {
View v = layoutSpecs.getChildAt(i);
LinearLayout layoutRules = v.findViewById(R.id.layout_rules);
AutoWrapLayout layoutRules = v.findViewById(R.id.layout_rules);
View view = getSelectedView(layoutRules);
if (view == null) {
continue;
......@@ -413,7 +443,7 @@ public class GoodsDetailDialog extends Dialog {
txtDiscount.setText(Utils.toString(mSku.getDiscount()));
}
private View getSelectedView(LinearLayout layoutRules) {
private View getSelectedView(AutoWrapLayout layoutRules) {
if (layoutRules.getChildCount() <= 0) {
return null;
}
......
......@@ -18,6 +18,7 @@ import android.view.View;
import android.view.WindowManager;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
......@@ -115,9 +116,8 @@ public class LauncherActivity extends Activity {
}
private void initSettingsQueue() {
View layoutLogo = findViewById(R.id.layout_logo);
View imgLogo = findViewById(R.id.img_logo);
new SettingsQueue(mContext, imgLogo, layoutLogo);
new SettingsQueue(mContext, imgLogo, txtCategory);
}
private void setMachineCode() {
......@@ -206,15 +206,40 @@ public class LauncherActivity extends Activity {
//给first赋值
first = firstPosition;
//判断如果右侧可见的第一个item是否是header,设置相应的值
if (scrollGoods.get(first).isHeader) {
title = scrollGoods.get(first).header;
} else {
title = scrollGoods.get(first).t.getType();
if (dy < 0) { // 上滑
// Log.d(AppConfig.TAG, "up, " + recGoods);
} else if (dy > 0) {// 下滑
// Log.d(AppConfig.TAG, "down, " + recGoods.getScrollY());
}
}
txtCategory.setText(title);
}
// 设置分类移动动画
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) txtCategory.getLayoutParams();
lp.setMargins(0, 0, 0, 0);
int nextPosition = firstPosition + 1; // 当前显示的下一个索引
if (nextPosition < scrollGoods.size()) { // 已经是最后一个item
if (scrollGoods.get(nextPosition).isHeader) { // 下一个是否是标题
View nextView = goodsLayoutManager.findViewByPosition(nextPosition); // 下一个view
int[] location = new int[2];
nextView.getLocationInWindow(location);
int topMargin = location[1];
int height = nextView.getHeight();
// Log.d(AppConfig.TAG, String.format("c:%s, n:%s, 0:%s, 1:%s", firstPosition, nextPosition, rect[0], rect[1]));
if (topMargin < height) {
lp.setMargins(0, -(height - topMargin), 0, 0);
}
}
}
txtCategory.setLayoutParams(lp);
// 遍历分类列表,设置选中分类
List<Category> categorys = HLApplication.getMainData().getCategorys();
for (Category category : categorys) {
......@@ -312,6 +337,13 @@ public class LauncherActivity extends Activity {
}
}
goodsAdapter.setNewData(scrollGoods);
recGoods.scrollBy(0, 0);
if (CollectionUtils.isEmpty(scrollGoods)) {
txtCategory.setText("");
} else {
txtCategory.setText(scrollGoods.get(0).header);
}
}
private void startLoadDataThread() {
......
......@@ -24,8 +24,7 @@
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.30833"
android:paddingTop="@dimen/padding20">
android:layout_weight="0.30833">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rec_right"
android:layout_width="match_parent"
......
......@@ -5,7 +5,8 @@
android:layout_height="wrap_content"
android:foreground="?selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="horizontal"
android:paddingVertical="@dimen/goods_padding_ver">
<RelativeLayout
android:layout_width="@dimen/goods_thum_size"
android:layout_height="@dimen/goods_thum_size"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
......@@ -9,9 +9,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/goods_category_margin_top"
android:paddingBottom="@dimen/goods_category_margin_bottom"
android:singleLine="true"
android:textColor="@color/textPrimary"
android:textSize="@dimen/ts_category_item"
android:textStyle="bold" />
</LinearLayout>
\ No newline at end of file
</RelativeLayout>
\ No newline at end of file
......@@ -2,15 +2,10 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/layout_logo"
<ImageView
android:id="@+id/img_logo"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@mipmap/logo" />
</FrameLayout>
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@mipmap/logo" />
</FrameLayout>
\ No newline at end of file
......@@ -12,10 +12,8 @@
android:textColor="@color/textSecondPrimary"
android:textSize="@dimen/ts_detail_spec"
android:textStyle="bold" />
<LinearLayout
<com.ihaoin.hooloo.device.component.AutoWrapLayout
android:id="@+id/layout_rules"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/goods_detail_layout_rule_margin_top"
android:orientation="horizontal" />
android:layout_height="wrap_content" />
</LinearLayout>
......@@ -2,7 +2,8 @@
<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_height="wrap_content"
android:paddingTop="@dimen/goods_detail_rule_margin_top">
<TextView
android:id="@+id/butn_rule"
android:layout_width="wrap_content"
......@@ -11,6 +12,8 @@
android:layout_marginEnd="@dimen/goods_detail_rule_margin_right"
android:background="@drawable/sel_spec_bg"
android:foreground="?selectableItemBackground"
android:gravity="center"
android:minWidth="@dimen/goods_detail_rule_width"
android:paddingHorizontal="@dimen/goods_detail_rule_padding_hor"
android:paddingVertical="@dimen/goods_detail_rule_padding_ver"
android:singleLine="true"
......
......@@ -90,7 +90,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/padding10"
android:layout_marginStart="@dimen/trolley_oper_margin"
android:gravity="center"
android:orientation="horizontal">
<Button
......
......@@ -33,7 +33,7 @@
android:id="@+id/intro_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/padding10"
android:layout_marginBottom="@dimen/goods_detail_indicator_margin"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone"
......@@ -109,7 +109,7 @@
android:id="@+id/txt_discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/padding5"
android:layout_marginEnd="@dimen/goods_detail_price_margin_right"
android:gravity="center_vertical"
android:text="19.9"
android:textColor="@color/textPrimary"
......
......@@ -13,7 +13,7 @@
android:layout_width="@dimen/ic_dialog_close"
android:layout_height="@dimen/ic_dialog_close"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/padding15"
android:layout_margin="@dimen/dialog_close_margin"
android:foreground="?selectableItemBackground"
android:src="@mipmap/chazi" />
</RelativeLayout>
\ No newline at end of file
......@@ -8,18 +8,20 @@
<dimen name="toast_width">376px</dimen>
<dimen name="toast_padding_hor">32px</dimen>
<dimen name="toast_padding_ver">55px</dimen>
<dimen name="recommend_padding">38px</dimen>
<dimen name="recommend_name_margin_top">82px</dimen>
<dimen name="recommend_name_margin_left">68px</dimen>
<dimen name="recommend_desc_margin_top">18px</dimen>
<dimen name="recommend_desc_margin_left">68px</dimen>
<dimen name="goods_padding_ver">30px</dimen>
<dimen name="goods_padding_right">38px</dimen>
<dimen name="goods_padding_bottom">50px</dimen>
<dimen name="goods_last_padding_bottom">300px</dimen>
<dimen name="goods_thum_size">174px</dimen>
<dimen name="goods_thum_margin_right">40px</dimen>
<dimen name="goods_recommend_margin">30px</dimen>
<dimen name="goods_category_margin_top">43px</dimen>
<dimen name="goods_category_margin_bottom">31px</dimen>
<dimen name="goods_category_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_hor">9px</dimen>
......@@ -49,6 +51,7 @@
<dimen name="goods_detail_content_margin_left">90px</dimen>
<dimen name="goods_detail_image_margin_top">50px</dimen>
<dimen name="goods_detail_spec_margin_top">25px</dimen>
<dimen name="goods_detail_rule_width">148px</dimen>
<dimen name="goods_detail_rule_margin_top">16px</dimen>
<dimen name="goods_detail_rule_margin_right">28px</dimen>
<dimen name="goods_detail_rule_padding_hor">60px</dimen>
......@@ -60,10 +63,12 @@
<dimen name="goods_detail_oper_margin_left">55px</dimen>
<dimen name="goods_detail_oper_margin_bottom">40px</dimen>
<dimen name="goods_detail_oper_margin_right">35px</dimen>
<dimen name="goods_detail_price_margin_right">3px</dimen>
<dimen name="goods_detail_butn_margin_top">28px</dimen>
<dimen name="goods_detail_butn_padding">23px</dimen>
<dimen name="goods_detail_count_margin_left">36px</dimen>
<dimen name="goods_detail_count_margin_right">40px</dimen>
<dimen name="goods_detail_indicator_margin">20px</dimen>
<dimen name="dialog_detail_width">1800px</dimen>
<dimen name="dialog_tip_width">1100px</dimen>
......@@ -72,7 +77,6 @@
<dimen name="trolley_width">850px</dimen>
<dimen name="trolley_item_height">210px</dimen>
<dimen name="trolley_bar_height">195px</dimen>
<dimen name="trolley_bar_goods_margin">400px</dimen>
<dimen name="trolley_pay_width">385px</dimen>
<dimen name="trolley_ic_margin_left">80px</dimen>
<dimen name="trolley_ic_parent_width">110px</dimen>
......@@ -96,6 +100,8 @@
<dimen name="trolley_price_margin_top">25px</dimen>
<dimen name="trolley_price_margin_left">11px</dimen>
<dimen name="trolley_count_margin">28px</dimen>
<dimen name="trolley_oper_margin">20px</dimen>
<dimen name="confirm_order_width">1000px</dimen>
<dimen name="confirm_order_padding_top">62px</dimen>
<dimen name="confirm_order_padding_bottom">37px</dimen>
......
......@@ -8,18 +8,20 @@
<dimen name="toast_width">376px</dimen>
<dimen name="toast_padding_hor">32px</dimen>
<dimen name="toast_padding_ver">55px</dimen>
<dimen name="recommend_padding">5dp</dimen>
<dimen name="recommend_name_margin_top">82px</dimen>
<dimen name="recommend_name_margin_left">68px</dimen>
<dimen name="recommend_desc_margin_top">30px</dimen>
<dimen name="recommend_desc_margin_left">68px</dimen>
<dimen name="goods_padding_ver">30px</dimen>
<dimen name="goods_padding_right">38px</dimen>
<dimen name="goods_padding_bottom">50px</dimen>
<dimen name="goods_last_padding_bottom">400px</dimen>
<dimen name="goods_thum_size">80dp</dimen>
<dimen name="goods_thum_margin_right">10dp</dimen>
<dimen name="goods_recommend_margin">5dp</dimen>
<dimen name="goods_category_margin_top">20dp</dimen>
<dimen name="goods_category_margin_bottom">20dp</dimen>
<dimen name="goods_category_margin_top">10dp</dimen>
<dimen name="goods_tag_margin_top">3dp</dimen>
<dimen name="goods_tag_padding_ver">3px</dimen>
<dimen name="goods_tag_padding_hor">9px</dimen>
......@@ -49,6 +51,7 @@
<dimen name="goods_detail_content_margin_left">40px</dimen>
<dimen name="goods_detail_image_margin_top">50px</dimen>
<dimen name="goods_detail_spec_margin_top">25px</dimen>
<dimen name="goods_detail_rule_width">80dp</dimen>
<dimen name="goods_detail_rule_margin_top">28px</dimen>
<dimen name="goods_detail_rule_margin_right">16px</dimen>
<dimen name="goods_detail_rule_padding_hor">60px</dimen>
......@@ -60,10 +63,12 @@
<dimen name="goods_detail_oper_margin_left">55px</dimen>
<dimen name="goods_detail_oper_margin_bottom">28px</dimen>
<dimen name="goods_detail_oper_margin_right">35px</dimen>
<dimen name="goods_detail_price_margin_right">3px</dimen>
<dimen name="goods_detail_butn_margin_top">28px</dimen>
<dimen name="goods_detail_butn_padding">23px</dimen>
<dimen name="goods_detail_count_margin_left">36px</dimen>
<dimen name="goods_detail_count_margin_right">40px</dimen>
<dimen name="goods_detail_indicator_margin">20px</dimen>
<dimen name="dialog_detail_width">600dp</dimen>
<dimen name="dialog_tip_width">600dp</dimen>
......@@ -72,7 +77,6 @@
<dimen name="trolley_width">400dp</dimen>
<dimen name="trolley_item_height">100dp</dimen>
<dimen name="trolley_bar_height">60dp</dimen>
<dimen name="trolley_bar_goods_margin">300dp</dimen>
<dimen name="trolley_pay_width">150dp</dimen>
<dimen name="trolley_ic_margin_left">80px</dimen>
<dimen name="trolley_ic_parent_width">110px</dimen>
......@@ -96,6 +100,8 @@
<dimen name="trolley_price_margin_top">25px</dimen>
<dimen name="trolley_price_margin_left">11px</dimen>
<dimen name="trolley_count_margin">28px</dimen>
<dimen name="trolley_oper_margin">20px</dimen>
<dimen name="confirm_order_width">1000px</dimen>
<dimen name="confirm_order_padding_top">62px</dimen>
<dimen name="confirm_order_padding_bottom">37px</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