Skip to content

Commit

Permalink
* more adjustments to fit the updated v2.1.0 fastadapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Nov 13, 2016
1 parent a91caac commit 29dce42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
27 changes: 14 additions & 13 deletions library/src/main/java/com/mikepenz/materialdrawer/MiniDrawer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.IAdapter;
import com.mikepenz.fastadapter.adapters.FastItemAdapter;
import com.mikepenz.fastadapter.adapters.ItemAdapter;
import com.mikepenz.materialdrawer.interfaces.ICrossfader;
import com.mikepenz.materialdrawer.model.MiniDrawerItem;
Expand All @@ -36,7 +35,8 @@ public class MiniDrawer {

private LinearLayout mContainer;
private RecyclerView mRecyclerView;
protected FastItemAdapter<IDrawerItem> mAdapter;
protected FastAdapter<IDrawerItem> mAdapter;
protected ItemAdapter<IDrawerItem> mItemAdapter;

private Drawer mDrawer;

Expand Down Expand Up @@ -223,7 +223,7 @@ public FastAdapter<IDrawerItem> getAdapter() {
* @return
*/
public ItemAdapter<IDrawerItem> getItemAdapter() {
return mAdapter.getItemAdapter();
return mItemAdapter;
}

/**
Expand Down Expand Up @@ -335,11 +335,12 @@ public View build(Context ctx) {
//additional stuff
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
//adapter
mAdapter = new FastItemAdapter<>();
mAdapter = new FastAdapter<>();
mItemAdapter = new ItemAdapter<>();
mAdapter.withSelectable(true);
mAdapter.withAllowDeselection(false);
mAdapter.withPositionBasedStateManagement(mPositionBasedStateManagement);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setAdapter(mItemAdapter.wrap(mAdapter));

//if the activity with the drawer should be fullscreen add the padding for the statusbar
if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentStatusBar)) {
Expand Down Expand Up @@ -372,7 +373,7 @@ public void onProfileClick() {
if (mAccountHeader != null) {
IProfile profile = mAccountHeader.getActiveProfile();
if (profile instanceof IDrawerItem) {
mAdapter.set(0, generateMiniDrawerItem((IDrawerItem) profile));
mItemAdapter.set(0, generateMiniDrawerItem((IDrawerItem) profile));
}
}
}
Expand Down Expand Up @@ -423,13 +424,13 @@ public void setSelection(long identifier) {
* @param identifier the identifier of the item which was updated
*/
public void updateItem(long identifier) {
if (mDrawer != null && mAdapter != null && mAdapter.getAdapterItems() != null && identifier != -1) {
if (mDrawer != null && mAdapter != null && mItemAdapter.getAdapterItems() != null && identifier != -1) {
IDrawerItem drawerItem = DrawerUtils.getDrawerItem(getDrawerItems(), identifier);
for (int i = 0; i < mAdapter.getAdapterItems().size(); i++) {
if (mAdapter.getAdapterItems().get(i).getIdentifier() == drawerItem.getIdentifier()) {
for (int i = 0; i < mItemAdapter.getAdapterItems().size(); i++) {
if (mItemAdapter.getAdapterItems().get(i).getIdentifier() == drawerItem.getIdentifier()) {
IDrawerItem miniDrawerItem = generateMiniDrawerItem(drawerItem);
if (miniDrawerItem != null) {
mAdapter.set(i, miniDrawerItem);
mItemAdapter.set(i, miniDrawerItem);
}
}
}
Expand All @@ -440,13 +441,13 @@ public void updateItem(long identifier) {
* creates the items for the MiniDrawer
*/
public void createItems() {
mAdapter.clear();
mItemAdapter.clear();

int profileOffset = 0;
if (mAccountHeader != null && mAccountHeader.getAccountHeaderBuilder().mProfileImagesVisible) {
IProfile profile = mAccountHeader.getActiveProfile();
if (profile instanceof IDrawerItem) {
mAdapter.add(generateMiniDrawerItem((IDrawerItem) profile));
mItemAdapter.add(generateMiniDrawerItem((IDrawerItem) profile));
profileOffset = 1;
}
}
Expand All @@ -464,7 +465,7 @@ public void createItems() {
if (miniDrawerItem.isSelected()) {
select = position;
}
mAdapter.add(miniDrawerItem);
mItemAdapter.add(miniDrawerItem);
position = position + 1;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import android.view.View;
import android.view.ViewGroup;

import com.mikepenz.fastadapter.IDraggable;
import com.mikepenz.fastadapter.IExpandable;
import com.mikepenz.fastadapter.IItem;
import com.mikepenz.fastadapter.ISubItem;
import com.mikepenz.materialdrawer.util.DrawerImageLoader;

import java.util.List;

Expand Down Expand Up @@ -42,7 +40,7 @@ public interface IDrawerItem<T, VH extends RecyclerView.ViewHolder> extends IIte

void unbindView(VH holder);

void bindView(VH holder, List payloads);
void bindView(VH holder, List<Object> payloads);

boolean equals(long id);
}

0 comments on commit 29dce42

Please sign in to comment.