Bug 999398 - Rename RawResource.get() to RawResource.getAsString() (r=nalexander)

This commit is contained in:
Lucas Rocha 2014-04-22 17:45:51 +01:00
parent 44f9892437
commit 7417d5e925
3 changed files with 13 additions and 4 deletions

View File

@ -83,7 +83,7 @@ public class HomeProvider extends SQLiteBridgeContentProvider {
private Cursor queryFakeItems(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
JSONArray items = null;
try {
final String jsonString = RawResource.get(getContext(), R.raw.fake_home_items);
final String jsonString = RawResource.getAsString(getContext(), R.raw.fake_home_items);
items = new JSONArray(jsonString);
} catch (IOException e) {
Log.e(LOGTAG, "Error getting fake home items", e);

View File

@ -12,8 +12,17 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
/**
* {@code RawResource} provides API to load raw resources in different
* forms. For now, we only load them as strings. We're using raw resources
* as localizable 'assets' as opposed to a string that can be directly
* translatable e.g. JSON file vs string.
*
* This is just a utility class to avoid code duplication for the different
* cases where need to read such assets.
*/
public final class RawResource {
public static String get(Context context, int id) throws IOException {
public static String getAsString(Context context, int id) throws IOException {
InputStreamReader reader = null;
try {

View File

@ -16,7 +16,7 @@ import java.io.IOException;
import org.mozilla.gecko.util.RawResource;
/**
* Tests whether RawResource.get() produces the right String
* Tests whether RawResource.getAsString() produces the right String
* result after reading the returned raw resource's InputStream.
*/
public class TestRawResource extends BrowserTestCase {
@ -57,7 +57,7 @@ public class TestRawResource extends BrowserTestCase {
String result;
try {
result = RawResource.get(context, RAW_RESOURCE_ID);
result = RawResource.getAsString(context, RAW_RESOURCE_ID);
} catch (IOException e) {
result = null;
}