Java Code Examples for com.android.internal.util.Predicate#apply()

The following examples show how to use com.android.internal.util.Predicate#apply() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactTestHelper.java    From react-native-GPay with MIT License 6 votes vote down vote up
private static View findChild(View root, Predicate<View> predicate) {
  if (predicate.apply(root)) {
    return root;
  }
  if (root instanceof ViewGroup) {
    ViewGroup viewGroup = (ViewGroup) root;
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
      View child = viewGroup.getChildAt(i);
      View result = findChild(child, predicate);
      if (result != null) {
        return result;
      }
    }
  }
  return null;
}
 
Example 2
Source File: Lists.java    From lockit with Apache License 2.0 5 votes vote down vote up
public static <T> List<T> filter(List<T> list, Predicate<T> predicate) {
    List<T> filteredList = new ArrayList<>();
    for (T t : list)
        if (predicate.apply(t))
            filteredList.add(t);
    return filteredList;
}
 
Example 3
Source File: MutableArrayList.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
public T find(Predicate<T> predicate) {
    for (T element : this) {
        if (predicate.apply(element)) {
            return element;
        }
    }

    return null;
}
 
Example 4
Source File: MutableArrayList.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
public List<T> findAll(Predicate<T> predicate) {
    List<T> results = new ArrayList<>(size());
    for (T element : this) {
        if (predicate.apply(element)) {
            results.add(element);
        }
    }

    return results;
}
 
Example 5
Source File: MutableArrayList.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
public void filter(Predicate<T> predicate) {
    this.mFilter = predicate;
    super.clear();

    if ( predicate == null ) {
        super.clear();
        super.addAll(mOriginalList);
    } else {
        for (T element : mOriginalList) {
            if (predicate.apply(element)) {
                super.add(element);
            }
        }
    }
}
 
Example 6
Source File: AppsGamesCatalogFragment.java    From 4pdaClient-plus with Apache License 2.0 5 votes vote down vote up
private ArrayList<AppGameCatalog> getFilteredList(Predicate<AppGameCatalog> predicate) {
    ArrayList<AppGameCatalog> res = new ArrayList<>();
    for (AppGameCatalog item : mCatalogData) {
        if (!predicate.apply(item)) continue;
        res.add(item);
    }
    return res;
}
 
Example 7
Source File: DigestCatalogFragment.java    From 4pdaClient-plus with Apache License 2.0 5 votes vote down vote up
private ArrayList<DigestCatalog> getFilteredList(Predicate<DigestCatalog> predicate) {
    ArrayList<DigestCatalog> res = new ArrayList<>();
    for (DigestCatalog item : mCatalogData) {
        if (!predicate.apply(item)) continue;
        res.add(item);
    }
    return res;
}
 
Example 8
Source File: Map.java    From Tanks with MIT License 5 votes vote down vote up
private static <T> T find(Collection<T> collection, Predicate<T> predicate)
{
  for (T current : collection)
    if (predicate.apply(current))
      return current;
  return null;
}
 
Example 9
Source File: Utils.java    From conference-app with Apache License 2.0 5 votes vote down vote up
public static <T> ArrayList<T> filter(Collection<T> target, Predicate<T> predicate) {
    ArrayList<T> result = new ArrayList<T>();
    for (T element: target) {
        if (predicate.apply(element)) {
            result.add(element);
        }
    }
    return result;
}