Merge "Replace com.android.internal.util.Predicate with java.util.function.Predicate"
am: 78a20be77a
Change-Id: I6f32dc27f70e4c22d25ec6bd2eec715700ebbd89
This commit is contained in:
@ -32,8 +32,6 @@ import android.view.MotionEvent.PointerCoords;
|
||||
import android.view.MotionEvent.PointerProperties;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import com.android.internal.util.Predicate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@ -261,7 +259,7 @@ class InteractionController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Runnable for use in {@link #runAndWaitForEvents(Runnable, Predicate, long) to
|
||||
* Returns a Runnable for use in {@link #runAndWaitForEvents(Runnable, AccessibilityEventFilter, long) to
|
||||
* perform a click.
|
||||
*
|
||||
* @param x coordinate
|
||||
|
@ -34,7 +34,6 @@ import android.view.accessibility.AccessibilityNodeProvider;
|
||||
import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
|
||||
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.util.Predicate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -43,6 +42,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Class for managing accessibility interactions initiated from the system
|
||||
@ -1233,7 +1233,7 @@ final class AccessibilityInteractionController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(View view) {
|
||||
public boolean test(View view) {
|
||||
if (view.getId() == mViewId && isShown(view)) {
|
||||
mInfos.add(view.createAccessibilityNodeInfo());
|
||||
}
|
||||
|
@ -103,7 +103,6 @@ import static android.os.Build.VERSION_CODES.*;
|
||||
import static java.lang.Math.max;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.util.Predicate;
|
||||
import com.android.internal.view.menu.MenuBuilder;
|
||||
import com.android.internal.widget.ScrollBarUtils;
|
||||
import com.google.android.collect.Lists;
|
||||
@ -126,6 +125,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -8778,7 +8778,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
final int id = mID;
|
||||
return root.findViewByPredicateInsideOut(this, new Predicate<View>() {
|
||||
@Override
|
||||
public boolean apply(View t) {
|
||||
public boolean test(View t) {
|
||||
return t.mNextFocusForwardId == id;
|
||||
}
|
||||
});
|
||||
@ -19349,7 +19349,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
* @return The first view that matches the predicate or null.
|
||||
*/
|
||||
protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) {
|
||||
if (predicate.apply(this)) {
|
||||
if (predicate.test(this)) {
|
||||
return this;
|
||||
}
|
||||
return null;
|
||||
@ -23639,20 +23639,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
}
|
||||
}
|
||||
|
||||
private class MatchIdPredicate implements Predicate<View> {
|
||||
private static class MatchIdPredicate implements Predicate<View> {
|
||||
public int mId;
|
||||
|
||||
@Override
|
||||
public boolean apply(View view) {
|
||||
public boolean test(View view) {
|
||||
return (view.mID == mId);
|
||||
}
|
||||
}
|
||||
|
||||
private class MatchLabelForPredicate implements Predicate<View> {
|
||||
private static class MatchLabelForPredicate implements Predicate<View> {
|
||||
private int mLabeledId;
|
||||
|
||||
@Override
|
||||
public boolean apply(View view) {
|
||||
public boolean test(View view) {
|
||||
return (view.mLabelForId == mLabeledId);
|
||||
}
|
||||
}
|
||||
|
@ -52,13 +52,13 @@ import android.view.animation.LayoutAnimationController;
|
||||
import android.view.animation.Transformation;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.util.Predicate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
|
||||
|
||||
@ -3994,7 +3994,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
||||
*/
|
||||
@Override
|
||||
protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) {
|
||||
if (predicate.apply(this)) {
|
||||
if (predicate.test(this)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,11 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
|
||||
import com.android.internal.util.Predicate;
|
||||
import com.android.internal.widget.PagerAdapter;
|
||||
import com.android.internal.widget.ViewPager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* This displays a list of months in a calendar format with selectable days.
|
||||
@ -143,7 +143,7 @@ class DayPickerViewPager extends ViewPager {
|
||||
|
||||
@Override
|
||||
protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) {
|
||||
if (predicate.apply(this)) {
|
||||
if (predicate.test(this)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ package android.widget;
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.util.Predicate;
|
||||
|
||||
import android.annotation.IdRes;
|
||||
import android.annotation.NonNull;
|
||||
@ -55,6 +54,7 @@ import android.widget.RemoteViews.RemoteView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/*
|
||||
* Implementation Notes:
|
||||
|
@ -26,8 +26,7 @@ import android.widget.ListView;
|
||||
import android.widget.HeaderViewListAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.android.internal.util.Predicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class WatchHeaderListView extends ListView {
|
||||
private View mTopPanel;
|
||||
|
@ -20,33 +20,14 @@ import android.annotation.Nullable;
|
||||
import android.provider.DocumentsContract.Document;
|
||||
|
||||
import com.android.documentsui.model.DocumentInfo;
|
||||
import com.android.internal.util.Predicate;
|
||||
|
||||
public class MimePredicate implements Predicate<DocumentInfo> {
|
||||
private final String[] mFilters;
|
||||
|
||||
private static final String APK_TYPE = "application/vnd.android.package-archive";
|
||||
public class MimePredicate {
|
||||
/**
|
||||
* MIME types that are visual in nature. For example, they should always be
|
||||
* shown as thumbnails in list mode.
|
||||
*/
|
||||
public static final String[] VISUAL_MIMES = new String[] { "image/*", "video/*" };
|
||||
|
||||
public MimePredicate(String[] filters) {
|
||||
mFilters = filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(DocumentInfo doc) {
|
||||
if (doc.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
if (mimeMatches(mFilters, doc.mimeType)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean mimeMatches(String[] filters, String[] tests) {
|
||||
if (tests == null) {
|
||||
return false;
|
||||
@ -97,10 +78,6 @@ public class MimePredicate implements Predicate<DocumentInfo> {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isApkType(@Nullable String mimeType) {
|
||||
return APK_TYPE.equals(mimeType);
|
||||
}
|
||||
|
||||
public static boolean isDirectoryType(@Nullable String mimeType) {
|
||||
return Document.MIME_TYPE_DIR.equals(mimeType);
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import android.util.Log;
|
||||
|
||||
import com.android.documentsui.model.DocumentStack;
|
||||
import com.android.documentsui.model.DurableUtils;
|
||||
import com.android.internal.util.Predicate;
|
||||
|
||||
import com.google.android.collect.Sets;
|
||||
|
||||
@ -47,6 +46,7 @@ import libcore.io.IoUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class RecentsProvider extends ContentProvider {
|
||||
private static final String TAG = "RecentsProvider";
|
||||
@ -269,7 +269,7 @@ public class RecentsProvider extends ContentProvider {
|
||||
|
||||
purgeByAuthority(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String authority) {
|
||||
public boolean test(String authority) {
|
||||
// Purge unknown authorities
|
||||
return !knownAuth.contains(authority);
|
||||
}
|
||||
@ -290,7 +290,7 @@ public class RecentsProvider extends ContentProvider {
|
||||
if (!packageAuth.isEmpty()) {
|
||||
purgeByAuthority(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean apply(String authority) {
|
||||
public boolean test(String authority) {
|
||||
// Purge authority matches
|
||||
return packageAuth.contains(authority);
|
||||
}
|
||||
@ -320,7 +320,7 @@ public class RecentsProvider extends ContentProvider {
|
||||
cursor.getColumnIndex(RecentColumns.STACK));
|
||||
DurableUtils.readFromArray(rawStack, stack);
|
||||
|
||||
if (stack.root != null && predicate.apply(stack.root.authority)) {
|
||||
if (stack.root != null && predicate.test(stack.root.authority)) {
|
||||
final String key = getCursorString(cursor, RecentColumns.KEY);
|
||||
db.delete(TABLE_RECENT, RecentColumns.KEY + "=?", new String[] { key });
|
||||
}
|
||||
@ -336,7 +336,7 @@ public class RecentsProvider extends ContentProvider {
|
||||
try {
|
||||
while (cursor.moveToNext()) {
|
||||
final String authority = getCursorString(cursor, StateColumns.AUTHORITY);
|
||||
if (predicate.apply(authority)) {
|
||||
if (predicate.test(authority)) {
|
||||
db.delete(TABLE_STATE, StateColumns.AUTHORITY + "=?", new String[] {
|
||||
authority });
|
||||
if (DEBUG) Log.d(TAG, "Purged state for " + authority);
|
||||
@ -354,7 +354,7 @@ public class RecentsProvider extends ContentProvider {
|
||||
cursor.getColumnIndex(ResumeColumns.STACK));
|
||||
DurableUtils.readFromArray(rawStack, stack);
|
||||
|
||||
if (stack.root != null && predicate.apply(stack.root.authority)) {
|
||||
if (stack.root != null && predicate.test(stack.root.authority)) {
|
||||
final String packageName = getCursorString(
|
||||
cursor, ResumeColumns.PACKAGE_NAME);
|
||||
db.delete(TABLE_RESUME, ResumeColumns.PACKAGE_NAME + "=?",
|
||||
|
@ -24,7 +24,6 @@ import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.internal.util.Predicate;
|
||||
import com.android.server.hdmi.HdmiAnnotations.IoThreadOnly;
|
||||
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
|
||||
import com.android.server.hdmi.HdmiControlService.DevicePollingCallback;
|
||||
@ -34,6 +33,7 @@ import libcore.util.EmptyArray;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Manages HDMI-CEC command and behaviors. It converts user's command into CEC command
|
||||
@ -72,7 +72,7 @@ final class HdmiCecController {
|
||||
// Predicate for whether the given logical address is remote device's one or not.
|
||||
private final Predicate<Integer> mRemoteDeviceAddressPredicate = new Predicate<Integer>() {
|
||||
@Override
|
||||
public boolean apply(Integer address) {
|
||||
public boolean test(Integer address) {
|
||||
return !isAllocatedLocalDeviceAddress(address);
|
||||
}
|
||||
};
|
||||
@ -80,7 +80,7 @@ final class HdmiCecController {
|
||||
// Predicate whether the given logical address is system audio's one or not
|
||||
private final Predicate<Integer> mSystemAudioAddressPredicate = new Predicate<Integer>() {
|
||||
@Override
|
||||
public boolean apply(Integer address) {
|
||||
public boolean test(Integer address) {
|
||||
return HdmiUtils.getTypeFromAddress(address) == Constants.ADDR_AUDIO_SYSTEM;
|
||||
}
|
||||
};
|
||||
@ -403,7 +403,7 @@ final class HdmiCecController {
|
||||
switch (iterationStrategy) {
|
||||
case Constants.POLL_ITERATION_IN_ORDER:
|
||||
for (int i = Constants.ADDR_TV; i <= Constants.ADDR_SPECIFIC_USE; ++i) {
|
||||
if (pickPredicate.apply(i)) {
|
||||
if (pickPredicate.test(i)) {
|
||||
pollingCandidates.add(i);
|
||||
}
|
||||
}
|
||||
@ -411,7 +411,7 @@ final class HdmiCecController {
|
||||
case Constants.POLL_ITERATION_REVERSE_ORDER:
|
||||
default: // The default is reverse order.
|
||||
for (int i = Constants.ADDR_SPECIFIC_USE; i >= Constants.ADDR_TV; --i) {
|
||||
if (pickPredicate.apply(i)) {
|
||||
if (pickPredicate.test(i)) {
|
||||
pollingCandidates.add(i);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.util.Arrays;
|
||||
/**
|
||||
* Predicates contains static methods for creating the standard set of
|
||||
* {@code Predicate} objects.
|
||||
* @hide
|
||||
*/
|
||||
public class Predicates {
|
||||
|
Reference in New Issue
Block a user