am 52d3312a: Merge "Make ResourceKey always use non-null configuration override." into mnc-dev

* commit '52d3312abeafd988ecb2288896b74ba72c3e70c0':
  Make ResourceKey always use non-null configuration override.
This commit is contained in:
Filip Gruszczynski
2015-08-04 23:11:24 +00:00
committed by Android Git Automerger

View File

@@ -16,6 +16,8 @@
package android.content.res; package android.content.res;
import android.annotation.NonNull;
import java.util.Objects; import java.util.Objects;
/** @hide */ /** @hide */
@@ -25,27 +27,27 @@ public final class ResourcesKey {
private final int mHash; private final int mHash;
public final int mDisplayId; public final int mDisplayId;
@NonNull
public final Configuration mOverrideConfiguration; public final Configuration mOverrideConfiguration;
public ResourcesKey(String resDir, int displayId, Configuration overrideConfiguration, public ResourcesKey(String resDir, int displayId, Configuration overrideConfiguration,
float scale) { float scale) {
mResDir = resDir; mResDir = resDir;
mDisplayId = displayId; mDisplayId = displayId;
mOverrideConfiguration = overrideConfiguration; mOverrideConfiguration = overrideConfiguration != null
? overrideConfiguration : Configuration.EMPTY;
mScale = scale; mScale = scale;
int hash = 17; int hash = 17;
hash = 31 * hash + (mResDir == null ? 0 : mResDir.hashCode()); hash = 31 * hash + (mResDir == null ? 0 : mResDir.hashCode());
hash = 31 * hash + mDisplayId; hash = 31 * hash + mDisplayId;
hash = 31 * hash + (mOverrideConfiguration != null hash = 31 * hash + mOverrideConfiguration.hashCode();
? mOverrideConfiguration.hashCode() : 0);
hash = 31 * hash + Float.floatToIntBits(mScale); hash = 31 * hash + Float.floatToIntBits(mScale);
mHash = hash; mHash = hash;
} }
public boolean hasOverrideConfiguration() { public boolean hasOverrideConfiguration() {
return mOverrideConfiguration != null return !Configuration.EMPTY.equals(mOverrideConfiguration);
&& !Configuration.EMPTY.equals(mOverrideConfiguration);
} }
@Override @Override
@@ -66,14 +68,9 @@ public final class ResourcesKey {
if (mDisplayId != peer.mDisplayId) { if (mDisplayId != peer.mDisplayId) {
return false; return false;
} }
if (mOverrideConfiguration != peer.mOverrideConfiguration) {
if (mOverrideConfiguration == null || peer.mOverrideConfiguration == null) {
return false;
}
if (!mOverrideConfiguration.equals(peer.mOverrideConfiguration)) { if (!mOverrideConfiguration.equals(peer.mOverrideConfiguration)) {
return false; return false;
} }
}
if (mScale != peer.mScale) { if (mScale != peer.mScale) {
return false; return false;
} }