Search in sources :

Example 6 with StoreInfo

use of com.litingzhe.justandroid.main.model.StoreInfo 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();
}
Also used : GoodsInfo(com.litingzhe.justandroid.main.model.GoodsInfo) StoreInfo(com.litingzhe.justandroid.main.model.StoreInfo)

Example 7 with StoreInfo

use of com.litingzhe.justandroid.main.model.StoreInfo 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);
    }
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) GoodsInfo(com.litingzhe.justandroid.main.model.GoodsInfo) StoreInfo(com.litingzhe.justandroid.main.model.StoreInfo)

Example 8 with StoreInfo

use of com.litingzhe.justandroid.main.model.StoreInfo 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();
}
Also used : GoodsInfo(com.litingzhe.justandroid.main.model.GoodsInfo) StoreInfo(com.litingzhe.justandroid.main.model.StoreInfo)

Example 9 with StoreInfo

use of com.litingzhe.justandroid.main.model.StoreInfo in project JustAndroid by chinaltz.

the class ShopFragment method checkGroup.

@Override
public void checkGroup(int groupPosition, boolean isChecked) {
    StoreInfo group = groups.get(groupPosition);
    List<GoodsInfo> childs = children.get(group.getId());
    for (int i = 0; i < childs.size(); i++) {
        childs.get(i).setChoosed(isChecked);
    }
    if (isAllCheck())
        allChekbox.setChecked(true);
    else
        allChekbox.setChecked(false);
    selva.notifyDataSetChanged();
    calculate();
}
Also used : GoodsInfo(com.litingzhe.justandroid.main.model.GoodsInfo) StoreInfo(com.litingzhe.justandroid.main.model.StoreInfo)

Aggregations

StoreInfo (com.litingzhe.justandroid.main.model.StoreInfo)9 GoodsInfo (com.litingzhe.justandroid.main.model.GoodsInfo)8 ArrayList (java.util.ArrayList)2 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 CheckBox (android.widget.CheckBox)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 Random (java.util.Random)1