本文整理汇总了Java中android.content.res.AssetManager.list方法的典型用法代码示例。如果您正苦于以下问题:Java AssetManager.list方法的具体用法?Java AssetManager.list怎么用?Java AssetManager.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.AssetManager
的用法示例。
在下文中一共展示了AssetManager.list方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listAssetFonts
import android.content.res.AssetManager; //导入方法依赖的package包/类
public static List<Font> listAssetFonts(Context context) {
AssetManager assetManager = context.getAssets();
String[] fontNames;
try {
fontNames = assetManager.list("fonts");
} catch (IOException e) {
Log.e("Error", "Unable to list fonts", e);
return new ArrayList<>();
}
ArrayList<Font> fonts = new ArrayList<>(fontNames.length);
for (int i = 0; i < fontNames.length; i++) {
fonts.add(new Font(fontNames[i]));
}
return fonts;
}
示例2: loadStickerCategory
import android.content.res.AssetManager; //导入方法依赖的package包/类
private void loadStickerCategory() {
AssetManager assetManager = NimUIKit.getContext().getResources().getAssets();
try {
String[] files = assetManager.list("sticker");
StickerCategory category;
for (String name : files) {
if (!FileUtil.hasExtentsion(name)) {
category = new StickerCategory(name, name, true, getStickerOrder(name));
stickerCategories.add(category);
stickerCategoryMap.put(name, category);
}
}
// 排序
Collections.sort(stickerCategories, new Comparator<StickerCategory>() {
@Override
public int compare(StickerCategory l, StickerCategory r) {
return l.getOrder() - r.getOrder();
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: isLitePalXMLExists
import android.content.res.AssetManager; //导入方法依赖的package包/类
/**
* If the litepal.xml configuration file exists.
* @return True if exists, false otherwise.
*/
public static boolean isLitePalXMLExists() {
try {
AssetManager assetManager = LitePalApplication.getContext().getAssets();
String[] fileNames = assetManager.list("");
if (fileNames != null && fileNames.length > 0) {
for (String fileName : fileNames) {
if (Const.Config.CONFIGURATION_FILE_NAME.equalsIgnoreCase(fileName)) {
return true;
}
}
}
} catch (IOException e) {
}
return false;
}
示例4: getPreDefLibFiles
import android.content.res.AssetManager; //导入方法依赖的package包/类
public static void getPreDefLibFiles(AssetManager am, String strPath, LinkedList<String> listFilePathLib)
{
String[] strSubFolderOrFiles;
try {
strSubFolderOrFiles = am.list(strPath);
} catch(IOException e) {
strSubFolderOrFiles = new String[0];
}
for (int index = 0; index < strSubFolderOrFiles.length; index ++) {
String strThisChild = strSubFolderOrFiles[index];
String strLeafPath = strPath + MFPFileManagerActivity.STRING_PATH_DIV + strThisChild;
if (strThisChild.length() >= STRING_ASSET_SCRIPT_LIB_FOLDER_EXTENSION.length()
&& strThisChild.substring(strThisChild.length() - STRING_ASSET_SCRIPT_LIB_FOLDER_EXTENSION.length())
.toLowerCase(Locale.US).equals(STRING_ASSET_SCRIPT_LIB_FOLDER_EXTENSION)) {
// this is a lib
getPreDefLibFiles(am, strLeafPath, listFilePathLib);
} else if (strThisChild.toLowerCase(Locale.US).equals(STRING_ASSET_SCRIPT_MATH_LIB_FILE)
|| strThisChild.toLowerCase(Locale.US).equals(STRING_ASSET_SCRIPT_MISC_LIB_FILE)
|| strThisChild.toLowerCase(Locale.US).equals(STRING_ASSET_SCRIPT_SIG_PROC_LIB_FILE)) {
// this is a script file, and it is math.mfps or misc.mfps or sig_proc.mfps
listFilePathLib.addLast(strLeafPath);
}
}
}
示例5: install
import android.content.res.AssetManager; //导入方法依赖的package包/类
/**
* Installs test files that are included in {@code path}.
* @params context Application context
* @params path
*/
private static void install(Context context, String path) throws IOException {
AssetManager assetManager = context.getAssets();
String files[] = assetManager.list(path);
Log.i(TAG, "Loading " + path + " ...");
String root = PathUtils.getDataDirectory(context);
if (files.length == 0) {
// The path is a file, so copy the file now.
copyTestFile(context, path, root + "/" + path);
} else {
// The path is a directory, so recursively handle its files, since
// the directory can contain subdirectories.
String fullPath = root + "/" + path;
File dir = new File(fullPath);
if (!dir.exists()) {
Log.i(TAG, "Creating directory " + fullPath + " ...");
if (!dir.mkdir()) {
throw new IOException("Directory not created.");
}
}
for (int i = 0; i < files.length; i++) {
install(context, path + "/" + files[i]);
}
}
}
示例6: getPlayList
import android.content.res.AssetManager; //导入方法依赖的package包/类
public static String [] getPlayList(Context context) {
AssetManager assetMgr;
String[] list = null;
try {
assetMgr = context.getAssets();
list = assetMgr.list("/assets");
displayFiles(assetMgr, "/assets");
// displayFiles(assetMgr, "./assets");
// displayFiles(assetMgr, "/");
// displayFiles(assetMgr, "./");
} catch (IOException e) {
Log.e(LOG_TAG , " Get asset Error ");
}
return list;
}
示例7: copyAssetFolder
import android.content.res.AssetManager; //导入方法依赖的package包/类
public static boolean copyAssetFolder(AssetManager assetManager,
String fromAssetPath, String toPath) {
try {
String[] files = assetManager.list(fromAssetPath);
new File(toPath).mkdirs();
boolean res = true;
for (String file : files)
if (file.contains(".")) {
res &= copyAsset(assetManager,
fromAssetPath + "/" + file,
toPath + "/" + file);
} else {
res &= copyAssetFolder(assetManager,
fromAssetPath + "/" + file,
toPath + "/" + file);
}
return res;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例8: findChildreen
import android.content.res.AssetManager; //导入方法依赖的package包/类
public List<TGBrowserElement> findChildreen() throws TGBrowserException {
try {
List<TGBrowserElement> elements = new ArrayList<TGBrowserElement>();
AssetManager assetManager = findAssetManager();
if( assetManager != null ) {
String[] assets = assetManager.list(this.getFullPath());
if( assets != null ) {
for(int i = 0; i < assets.length; i ++){
elements.add(new TGAssetBrowserElement(this.context, this, assets[i]));
}
}
}
return elements;
} catch (IOException e) {
throw new TGBrowserException();
}
}
示例9: copyAssetDirToFiles
import android.content.res.AssetManager; //导入方法依赖的package包/类
public boolean copyAssetDirToFiles(Context context, String dirname) {
try {
AssetManager assetManager = context.getAssets();
String[] children = assetManager.list(dirname);
for (String child : children) {
child = dirname + '/' + child;
String[] grandChildren = assetManager.list(child);
if (0 == grandChildren.length)
copyAssetFileToFiles(context, child);
else
copyAssetDirToFiles(context, child);
}
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
示例10: getSamplesFromAssets
import android.content.res.AssetManager; //导入方法依赖的package包/类
public List<SampleGroup> getSamplesFromAssets(AssetManager assets, String path) {
List<SampleGroup> sampleGroups = new ArrayList<>();
try {
String[] groups = assets.list(path);
for (String groupName : groups) {
sampleGroups.add(getSampleGroupFromAssets(assets, groupName, path + "/" + groupName));
}
return sampleGroups;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:13,代码来源:SampleFileManager.java
示例11: copyAssetCharts2SD
import android.content.res.AssetManager; //导入方法依赖的package包/类
public static boolean copyAssetCharts2SD(AssetManager am, String strSrcPath, String strDestPath) {
String strAssetFiles[] = null;
boolean bReturnValue = true;
try {
String strScriptExt = MFPFileManagerActivity.STRING_CHART_EXTENSION;
if (strSrcPath.substring(strSrcPath.length() - strScriptExt.length())
.toLowerCase(Locale.US).equals(strScriptExt)
&& (strSrcPath.equals(STRING_ASSET_CHARTS_FOLDER
+ MFPFileManagerActivity.STRING_PATH_DIV
+ STRING_ASSET_CHART_EXAMPLE1_FILE)
|| strSrcPath.equals(STRING_ASSET_CHARTS_FOLDER
+ MFPFileManagerActivity.STRING_PATH_DIV
+ STRING_ASSET_CHART_EXAMPLE2_FILE))) {
// this is a chart.
if (copyAssetFile2SD(am, strSrcPath, strDestPath) == false) {
return false;
}
} else if (strSrcPath.substring(strSrcPath.length() - STRING_ASSET_CHARTS_FOLDER_EXTENSION.length())
.toLowerCase(Locale.US).equals(STRING_ASSET_CHARTS_FOLDER_EXTENSION)) {
File dir = new File(strDestPath);
if (!dir.exists()) {
if (!dir.mkdirs()) {
return false; // cannot create destination folder
}
}
strAssetFiles = am.list(strSrcPath);
for (int i = 0; i < strAssetFiles.length; ++i) {
boolean bThisCpyReturn = copyAssetCharts2SD(am, strSrcPath + MFPFileManagerActivity.STRING_PATH_DIV + strAssetFiles[i],
strDestPath + MFPFileManagerActivity.STRING_PATH_DIV + strAssetFiles[i]);
if (!bThisCpyReturn) {
bReturnValue = false;
}
}
}
} catch (IOException ex) {
return false;
}
return bReturnValue;
}
示例12: getInputStream
import android.content.res.AssetManager; //导入方法依赖的package包/类
private InputStream getInputStream() throws IOException {
AssetManager assetManager = LitePalApplication.getContext().getAssets();
String[] fileNames = assetManager.list("");
if (fileNames != null && fileNames.length > 0) {
for (String fileName : fileNames) {
if (Const.Config.CONFIGURATION_FILE_NAME.equalsIgnoreCase(fileName)) {
return assetManager.open(fileName, AssetManager.ACCESS_BUFFER);
}
}
}
throw new ParseConfigurationFileException(
ParseConfigurationFileException.CAN_NOT_FIND_LITEPAL_FILE);
}
示例13: onCreate
import android.content.res.AssetManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_chooser_activity);
Intent intent = getIntent();
String dataUri = intent.getDataString();
String[] uris;
if (dataUri != null) {
uris = new String[] {dataUri};
} else {
ArrayList<String> uriList = new ArrayList<>();
AssetManager assetManager = getAssets();
try {
for (String asset : assetManager.list("")) {
if (asset.endsWith(".exolist.json")) {
// uriList.add("asset:///" + asset);
}else if(asset.endsWith(".exolist.new.json")){
uriList.add("asset:///" + asset);
}
}
} catch (IOException e) {
Toast.makeText(getApplicationContext(), R.string.sample_list_load_error, Toast.LENGTH_LONG)
.show();
}
uris = new String[uriList.size()];
uriList.toArray(uris);
Arrays.sort(uris);
}
SampleListLoader loaderTask = new SampleListLoader();
loaderTask.execute(uris);
}
示例14: createPresenter
import android.content.res.AssetManager; //导入方法依赖的package包/类
private void createPresenter() {
if (mPresenter != null) return;
try {
AssetManager assets = getContext().getAssets();
String[] names = assets.list("bigtext");
InputStream[] inputStreams = new InputStream[names.length];
for (int i = 0; i < names.length; i++) {
String name = names[i];
inputStreams[i] = assets.open("bigtext" + "/" + name);
}
mPresenter = new BigFontPresenter(inputStreams, this);
} catch (Exception e) {
e.printStackTrace();
}
}
示例15: displayFiles
import android.content.res.AssetManager; //导入方法依赖的package包/类
public static void displayFiles (AssetManager mgr, String path) {
try {
String list[] = mgr.list(path);
if (list != null)
for (int i=0; i<list.length; ++i)
{
Log.v("Assets:", path +"/"+ list[i]);
displayFiles(mgr, path + "/" + list[i]);
}
} catch (IOException e) {
Log.v("List error:", "can't list" + path);
}
}