@Implementation(maxSdk = M) public String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { ShadowLegacyAssetManager shadowAssetManager = legacyShadowOf(realResourcesImpl.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable().getValue(resId, shadowAssetManager.config); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), shadowAssetManager.config, resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } }
@Override public void onEnd(XMLStreamReader xml, XmlContext xmlContext) throws XMLStreamException { resourceTable.addResource(attrType, name, new PluralRules(new ArrayList<>(plurals), resType, xmlContext)); plurals.clear(); } }
@Implementation(maxSdk = M) public String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { ShadowLegacyAssetManager shadowAssetManager = legacyShadowOf(realResourcesImpl.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable().getValue(resId, shadowAssetManager.config); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), shadowAssetManager.config, resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } }
@Override public void onEnd(XMLStreamReader xml, XmlContext xmlContext) throws XMLStreamException { resourceTable.addResource(attrType, name, new PluralRules(new ArrayList<>(plurals), resType, xmlContext)); plurals.clear(); } }
@Implementation protected String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { if (isLegacyAssetManager()) { ShadowLegacyAssetManager shadowAssetManager = legacyShadowOf(realResources.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable() .getValue(resId, shadowAssetManager.config); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), shadowAssetManager.config, resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } } else { return directlyOn(realResources, Resources.class).getQuantityString(resId, quantity); } }
@Override public void onEnd(XMLStreamReader xml, XmlContext xmlContext) throws XMLStreamException { resourceTable.addResource(attrType, name, new PluralRules(new ArrayList<>(plurals), resType, xmlContext)); plurals.clear(); } }
@Implementation public String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { ShadowAssetManager shadowAssetManager = shadowOf(realResources.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable().getValue(resId, RuntimeEnvironment.getQualifiers()); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), RuntimeEnvironment.getQualifiers(), resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } }
@Implementation public String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { ShadowAssetManager shadowAssetManager = shadowOf(realResources.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable().getValue(resId, RuntimeEnvironment.getQualifiers()); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), RuntimeEnvironment.getQualifiers(), resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } }
@Implementation(maxSdk = M) public String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { ShadowLegacyAssetManager shadowAssetManager = legacyShadowOf(realResourcesImpl.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable().getValue(resId, shadowAssetManager.config); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), shadowAssetManager.config, resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } }
@Implementation(maxSdk = M) public String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { ShadowLegacyAssetManager shadowAssetManager = legacyShadowOf(realResourcesImpl.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable().getValue(resId, shadowAssetManager.config); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), shadowAssetManager.config, resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } }
@Implementation protected String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { if (isLegacyAssetManager()) { ShadowLegacyAssetManager shadowAssetManager = legacyShadowOf(realResources.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable() .getValue(resId, shadowAssetManager.config); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), shadowAssetManager.config, resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } } else { return directlyOn(realResources, Resources.class).getQuantityString(resId, quantity); } }
@Implementation public String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { ShadowAssetManager shadowAssetManager = shadowOf(realResourcesImpl.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable().getValue(resId, RuntimeEnvironment.getQualifiers()); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), RuntimeEnvironment.getQualifiers(), resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } }
@Implementation public String getQuantityString(int resId, int quantity) throws Resources.NotFoundException { ShadowAssetManager shadowAssetManager = shadowOf(realResourcesImpl.getAssets()); TypedResource typedResource = shadowAssetManager.getResourceTable().getValue(resId, RuntimeEnvironment.getQualifiers()); if (typedResource != null && typedResource instanceof PluralRules) { PluralRules pluralRules = (PluralRules) typedResource; Plural plural = pluralRules.find(quantity); if (plural == null) { return null; } TypedResource<?> resolvedTypedResource = shadowAssetManager.resolve( new TypedResource<>(plural.getString(), ResType.CHAR_SEQUENCE, pluralRules.getXmlContext()), RuntimeEnvironment.getQualifiers(), resId); return resolvedTypedResource == null ? null : resolvedTypedResource.asString(); } else { return null; } }