Skip to content

Commit

Permalink
* move toogleExpandable logic to the FastAdapter, change ExpandableDr…
Browse files Browse the repository at this point in the history
…awerItem as the item is already toggled at this point now, consume the event if we have an Expandable Item
  • Loading branch information
mikepenz committed Feb 24, 2016
1 parent 996ee80 commit 88e9bdf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import com.mikepenz.aboutlibraries.Libs;
import com.mikepenz.aboutlibraries.LibsBuilder;
import com.mikepenz.fastadapter.IExpandable;
import com.mikepenz.fastadapter.utils.RecyclerViewCacheUtil;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
Expand Down Expand Up @@ -158,14 +157,6 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {

if (drawerItem != null) {
Intent intent = null;

//if our drawer has collapsible items we check if the clicked items has subItem. if yes we open it
if (((IExpandable) drawerItem).getSubItems() != null) {
result.getAdapter().toggleExpandable(position);
//we consume the event and want no further handling
return true;
}

if (drawerItem.getIdentifier() == 1) {
intent = new Intent(DrawerActivity.this, CompactHeaderDrawerActivity.class);
} else if (drawerItem.getIdentifier() == 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.IAdapter;
import com.mikepenz.fastadapter.IExpandable;
import com.mikepenz.fastadapter.IItemAdapter;
import com.mikepenz.fastadapter.adapters.FooterAdapter;
import com.mikepenz.fastadapter.adapters.HeaderAdapter;
Expand Down Expand Up @@ -1672,6 +1673,13 @@ public void run() {
consumed = mMiniDrawer.onItemClick(item);
}

//if we were a expandable item we consume the event closing makes no sense
if (item instanceof IExpandable && ((IExpandable) item).getSubItems() != null) {
//we consume the event and want no further handling
return true;
}


if (!consumed) {
//close the drawer after click
closeDrawerDelayed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Drawer.OnDrawerItemClickListener getOnDrawerItemClickListener() {
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem instanceof AbstractDrawerItem && drawerItem.isEnabled()) {
if (((AbstractDrawerItem) drawerItem).getSubItems() != null) {
if (!((AbstractDrawerItem) drawerItem).isExpanded()) {
if (((AbstractDrawerItem) drawerItem).isExpanded()) {
ViewCompat.animate(view.findViewById(R.id.material_drawer_arrow)).rotation(180).start();
} else {
ViewCompat.animate(view.findViewById(R.id.material_drawer_arrow)).rotation(0).start();
Expand Down

0 comments on commit 88e9bdf

Please sign in to comment.