Search in sources :

Example 21 with AssetManager

use of android.content.res.AssetManager in project atlas by alibaba.

the class DelegateResources method updateResources.

private static synchronized void updateResources(Resources res, String assetPath, int assertType) throws Exception {
    if (sAssetManagerProcessor == null) {
        sAssetManagerProcessor = new AssetManagerProcessor();
    }
    AssetManager updatedAssetManager = sAssetManagerProcessor.updateAssetManager(res.getAssets(), assetPath, assertType);
    if (sResourcesProcessor == null) {
        sResourcesProcessor = getResourceProcessor();
    }
    sResourcesProcessor.updateResources(updatedAssetManager);
    if (sResourcesFetcher == null) {
        sResourcesFetcher = new ResourceIdFetcher();
    }
    sResourcesFetcher.addAssetForGetIdentifier(assetPath);
}
Also used : AssetManager(android.content.res.AssetManager)

Example 22 with AssetManager

use of android.content.res.AssetManager in project atlas by alibaba.

the class ResourceIdFetcher method addAssetForGetIdentifier.

public void addAssetForGetIdentifier(String newPath) throws InstantiationException, IllegalAccessException, InvocationTargetException {
    try {
        // Make asset for getIdentifier on android 5.0
        if ((AtlasHacks.AssetManager_addAssetPath != null) && (AtlasHacks.AssetManager_ensureStringBlocks != null) && Build.VERSION.SDK_INT > 20) {
            AssetManager asset = AssetManager.class.newInstance();
            AtlasHacks.AssetManager_addAssetPath.invoke(asset, newPath);
            AtlasHacks.AssetManager_ensureStringBlocks.invoke(asset);
            assetList.add(asset);
        }
    } catch (Throwable e) {
    }
}
Also used : AssetManager(android.content.res.AssetManager)

Example 23 with AssetManager

use of android.content.res.AssetManager in project restful-android by jeremyhaberman.

the class AboutActivity method getInputStream.

private static InputStream getInputStream(Context context, String filename) {
    AssetManager assetManager = context.getAssets();
    InputStream inputStream = null;
    try {
        inputStream = assetManager.open(filename);
    } catch (IOException e) {
        Log.e(TAG, e.getLocalizedMessage(), e);
    }
    return inputStream;
}
Also used : AssetManager(android.content.res.AssetManager) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 24 with AssetManager

use of android.content.res.AssetManager in project Talon-for-Twitter by klinker24.

the class IOUtils method readChangelog.

public static String readChangelog(Context context) {
    String ret = "";
    try {
        AssetManager assetManager = context.getAssets();
        Scanner in = new Scanner(assetManager.open("changelog.txt"));
        while (in.hasNextLine()) {
            ret += in.nextLine() + "\n";
        }
    } catch (FileNotFoundException e) {
    } catch (IOException e) {
    }
    return ret;
}
Also used : Scanner(java.util.Scanner) AssetManager(android.content.res.AssetManager) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 25 with AssetManager

use of android.content.res.AssetManager in project android-stackblur by kikoso.

the class MainActivity method getBitmapFromAsset.

private Bitmap getBitmapFromAsset(Context context, String strName) {
    AssetManager assetManager = context.getAssets();
    InputStream istr;
    Bitmap bitmap = null;
    try {
        istr = assetManager.open(strName);
        bitmap = BitmapFactory.decodeStream(istr);
    } catch (IOException e) {
        return null;
    }
    return bitmap;
}
Also used : Bitmap(android.graphics.Bitmap) AssetManager(android.content.res.AssetManager) InputStream(java.io.InputStream) IOException(java.io.IOException)

Aggregations

AssetManager (android.content.res.AssetManager)196 IOException (java.io.IOException)70 InputStream (java.io.InputStream)58 Resources (android.content.res.Resources)47 XmlResourceParser (android.content.res.XmlResourceParser)28 File (java.io.File)28 DisplayMetrics (android.util.DisplayMetrics)24 Configuration (android.content.res.Configuration)15 BufferedReader (java.io.BufferedReader)13 FileOutputStream (java.io.FileOutputStream)13 Bitmap (android.graphics.Bitmap)12 InputStreamReader (java.io.InputStreamReader)12 FileInputStream (java.io.FileInputStream)10 FileNotFoundException (java.io.FileNotFoundException)10 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)10 AndroidRuntimeException (android.util.AndroidRuntimeException)8 OutputStream (java.io.OutputStream)8 Method (java.lang.reflect.Method)8 Intent (android.content.Intent)7 AttributeSet (android.util.AttributeSet)7