Merge "Replace com.android.internal.util.Predicate with java.util.function.Predicate"

am: 78a20be77a

Change-Id: I6f32dc27f70e4c22d25ec6bd2eec715700ebbd89
This commit is contained in:
Paul Duffin
2017-02-08 18:14:50 +00:00
committed by android-build-merger
13 changed files with 29 additions and 54 deletions

View File

@ -32,8 +32,6 @@ import android.view.MotionEvent.PointerCoords;
import android.view.MotionEvent.PointerProperties; import android.view.MotionEvent.PointerProperties;
import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent;
import com.android.internal.util.Predicate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeoutException; 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. * perform a click.
* *
* @param x coordinate * @param x coordinate

View File

@ -34,7 +34,6 @@ import android.view.accessibility.AccessibilityNodeProvider;
import android.view.accessibility.IAccessibilityInteractionConnectionCallback; import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
import com.android.internal.os.SomeArgs; import com.android.internal.os.SomeArgs;
import com.android.internal.util.Predicate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -43,6 +42,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.function.Predicate;
/** /**
* Class for managing accessibility interactions initiated from the system * Class for managing accessibility interactions initiated from the system
@ -1233,7 +1233,7 @@ final class AccessibilityInteractionController {
} }
@Override @Override
public boolean apply(View view) { public boolean test(View view) {
if (view.getId() == mViewId && isShown(view)) { if (view.getId() == mViewId && isShown(view)) {
mInfos.add(view.createAccessibilityNodeInfo()); mInfos.add(view.createAccessibilityNodeInfo());
} }

View File

@ -103,7 +103,6 @@ import static android.os.Build.VERSION_CODES.*;
import static java.lang.Math.max; import static java.lang.Math.max;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.util.Predicate;
import com.android.internal.view.menu.MenuBuilder; import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.widget.ScrollBarUtils; import com.android.internal.widget.ScrollBarUtils;
import com.google.android.collect.Lists; import com.google.android.collect.Lists;
@ -126,6 +125,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
/** /**
* <p> * <p>
@ -8778,7 +8778,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
final int id = mID; final int id = mID;
return root.findViewByPredicateInsideOut(this, new Predicate<View>() { return root.findViewByPredicateInsideOut(this, new Predicate<View>() {
@Override @Override
public boolean apply(View t) { public boolean test(View t) {
return t.mNextFocusForwardId == id; 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. * @return The first view that matches the predicate or null.
*/ */
protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) { protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) {
if (predicate.apply(this)) { if (predicate.test(this)) {
return this; return this;
} }
return null; 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; public int mId;
@Override @Override
public boolean apply(View view) { public boolean test(View view) {
return (view.mID == mId); return (view.mID == mId);
} }
} }
private class MatchLabelForPredicate implements Predicate<View> { private static class MatchLabelForPredicate implements Predicate<View> {
private int mLabeledId; private int mLabeledId;
@Override @Override
public boolean apply(View view) { public boolean test(View view) {
return (view.mLabelForId == mLabeledId); return (view.mLabelForId == mLabeledId);
} }
} }

View File

