本文整理汇总了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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}