Example usage for android.content Context getAssets

List of usage examples for android.content Context getAssets

Introduction

In this page you can find the example usage for android.content Context getAssets.

Prototype

public abstract AssetManager getAssets();

Source Link

Document

Returns an AssetManager instance for the application's package.

Usage

From source file:Main.java

/**
 *
 * @param context//www  .java  2 s.  c o  m
 * @return The custom Typeface for RobotoSlab-Bold.ttf
 */
public static Typeface robotoBold(Context context) {
    return Typeface.createFromAsset(context.getAssets(), "fonts/RobotoSlab-Bold.ttf");
}

From source file:Main.java

/**
 *
 * @param context//ww w. j  a va2 s.c o m
 * @return The custom Typeface for RobotoSlab-Regular.ttf
 */
public static Typeface robotoRegular(Context context) {
    return Typeface.createFromAsset(context.getAssets(), "fonts/RobotoSlab-Regular.ttf");
}

From source file:Main.java

public static void generateTypeface(Context context) {
    arabicTypeFace = Typeface.createFromAsset(context.getAssets(), "fonts/app_font.ttf");
}

From source file:Main.java

public static InputStream getAssetInputStream(String assetFileName, Context context) throws IOException {
    InputStream inputStream = context.getAssets().open(assetFileName);
    return inputStream;
}

From source file:Main.java

public static Typeface createTypeface(Context context, int typeface) {
    return Typeface.createFromAsset(context.getAssets(),
            String.format("fonts/%s.ttf", context.getString(typeface)));
}

From source file:Main.java

public static Typeface getTypeface(Context context, String fontName) {
    return Typeface.createFromAsset(context.getAssets(), fontName);
}

From source file:Main.java

public static Typeface getFontAwesomeTypeFace(Context context) {

    return Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
}

From source file:Main.java

public static InputStream openAssetFile(Context context, String fileName) {
    AssetManager am = context.getAssets();
    InputStream is = null;/*from  w w w.j  a v  a 2  s . c  om*/
    try {
        is = am.open(fileName);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return is;
}

From source file:Main.java

public static void init(Context context) {
    typefaceLatoRegular = Typeface.createFromAsset(context.getAssets(), "fonts/Lato-Regular.ttf");
    typefaceLatoHairline = Typeface.createFromAsset(context.getAssets(), "fonts/Lato-Hairline.ttf");
    typefaceLatoLight = Typeface.createFromAsset(context.getAssets(), "fonts/LatoLatin-Light.ttf");
}

From source file:Main.java

public static String AssetJSONFile(String filename, Context context) throws IOException {
    AssetManager manager = context.getAssets();
    InputStream file = manager.open(filename);
    byte[] formArray = new byte[file.available()];
    file.read(formArray);/*ww  w.java2 s  .c o m*/
    file.close();

    return new String(formArray);
}