Search in sources :

Example 1 with DefaultExpandable

use of xyz.zpayh.adapter.DefaultExpandable in project SherlockAdapter by EvilBT.

the class ExpandableActivity method refreshData.

private void refreshData() {
    List<IMultiItem> oldData = mAdapter.getData();
    List<IMultiItem> data = new ArrayList<>();
    data.addAll(oldData);
    Collections.reverse(data);
    DefaultExpandable expandable = (DefaultExpandable) data.get(1);
    Collections.reverse(expandable.getSubItems());
    expandable = (DefaultExpandable) data.get(2);
    Collections.reverse(expandable.getSubItems());
    mAdapter.setData(data);
}
Also used : ArrayList(java.util.ArrayList) DefaultExpandable(xyz.zpayh.adapter.DefaultExpandable) IMultiItem(xyz.zpayh.adapter.IMultiItem)

Example 2 with DefaultExpandable

use of xyz.zpayh.adapter.DefaultExpandable in project SherlockAdapter by EvilBT.

the class ExpandableActivity method initData.

private void initData() {
    int width = getResources().getDisplayMetrics().widthPixels / mStaggeredGridLayoutManager.getSpanCount();
    List<IMultiItem> data = new ArrayList<>();
    for (int i = 0; i < mLabels.length; i++) {
        ImageLabel label = new ImageLabel(mLabels[i]);
        data.add(label);
    }
    // Add animals
    List<IMultiItem> animalData = new ArrayList<>(2);
    for (int i = 0; i < mAnimalIds.length; i++) {
        ImageCard cardData = new ImageCard(mAnimalIds[i], mAnimalTitles[i]);
        Card card = new Card(width, cardData);
        animalData.add(card);
    }
    ((DefaultExpandable) data.get(0)).addSubData(animalData);
    // Add beauties
    List<IMultiItem> beautyData = new ArrayList<>(mBeautyIds.length);
    for (int i = 0; i < mBeautyIds.length; i++) {
        ImageCard cardData = new ImageCard(mBeautyIds[i], mBeautyTitles[i]);
        Card card = new Card(width, cardData);
        beautyData.add(card);
    }
    ((DefaultExpandable) data.get(1)).addSubData(beautyData);
    // Add scenery
    List<IMultiItem> sceneryData = new ArrayList<>(mSceneryIds.length);
    for (int i = 0; i < mSceneryIds.length; i++) {
        ImageCard cardData = new ImageCard(mSceneryIds[i], mSceneryTitles[i]);
        Card card = new Card(width, cardData);
        sceneryData.add(card);
    }
    ((DefaultExpandable) data.get(2)).addSubData(sceneryData);
    // Add tranquil
    List<IMultiItem> tranquilData = new ArrayList<>(mTranquilIds.length);
    for (int i = 0; i < mTranquilIds.length; i++) {
        ImageCard cardData = new ImageCard(mTranquilIds[i], mTranquilTitles[i]);
        Card card = new Card(width, cardData);
        tranquilData.add(card);
    }
    ((DefaultExpandable) data.get(3)).addSubData(tranquilData);
    mAdapter.setData(data);
}
Also used : ImageLabel(xyz.zpayh.myadapter.data.ImageLabel) ArrayList(java.util.ArrayList) ImageCard(xyz.zpayh.myadapter.data.ImageCard) DefaultExpandable(xyz.zpayh.adapter.DefaultExpandable) IMultiItem(xyz.zpayh.adapter.IMultiItem) Card(xyz.zpayh.myadapter.data.Card) ImageCard(xyz.zpayh.myadapter.data.ImageCard)

Aggregations

ArrayList (java.util.ArrayList)2 DefaultExpandable (xyz.zpayh.adapter.DefaultExpandable)2 IMultiItem (xyz.zpayh.adapter.IMultiItem)2 Card (xyz.zpayh.myadapter.data.Card)1 ImageCard (xyz.zpayh.myadapter.data.ImageCard)1 ImageLabel (xyz.zpayh.myadapter.data.ImageLabel)1