Skip to content

Commit

Permalink
fix: use iterator for Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
percula committed Mar 17, 2020
1 parent 1aeb254 commit 8a28acb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/src/main/java/dev/percula/ktx/Menu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package dev.percula.ktx

import android.view.Menu
import android.view.MenuItem
import androidx.core.view.forEach
import androidx.core.view.iterator

/** Performs the given action on each item in this menu. */
inline fun Menu.filter(action: (item: MenuItem) -> Boolean): List<MenuItem> {
val filteredItems = mutableListOf<MenuItem>()
this.forEach {
this.iterator().forEach {
if (action.invoke(it)) filteredItems.add(it)
}
return filteredItems
Expand Down

0 comments on commit 8a28acb

Please sign in to comment.