use of com.litingzhe.justandroid.main.model.GoodsInfo in project JustAndroid by chinaltz.
the class ShopFragment method setCartNum.
// @Override
// protected void onResume() {
// super.onResume();
// setCartNum();
// }
/**
* 设置购物车产品数量
*/
private void setCartNum() {
int count = 0;
for (int i = 0; i < groups.size(); i++) {
groups.get(i).setChoosed(allChekbox.isChecked());
StoreInfo group = groups.get(i);
List<GoodsInfo> childs = children.get(group.getId());
for (GoodsInfo goodsInfo : childs) {
count += 1;
}
}
//购物车已清空
if (count == 0) {
clearCart();
} else {
}
}
use of com.litingzhe.justandroid.main.model.GoodsInfo in project JustAndroid by chinaltz.
the class ShopFragment method checkChild.
@Override
public void checkChild(int groupPosition, int childPosiTion, boolean isChecked) {
// 判断改组下面的所有子元素是否是同一种状态
boolean allChildSameState = true;
StoreInfo group = groups.get(groupPosition);
List<GoodsInfo> childs = children.get(group.getId());
for (int i = 0; i < childs.size(); i++) {
// 不全选中
if (childs.get(i).isChoosed() != isChecked) {
allChildSameState = false;
break;
}
}
//获取店铺选中商品的总金额
if (allChildSameState) {
// 如果所有子元素状态相同,那么对应的组元素被设为这种统一状态
group.setChoosed(isChecked);
} else {
// 否则,组元素一律设置为未选中状态
group.setChoosed(false);
}
if (isAllCheck()) {
// 全选
allChekbox.setChecked(true);
} else {
// 反选
allChekbox.setChecked(false);
}
selva.notifyDataSetChanged();
calculate();
}
use of com.litingzhe.justandroid.main.model.GoodsInfo in project JustAndroid by chinaltz.
the class ShopFragment method childDelete.
@Override
public void childDelete(int groupPosition, int childPosition) {
children.get(groups.get(groupPosition).getId()).remove(childPosition);
StoreInfo group = groups.get(groupPosition);
List<GoodsInfo> childs = children.get(group.getId());
if (childs.size() == 0) {
groups.remove(groupPosition);
}
selva.notifyDataSetChanged();
// handler.sendEmptyMessage(0);
calculate();
}
use of com.litingzhe.justandroid.main.model.GoodsInfo in project JustAndroid by chinaltz.
the class ShopFragment method initDatas.
/**
* 模拟数据<br>
* 遵循适配器的数据列表填充原则,组元素被放在一个List中,对应的组元素下辖的子元素被放在Map中,<br>
* 其键是组元素的Id(通常是一个唯一指定组元素身份的值)
*/
private void initDatas() {
for (int i = 0; i < 3; i++) {
groups.add(new StoreInfo(i + "", "天猫店铺" + (i + 1) + "号店"));
List<GoodsInfo> products = new ArrayList<GoodsInfo>();
for (int j = 0; j <= i; j++) {
int[] img = { R.drawable.goods1, R.drawable.goods2, R.drawable.goods3, R.drawable.goods4, R.drawable.goods5, R.drawable.goods6 };
products.add(new GoodsInfo(j + "", "商品", groups.get(i).getName() + "的第" + (j + 1) + "个商品", 12.00 + new Random().nextInt(23), new Random().nextInt(5) + 1, "豪华", "1", img[i * j], 6.00 + new Random().nextInt(13)));
}
// 将组元素的一个唯一值,这里取Id,作为子元素List的Key
children.put(groups.get(i).getId(), products);
}
}
use of com.litingzhe.justandroid.main.model.GoodsInfo in project JustAndroid by chinaltz.
the class ShopFragment method doCheckAll.
/**
* 全选与反选
*/
private void doCheckAll() {
for (int i = 0; i < groups.size(); i++) {
groups.get(i).setChoosed(allChekbox.isChecked());
StoreInfo group = groups.get(i);
List<GoodsInfo> childs = children.get(group.getId());
for (int j = 0; j < childs.size(); j++) {
childs.get(j).setChoosed(allChekbox.isChecked());
}
}
selva.notifyDataSetChanged();
calculate();
}
Aggregations