use of android.content.res.AssetManager in project Osmand by osmandapp.
the class DownloadOsmandIndexesHelper method getIndexesList.
public static IndexFileList getIndexesList(OsmandApplication app) {
PackageManager pm = app.getPackageManager();
AssetManager amanager = app.getAssets();
IndexFileList result = downloadIndexesListFromInternet(app);
if (result == null) {
result = new IndexFileList();
} else {
result.setDownloadedFromInternet(true);
}
// add all tts files from assets
listVoiceAssets(result, amanager, pm, app.getSettings());
return result;
}
use of android.content.res.AssetManager in project MagiskManager by topjohnwu.
the class Utils method getAssets.
public static AssetManager getAssets(String apk) {
try {
AssetManager asset = AssetManager.class.newInstance();
AssetManager.class.getMethod("addAssetPath", String.class).invoke(asset, apk);
return asset;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of android.content.res.AssetManager in project sample-tensorflow-imageclassifier by androidthings.
the class TensorFlowHelper method readLabels.
public static List<String> readLabels(Context context, String labelsFile) {
AssetManager assetManager = context.getAssets();
ArrayList<String> result = new ArrayList<>();
try (InputStream is = assetManager.open(labelsFile);
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String line;
while ((line = br.readLine()) != null) {
result.add(line);
}
return result;
} catch (IOException ex) {
throw new IllegalStateException("Cannot read labels from " + labelsFile);
}
}
use of android.content.res.AssetManager in project AndroidAsync by koush.
the class AsyncHttpServerRouter method directory.
public void directory(Context context, String regex, final String assetPath) {
AssetManager am = context.getAssets();
addAction(AsyncHttpGet.METHOD, regex, (request, response) -> {
String path = request.getMatcher().replaceAll("");
Asset pair = getAssetStream(am, assetPath + path);
if (pair == null || pair.inputStream == null) {
response.code(404);
response.end();
return;
}
if (isClientCached(context, request, response, pair.path)) {
StreamUtility.closeQuietly(pair.inputStream);
response.code(304);
response.end();
return;
}
response.getHeaders().set("Content-Length", String.valueOf(pair.available));
response.getHeaders().add("Content-Type", getContentType(pair.path));
response.code(200);
Util.pump(pair.inputStream, pair.available, response, ex -> {
response.end();
StreamUtility.closeQuietly(pair.inputStream);
});
});
addAction(AsyncHttpHead.METHOD, regex, (request, response) -> {
String path = request.getMatcher().replaceAll("");
Asset pair = getAssetStream(am, assetPath + path);
if (pair == null || pair.inputStream == null) {
response.code(404);
response.end();
return;
}
StreamUtility.closeQuietly(pair.inputStream);
if (isClientCached(context, request, response, pair.path)) {
response.code(304);
} else {
response.getHeaders().set("Content-Length", String.valueOf(pair.available));
response.getHeaders().add("Content-Type", getContentType(pair.path));
response.code(200);
}
response.end();
});
}
use of android.content.res.AssetManager in project anitrend-app by AniTrend.
the class SingleLineFontTextView method onInit.
/**
* Optionally included when constructing custom views
*/
@Override
public void onInit() {
super.onInit();
AssetManager assetManager = getContext().getAssets();
setTypeface(Typeface.createFromAsset(assetManager, "fonts/Lobster-Regular.ttf"));
}
Aggregations