@ -52,13 +52,13 @@ import android.view.animation.LayoutAnimationController;
import android.view.animation.Transformation; import android.view.animation.Transformation;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.util.Predicate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Predicate;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
@ -3994,7 +3994,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*/ */
@Override @Override
protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) { protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) {
if (predicate.apply(this)) { if (predicate.test(this)) {
return this; return this;
} }

View File

@ -25,11 +25,11 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import com.android.internal.util.Predicate;
import com.android.internal.widget.PagerAdapter; import com.android.internal.widget.PagerAdapter;
import com.android.internal.widget.ViewPager; import com.android.internal.widget.ViewPager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.function.Predicate;
/** /**
* This displays a list of months in a calendar format with selectable days. * This displays a list of months in a calendar format with selectable days.
@ -143,7 +143,7 @@ class DayPickerViewPager extends ViewPager {
@Override @Override
protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) { protected View findViewByPredicateTraversal(Predicate<View> predicate, View childToSkip) {
if (predicate.apply(this)) { if (predicate.test(this)) {
return this; return this;
} }

View File

@ -19,7 +19,6 @@ package android.widget;
import com.google.android.collect.Lists; import com.google.android.collect.Lists;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.util.Predicate;
import android.annotation.IdRes; import android.annotation.IdRes;
import android.annotation.NonNull; import android.annotation.NonNull;
@ -55,6 +54,7 @@ import android.widget.RemoteViews.RemoteView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
/* /*
* Implementation Notes: * Implementation Notes:

View File

@ -26,8 +26,7 @@ import android.widget.ListView;
import android.widget.HeaderViewListAdapter; import android.widget.HeaderViewListAdapter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.function.Predicate;
import com.android.internal.util.Predicate;
public class WatchHeaderListView extends ListView { public class WatchHeaderListView extends ListView {
private View mTopPanel; private View mTopPanel;

View File

@ -20,33 +20,14 @@ import android.annotation.Nullable;
import android.provider.DocumentsContract.Document; import android.provider.DocumentsContract.Document;
import com.android.documentsui.model.DocumentInfo; import com.android.documentsui.model.DocumentInfo;
import com.android.internal.util.Predicate;
public class MimePredicate implements Predicate<DocumentInfo> { public class MimePredicate {
private final String[] mFilters;
private static final String APK_TYPE = "application/vnd.android.package-archive";
/** /**
* MIME types that are visual in nature. For example, they should always be * MIME types that are visual in nature. For example, they should always be
* shown as thumbnails in list mode. * shown as thumbnails in list mode.
*/ */
public static final String[] VISUAL_MIMES = new String[] { "image/*", "video/*" }; 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) { public static boolean mimeMatches(String[] filters, String[] tests) {
if (tests == null) { if (tests == null) {
return false; 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) { public static boolean isDirectoryType(@Nullable String mimeType) {
return Document.MIME_TYPE_DIR.equals(mimeType); return Document.MIME_TYPE_DIR.equals(mimeType);
} }

View File

@ -39,7 +39,6 @@ import android.util.Log;
import com.android.documentsui.model.DocumentStack; import com.android.documentsui.model.DocumentStack;
import com.android.documentsui.model.DurableUtils; import com.android.documentsui.model.DurableUtils;
import com.android.internal.util.Predicate;
import com.google.android.collect.Sets; import com.google.android.collect.Sets;
@ -47,6 +46,7 @@ import libcore.io.IoUtils;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate;
public class RecentsProvider extends ContentProvider { public class RecentsProvider extends ContentProvider {
private static final String TAG = "RecentsProvider"; private static final String TAG = "RecentsProvider";
@ -269,7 +269,7 @@ public class RecentsProvider extends ContentProvider {
purgeByAuthority(new Predicate<String>() { purgeByAuthority(new Predicate<String>() {
@Override @Override
public boolean apply(String authority) { public boolean test(String authority) {
// Purge unknown authorities // Purge unknown authorities
return !knownAuth.contains(authority); return !knownAuth.contains(authority);
} }
@ -290,7 +290,7 @@ public class RecentsProvider extends ContentProvider {
if (!packageAuth.isEmpty()) { if (!packageAuth.isEmpty()) {
purgeByAuthority(new Predicate<String>() { purgeByAuthority(new Predicate<String>() {
@Override @Override
public boolean apply(String authority) { public boolean test(String authority) {
// Purge authority matches // Purge authority matches
return packageAuth.contains(authority); return packageAuth.contains(authority);
} }
@ -320,7 +320,7 @@ public class RecentsProvider extends ContentProvider {
cursor.getColumnIndex(RecentColumns.STACK)); cursor.getColumnIndex(RecentColumns.STACK));
DurableUtils.readFromArray(rawStack, 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); final String key = getCursorString(cursor, RecentColumns.KEY);
db.delete(TABLE_RECENT, RecentColumns.KEY + "=?", new String[] { key }); db.delete(TABLE_RECENT, RecentColumns.KEY + "=?", new String[] { key });
} }
@ -336,7 +336,7 @@ public class RecentsProvider extends ContentProvider {
try { try {
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
final String authority = getCursorString(cursor, StateColumns.AUTHORITY); final String authority = getCursorString(cursor, StateColumns.AUTHORITY);
if (predicate.apply(authority)) { if (predicate.test(authority)) {
db.delete(TABLE_STATE, StateColumns.AUTHORITY + "=?", new String[] { db.delete(TABLE_STATE, StateColumns.AUTHORITY + "=?", new String[] {
authority }); authority });
if (DEBUG) Log.d(TAG, "Purged state for " + authority); if (DEBUG) Log.d(TAG, "Purged state for " + authority);
@ -354,7 +354,7 @@ public class RecentsProvider extends ContentProvider {
cursor.getColumnIndex(ResumeColumns.STACK)); cursor.getColumnIndex(ResumeColumns.STACK));
DurableUtils.readFromArray(rawStack, 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( final String packageName = getCursorString(
cursor, ResumeColumns.PACKAGE_NAME); cursor, ResumeColumns.PACKAGE_NAME);
db.delete(TABLE_RESUME, ResumeColumns.PACKAGE_NAME + "=?", db.delete(TABLE_RESUME, ResumeColumns.PACKAGE_NAME + "=?",

View File

@ -24,7 +24,6 @@ import android.util.Slog;
import android.util.SparseArray; import android.util.SparseArray;
import com.android.internal.util.IndentingPrintWriter; 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.IoThreadOnly;
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly; import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
import com.android.server.hdmi.HdmiControlService.DevicePollingCallback; import com.android.server.hdmi.HdmiControlService.DevicePollingCallback;
@ -34,6 +33,7 @@ import libcore.util.EmptyArray;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
/** /**
* Manages HDMI-CEC command and behaviors. It converts user's command into CEC command * 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. // Predicate for whether the given logical address is remote device's one or not.
private final Predicate<Integer> mRemoteDeviceAddressPredicate = new Predicate<Integer>() { private final Predicate<Integer> mRemoteDeviceAddressPredicate = new Predicate<Integer>() {
@Override @Override
public boolean apply(Integer address) { public boolean test(Integer address) {
return !isAllocatedLocalDeviceAddress(address); return !isAllocatedLocalDeviceAddress(address);
} }
}; };
@ -80,7 +80,7 @@ final class HdmiCecController {
// Predicate whether the given logical address is system audio's one or not // Predicate whether the given logical address is system audio's one or not
private final Predicate<Integer> mSystemAudioAddressPredicate = new Predicate<Integer>() { private final Predicate<Integer> mSystemAudioAddressPredicate = new Predicate<Integer>() {
@Override @Override
public boolean apply(Integer address) { public boolean test(Integer address) {
return HdmiUtils.getTypeFromAddress(address) == Constants.ADDR_AUDIO_SYSTEM; return HdmiUtils.getTypeFromAddress(address) == Constants.ADDR_AUDIO_SYSTEM;
} }
}; };
@ -403,7 +403,7 @@ final class HdmiCecController {
switch (iterationStrategy) { switch (iterationStrategy) {
case Constants.POLL_ITERATION_IN_ORDER: case Constants.POLL_ITERATION_IN_ORDER:
for (int i = Constants.ADDR_TV; i <= Constants.ADDR_SPECIFIC_USE; ++i) { for (int i = Constants.ADDR_TV; i <= Constants.ADDR_SPECIFIC_USE; ++i) {
if (pickPredicate.apply(i)) { if (pickPredicate.test(i)) {
pollingCandidates.add(i); pollingCandidates.add(i);
} }
} }
@ -411,7 +411,7 @@ final class HdmiCecController {
case Constants.POLL_ITERATION_REVERSE_ORDER: case Constants.POLL_ITERATION_REVERSE_ORDER:
default: // The default is reverse order. default: // The default is reverse order.
for (int i = Constants.ADDR_SPECIFIC_USE; i >= Constants.ADDR_TV; --i) { for (int i = Constants.ADDR_SPECIFIC_USE; i >= Constants.ADDR_TV; --i) {
if (pickPredicate.apply(i)) { if (pickPredicate.test(i)) {
pollingCandidates.add(i); pollingCandidates.add(i);
} }
} }

View File

@ -21,6 +21,7 @@ import java.util.Arrays;
/** /**
* Predicates contains static methods for creating the standard set of * Predicates contains static methods for creating the standard set of
* {@code Predicate} objects. * {@code Predicate} objects.
* @hide
*/ */
public class Predicates { public class Predicates {