Commit f44c9f91 by wjg

修改推荐、特惠bug

parent ef3fc397
......@@ -142,13 +142,12 @@ public class LauncherActivity extends Activity {
private void setRecommendsData() {
List<Recommend> recommends = HLApplication.getMainData().getRecommends();
scrollRecommends = new ArrayList<>();
if (CollectionUtils.isEmpty(recommends)) {
return;
}
for (int i = 0; i < recommends.size(); i++) {
Recommend x = recommends.get(i);
x.setIndex(i);
scrollRecommends.add(new ScrollBean(new ScrollBean.ScrollItemBean(x, null)));
if (!CollectionUtils.isEmpty(recommends)) {
for (int i = 0; i < recommends.size(); i++) {
Recommend x = recommends.get(i);
x.setIndex(i);
scrollRecommends.add(new ScrollBean(new ScrollBean.ScrollItemBean(x, null)));
}
}
recommendAdapter.setNewData(scrollRecommends);
}
......@@ -270,31 +269,30 @@ public class LauncherActivity extends Activity {
private void initCategorys() {
groupCategory.removeAllViews();
List<Category> categorys = HLApplication.getMainData().getCategorys();
if (CollectionUtils.isEmpty(categorys)) {
return;
}
for (int i = 0; i < categorys.size(); i++) {
Category category = categorys.get(i);
if (CollectionUtils.isEmpty(category.getGoods())) {
continue;
}
RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(RadioGroup.LayoutParams.MATCH_PARENT, RadioGroup.LayoutParams.WRAP_CONTENT);
RadioButton view = (RadioButton) this.getLayoutInflater().inflate(R.layout.item_category, null);
view.setText(category.getName());
view.setId(category.getId());
view.setTag(category);
if (i == 0) {
view.setChecked(true);
view.getPaint().setFakeBoldText(true);
if (!CollectionUtils.isEmpty(categorys)) {
for (int i = 0; i < categorys.size(); i++) {
Category category = categorys.get(i);
if (CollectionUtils.isEmpty(category.getGoods())) {
continue;
}
RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(RadioGroup.LayoutParams.MATCH_PARENT, RadioGroup.LayoutParams.WRAP_CONTENT);
RadioButton view = (RadioButton) this.getLayoutInflater().inflate(R.layout.item_category, null);
view.setText(category.getName());
view.setId(category.getId());
view.setTag(category);
if (i == 0) {
view.setChecked(true);
view.getPaint().setFakeBoldText(true);
}
groupCategory.addView(view, layoutParams);
view.setOnClickListener(v -> {
Integer checkedId = v.getId();
Category tagCategory = (Category) groupCategory.findViewById(checkedId).getTag();
int position = categorys.indexOf(tagCategory);
goodsLayoutManager.scrollToPositionWithOffset(tPosition.get(position), 0);
});
}
groupCategory.addView(view, layoutParams);
view.setOnClickListener(v -> {
Integer checkedId = v.getId();
Category tagCategory = (Category) groupCategory.findViewById(checkedId).getTag();
int position = categorys.indexOf(tagCategory);
goodsLayoutManager.scrollToPositionWithOffset(tPosition.get(position), 0);
});
}
groupCategory.setOnCheckedChangeListener((group, checkedId) -> {
for (int i = 0; i < groupCategory.getChildCount(); i++) {
......
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