Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
Fix Resources$NotFoundException crash
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Mar 30, 2014
1 parent e5ef56d commit e92a9c7
Showing 1 changed file with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public interface OnTriggerListener {
private static final float RING_SCALE_EXPANDED = 1.0f;
private static final float RING_SCALE_COLLAPSED = 0.5f;

private ArrayList<TargetDrawable> mTargetDrawables = new ArrayList<TargetDrawable>();
private ArrayList<TargetDrawable> mTargetDrawables = new ArrayList<>();
private AnimationBundle mWaveAnimations = new AnimationBundle();
private AnimationBundle mTargetAnimations = new AnimationBundle();
private AnimationBundle mGlowAnimations = new AnimationBundle();
Expand Down Expand Up @@ -584,7 +584,7 @@ private ArrayList<TargetDrawable> loadDrawableArray(int resourceId) {
Resources res = getContext().getResources();
TypedArray array = res.obtainTypedArray(resourceId);
final int count = array.length();
ArrayList<TargetDrawable> drawables = new ArrayList<TargetDrawable>(count);
ArrayList<TargetDrawable> drawables = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
TypedValue value = array.peekValue(i);
TargetDrawable target = new TargetDrawable(res, value != null ? value.resourceId : 0);
Expand Down Expand Up @@ -1369,15 +1369,27 @@ private String getDirectionDescription(int index) {
}

private ArrayList<String> loadDescriptions(int resourceId) {
TypedArray array = getContext().getResources().obtainTypedArray(resourceId);
final int count = array.length();
ArrayList<String> targetContentDescriptions = new ArrayList<String>(count);
for (int i = 0; i < count; i++) {
String contentDescription = array.getString(i);
targetContentDescriptions.add(contentDescription);
if (resourceId == 0) {
return new ArrayList<>(0);
}
array.recycle();
return targetContentDescriptions;

final Context context = getContext();
TypedArray array = null;
if (context != null) {
array = context.getResources().obtainTypedArray(resourceId);
}
final int count;
if (array != null) {
count = array.length();
ArrayList<String> targetContentDescriptions = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
String contentDescription = array.getString(i);
targetContentDescriptions.add(contentDescription);
}
array.recycle();
return targetContentDescriptions;
}
return new ArrayList<>(0);
}

public int getResourceIdForTarget(int index) {
Expand Down

0 comments on commit e92a9c7

Please sign in to comment.