Skip to content
This repository was archived by the owner on Jan 30, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class FloatingActionMenu {
private MenuAnimationHandler animationHandler;
/** Reference to a listener that listens open/close actions */
private MenuStateChangeListener stateChangeListener;
/** Reference to a listener that listens click sub action button */
private OnSubActionButtonClickListener subButtonClickListener;
/** whether the openings and closings should be animated or not */
private boolean animated;
/** whether the menu is currently open or not */
Expand Down Expand Up @@ -108,7 +110,9 @@ public FloatingActionMenu(final View mainActionView,
}

// Find items with undefined sizes
for(final Item item : subActionItems) {
for (int i = 0; i < subActionItems.size(); i++) {
final int index = i;
Item item = subActionItems.get(i);
if(item.width == 0 || item.height == 0) {
if(systemOverlay) {
throw new RuntimeException("Sub action views cannot be added without " +
Expand All @@ -122,6 +126,14 @@ public FloatingActionMenu(final View mainActionView,
// Wait for the right time
item.view.post(new ItemViewQueueListener(item));
}
item.view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(subButtonClickListener != null){
subButtonClickListener.onSubButtonClick(FloatingActionMenu.this, index);
}
}
});
}

if(systemOverlay) {
Expand Down Expand Up @@ -513,6 +525,10 @@ public void setStateChangeListener(MenuStateChangeListener listener) {
this.stateChangeListener = listener;
}

public void setOnSubButtonClickListener(OnSubActionButtonClickListener listener) {
this.subButtonClickListener = listener;
}

/**
* A simple click listener used by the main action view
*/
Expand Down Expand Up @@ -587,6 +603,13 @@ public static interface MenuStateChangeListener {
public void onMenuClosed(FloatingActionMenu menu);
}

/**
* A listener to listen click of sub action button
*/
public static interface OnSubActionButtonClickListener {
public void onSubButtonClick(FloatingActionMenu menu,int index);
}

/**
* A builder for {@link FloatingActionMenu} in conventional Java Builder format
*/
Expand Down