am 51a05d74: Merge "Fix TypedArray.getTextArray()" into mnc-ub-dev
* commit '51a05d74a81aeb334ef095fc6f1aa98e5163763f': Fix TypedArray.getTextArray()
This commit is contained in:
@@ -48,9 +48,6 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final class BridgeResources extends Resources {
|
public final class BridgeResources extends Resources {
|
||||||
|
|
||||||
private BridgeContext mContext;
|
private BridgeContext mContext;
|
||||||
@@ -278,7 +275,7 @@ public final class BridgeResources extends Resources {
|
|||||||
* always Strings. The ideal signature for the method should be <T super String>, but java
|
* always Strings. The ideal signature for the method should be <T super String>, but java
|
||||||
* generics don't support it.
|
* generics don't support it.
|
||||||
*/
|
*/
|
||||||
private <T extends CharSequence> T[] fillValues(ArrayResourceValue resValue, T[] values) {
|
<T extends CharSequence> T[] fillValues(ArrayResourceValue resValue, T[] values) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Iterator<String> iterator = resValue.iterator(); iterator.hasNext(); i++) {
|
for (Iterator<String> iterator = resValue.iterator(); iterator.hasNext(); i++) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.content.res;
|
package android.content.res;
|
||||||
|
|
||||||
|
import com.android.ide.common.rendering.api.ArrayResourceValue;
|
||||||
import com.android.ide.common.rendering.api.AttrResourceValue;
|
import com.android.ide.common.rendering.api.AttrResourceValue;
|
||||||
import com.android.ide.common.rendering.api.LayoutLog;
|
import com.android.ide.common.rendering.api.LayoutLog;
|
||||||
import com.android.ide.common.rendering.api.RenderResources;
|
import com.android.ide.common.rendering.api.RenderResources;
|
||||||
@@ -33,6 +34,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.content.res.Resources.NotFoundException;
|
||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
@@ -740,12 +742,20 @@ public final class BridgeTypedArray extends TypedArray {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CharSequence[] getTextArray(int index) {
|
public CharSequence[] getTextArray(int index) {
|
||||||
String value = getString(index);
|
if (!hasValue(index)) {
|
||||||
if (value != null) {
|
return null;
|
||||||
return new CharSequence[] { value };
|
|
||||||
}
|
}
|
||||||
|
ResourceValue resVal = mResourceData[index];
|
||||||
return null;
|
if (resVal instanceof ArrayResourceValue) {
|
||||||
|
ArrayResourceValue array = (ArrayResourceValue) resVal;
|
||||||
|
int count = array.getElementCount();
|
||||||
|
return count >= 0 ? mBridgeResources.fillValues(array, new CharSequence[count]) : null;
|
||||||
|
}
|
||||||
|
int id = getResourceId(index, 0);
|
||||||
|
String resIdMessage = id > 0 ? " (resource id 0x" + Integer.toHexString(id) + ')' : "";
|
||||||
|
throw new NotFoundException(
|
||||||
|
String.format("%1$s in %2$s%3$s is not a valid array resource.",
|
||||||
|
resVal.getValue(), mNames[index], resIdMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user