当前位置: 首页>>代码示例>>Java>>正文


Java Predicate.apply方法代码示例

本文整理汇总了Java中com.android.internal.util.Predicate.apply方法的典型用法代码示例。如果您正苦于以下问题:Java Predicate.apply方法的具体用法?Java Predicate.apply怎么用?Java Predicate.apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.internal.util.Predicate的用法示例。


在下文中一共展示了Predicate.apply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findChild

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:ReactTestHelper.java

示例2: tossOne

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
T tossOne(Predicate<T> predicate) {
    List<T> filtered;
    if (predicate == null) {
        filtered = getSamples();
    } else {
        filtered = new ArrayList<>();
        for (T i : getSamples()) {
            if (predicate.apply(i)) {
                filtered.add(i);
            }
        }
    }
    if (filtered.size() <= 0) {
        throw new IllegalArgumentException("No samples found that match the predicate");
    }
    int idx = mRandom.nextInt(filtered.size());
    return filtered.get(idx);
}
 
开发者ID:jimulabs,项目名称:mirror-sandbox,代码行数:19,代码来源:MockData.java

示例3: showProgressDialogWhile

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
public static void showProgressDialogWhile(final Context context, final Predicate<Void> predicate, final Runnable callback) {
    if (predicate.apply(null)) {
        callback.run();
    } else {
        final ProgressDialog progressDialog = showProgressDialog(context);
        Runnable predicateVerifier = new Runnable() {
            public void run() {
                if (predicate.apply(null)) {
                    Tasks.runDelayed(this, 100);
                } else {
                    progressDialog.dismiss();
                    callback.run();
                }
            }
        };
        Tasks.runDelayed(predicateVerifier, 100);
    }
}
 
开发者ID:openforis,项目名称:collect-mobile,代码行数:19,代码来源:Dialogs.java

示例4: getMatchingEntries

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
/** Gets the all matching elements. */
public synchronized ArrayList<LinkedHashMap.Entry<K, V>> getMatchingEntries(
    @Nullable Predicate<K> predicate) {
  ArrayList<LinkedHashMap.Entry<K, V>> matchingEntries = new ArrayList<>(mMap.entrySet().size());
  for (LinkedHashMap.Entry<K, V> entry : mMap.entrySet()) {
    if (predicate == null || predicate.apply(entry.getKey())) {
      matchingEntries.add(entry);
    }
  }
  return matchingEntries;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:CountingLruMap.java

示例5: removeAll

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
/** Removes all the matching elements from the map. */
public synchronized ArrayList<V> removeAll(@Nullable Predicate<K> predicate) {
  ArrayList<V> oldValues = new ArrayList<>();
  Iterator<LinkedHashMap.Entry<K, V>> iterator = mMap.entrySet().iterator();
  while (iterator.hasNext()) {
    LinkedHashMap.Entry<K, V> entry = iterator.next();
    if (predicate == null || predicate.apply(entry.getKey())) {
      oldValues.add(entry.getValue());
      mSizeInBytes -= getValueSizeInBytes(entry.getValue());
      iterator.remove();
    }
  }
  return oldValues;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:CountingLruMap.java

示例6: filter

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
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;
}
 
开发者ID:shivamsingh,项目名称:lockit,代码行数:8,代码来源:Lists.java

示例7: filter

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
private static <T> List<T> filter(
    @NonNull final List<T> origin,
    @NonNull final Predicate<T> predicate
) {
    final List<T> res = new LinkedList<>();
    for (T item : origin) {
        if (predicate.apply(item)) {
            res.add(item);
        }
    }
    return res;
}
 
开发者ID:g4s8,项目名称:Android-Migrator,代码行数:13,代码来源:ListFilter.java

示例8: find

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
public T find(Predicate<T> predicate) {
    for (T element : this) {
        if (predicate.apply(element)) {
            return element;
        }
    }

    return null;
}
 
开发者ID:timothymiko,项目名称:narrate-android,代码行数:10,代码来源:MutableArrayList.java

示例9: findAll

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
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;
}
 
开发者ID:timothymiko,项目名称:narrate-android,代码行数:11,代码来源:MutableArrayList.java

示例10: filter

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
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);
            }
        }
    }
}
 
开发者ID:timothymiko,项目名称:narrate-android,代码行数:16,代码来源:MutableArrayList.java

示例11: filter

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
public EntityList filter(Predicate<Entity> predicate) {
    EntityList list = new EntityList();
    for (Entity entity : this) {
        if (predicate.apply(entity)) {
            list.add(entity);
        }
    }
    return list;
}
 
开发者ID:HearthSim,项目名称:arcane_tracker,代码行数:10,代码来源:EntityList.java

示例12: getEntityList

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
public EntityList getEntityList(Predicate<Entity> predicate) {
    EntityList entityList = new EntityList();
    for (Entity entity: entityMap.values()) {
        if (predicate.apply(entity)) {
            entityList.add(entity);
        }
    }

    return entityList;
}
 
开发者ID:HearthSim,项目名称:arcane_tracker,代码行数:11,代码来源:Game.java

示例13: indexOf

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
/**
 * 获得符合mattcher的第一个元素的下标
 * 下标将从0开始计算
 *
 * @param mattcher 匹配器
 * @return 返回与mattcher匹配的第一个元素的下标,如果集合中没有匹配项,则返回-1
 */
public int indexOf(Predicate<E> mattcher) {
    int index = 0;
    for (E e : backingList) {
        if (mattcher.apply(e)) return index;
        index++;
    }
    return -1;
}
 
开发者ID:HyperSimon,项目名称:RoseBase,代码行数:16,代码来源:RoseList.java

示例14: removeEvent

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
/**
 * Removes all events that was filtered by given predicate.
 * Changes will be saved when {@link TimeToAct#storeEventData()} will be called.
 *
 * @param eventPredicate predicate to filter events. Must be not null.
 */
public final void removeEvent(@NonNull Predicate<ActEvent> eventPredicate) {
    for(ActEvent event : eventMap.values()) {
        if(eventPredicate.apply(event)) {
            removeEvent(event);
        }
    }
}
 
开发者ID:seroperson,项目名称:itstimetoact,代码行数:14,代码来源:TimeToAct.java

示例15: getEventSet

import com.android.internal.util.Predicate; //导入方法依赖的package包/类
/**
 * Returns all events that was filtered by given predicate.
 *
 * @param eventPredicate predicate to filter events. Must be not null.
 *
 * @return set of events filtered by given predicate.
 */
@NonNull
public final Set<ActEvent> getEventSet(@NonNull Predicate<ActEvent> eventPredicate) {
    Set<ActEvent> result = new HashSet<ActEvent>();
    for(ActEvent event : eventMap.values()) {
        if(eventPredicate.apply(event)) {
            result.add(event);
        }
    }
    return result;
}
 
开发者ID:seroperson,项目名称:itstimetoact,代码行数:18,代码来源:TimeToAct.java


注:本文中的com.android.internal.util.Predicate.apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。