| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.internal.widget; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.os.Bundle; |
| 22 |
import android.os.IBinder; |
| 23 |
|
| 24 |
import java.util.Objects; |
| 25 |
import java.util.Set; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public final class InlinePresentationStyleUtils { |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public static boolean bundleEquals(@NonNull Bundle bundle1, @NonNull Bundle bundle2) { |
| 42 |
if (bundle1 == bundle2) { |
| 43 |
return true; |
| 44 |
} |
| 45 |
if (bundle1 == null || bundle2 == null) { |
| 46 |
return false; |
| 47 |
} |
| 48 |
if (bundle1.size() != bundle2.size()) { |
| 49 |
return false; |
| 50 |
} |
| 51 |
Set<String> keys = bundle1.keySet(); |
| 52 |
for (String key : keys) { |
| 53 |
Object value1 = bundle1.get(key); |
| 54 |
Object value2 = bundle2.get(key); |
| 55 |
final boolean equal = value1 instanceof Bundle && value2 instanceof Bundle |
| 56 |
? bundleEquals((Bundle) value1, (Bundle) value2) |
| 57 |
: Objects.equals(value1, value2); |
| 58 |
if (!equal) { |
| 59 |
return false; |
| 60 |
} |
| 61 |
} |
| 62 |
return true; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public static void filterContentTypes(@Nullable Bundle bundle) { |
| 69 |
if (bundle == null) { |
| 70 |
return; |
| 71 |
} |
| 72 |
|
| 73 |
for (String key : bundle.keySet()) { |
| 74 |
Object o = bundle.get(key); |
| 75 |
|
| 76 |
if (o instanceof Bundle) { |
| 77 |
filterContentTypes((Bundle) o); |
| 78 |
} else if (o instanceof IBinder) { |
| 79 |
bundle.remove(key); |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
private InlinePresentationStyleUtils() { |
| 88 |
} |
| 89 |
} |