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);
}
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);
}
Aggregations