Skip to content

Commit

Permalink
Merge pull request #17 from Envative/master
Browse files Browse the repository at this point in the history
Added methods to remove OnSegmentClickListener and OnSegmentSelectListener
  • Loading branch information
RobertApikyan authored Feb 7, 2019
2 parents 0ddf259 + 87aa277 commit 2201946
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,26 @@ void addOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener)
onSegmentClickListeners.add(onSegmentClickListener);
}

void removeOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {
onSegmentClickListeners = lazy(onSegmentClickListeners, new ArrayList<OnSegmentClickListener<D>>());
onSegmentClickListeners.remove(onSegmentClickListener);
}

void addOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {
onSegmentSelectedListeners = lazy(onSegmentSelectedListeners, new ArrayList<OnSegmentSelectedListener<D>>());
onSegmentSelectedListeners.add(onSegmentSelectedListener);
}

void removeOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {
onSegmentSelectedListeners = lazy(onSegmentSelectedListeners, new ArrayList<OnSegmentSelectedListener<D>>());
onSegmentSelectedListeners.remove(onSegmentSelectedListener);
}

void setOnSegmentSelectRequestListener(OnSegmentSelectRequestListener<D> onSegmentSelectRequestListener) {
this.onSegmentSelectRequestListener = onSegmentSelectRequestListener;
}


private <T> void onEvent(List<T> eventListeners, Consumer<T> listenerConsumer) {
if (eventListeners != null && eventListeners.size() != 0) {
for (T t : eventListeners) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,16 @@ public void addOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickLi
getControllerComponent().addOnSegmentClickListener(onSegmentClickListener);
}

/**
* @param onSegmentClickListener, every time click event will be notified,
* even if the segment is already selected
*
* Remove listener
*/
public void removeOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {
getControllerComponent().removeOnSegmentClickListener(onSegmentClickListener);
}

/**
* @param onSegmentSelectedListener, event will be notified, when segment is selected and unSelected and reselected,
* for more info check out {@link OnSegmentSelectedListener} class
Expand All @@ -401,6 +411,16 @@ public void addOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSel
getControllerComponent().addOnSegmentSelectListener(onSegmentSelectedListener);
}

/**
* @param onSegmentSelectedListener, event will be notified, when segment is selected and unSelected and reselected,
* for more info check out {@link OnSegmentSelectedListener} class
*
* Remove listener
*/
public void removeOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {
getControllerComponent().removeOnSegmentSelectListener(onSegmentSelectedListener);
}

/**
* @param onSegmentSelectRequestListener, event will be triggered after click event and before selection event
* for more info click out {@link OnSegmentSelectRequestListener} class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,18 @@ void addOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener)
notifier.addOnSegmentClickListener(onSegmentClickListener);
}

void removeOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {
notifier.removeOnSegmentClickListener(onSegmentClickListener);
}

void addOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {
notifier.addOnSegmentSelectListener(onSegmentSelectedListener);
}

void removeOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {
notifier.removeOnSegmentSelectListener(onSegmentSelectedListener);
}

void setOnSegmentSelectRequestListener(OnSegmentSelectRequestListener<D> onSegmentSelectRequestListener) {
notifier.setOnSegmentSelectRequestListener(onSegmentSelectRequestListener);
}
Expand Down

0 comments on commit 2201946

Please sign in to comment.