本文整理汇总了Java中com.archos.filecorelibrary.FileEditorFactory类的典型用法代码示例。如果您正苦于以下问题:Java FileEditorFactory类的具体用法?Java FileEditorFactory怎么用?Java FileEditorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileEditorFactory类属于com.archos.filecorelibrary包,在下文中一共展示了FileEditorFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteAssociatedNfoFiles
import com.archos.filecorelibrary.FileEditorFactory; //导入依赖的package包/类
public void deleteAssociatedNfoFiles(final Uri fileUri){ //when deleting a description, also delete Nfo
new Thread(){
public void run(){
if(!UriUtils.isImplementedByFileCore(fileUri)||"upnp".equals(fileUri.getScheme())) //we can"t delete files on upnp
return;
List<Uri> toDelete = getAssociatedFiles(fileUri);
if(toDelete!=null){
for(Uri uri : toDelete){
try {
FileEditorFactory.getFileEditorForUrl(uri,mContext).delete();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}.start();
}
示例2: deleteFolder
import com.archos.filecorelibrary.FileEditorFactory; //导入依赖的package包/类
public void deleteFolder(final Uri uri){
new Thread(){
public void run() {
try {
FileEditorFactory.getFileEditorForUrl(uri, mContext).delete();
} catch (Exception e) {
}
mHandler.post(new Runnable() {
@Override
public void run() {
mListener.onFolderRemoved(uri);
}
});
}
}.start();
}
示例3: compressFile
import com.archos.filecorelibrary.FileEditorFactory; //导入依赖的package包/类
public static boolean compressFile(File toCompress, File target) {
if (target == null || toCompress == null) {
return false;
}
try {
final Uri uri = Uri.fromFile(toCompress);
final String rootPath = Utils.getParentUrl(uri.toString());
final int rootOffset = rootPath.length();
ZipOutputStream zos = new ZipOutputStream(FileEditorFactory.getFileEditorForUrl(Uri.fromFile(target), null).getOutputStream());
ZipEntry entry = new ZipEntry(uri.toString().substring(rootOffset));
byte[] bytes = new byte[1024];
InputStream fis = FileEditorFactory.getFileEditorForUrl(uri, null).getInputStream();
entry.setSize(toCompress.length());
entry.setTime(toCompress.lastModified());
zos.putNextEntry(entry);
int count;
while ((count = fis.read(bytes)) > 0) {
zos.write(bytes, 0, count);
}
zos.closeEntry();
closeSilently(fis);
closeSilently(zos);
return true;
}
catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例4: checkShortcutAvailability
import com.archos.filecorelibrary.FileEditorFactory; //导入依赖的package包/类
private void checkShortcutAvailability(){
if(mCheckShortcutAvailabilityTask!=null)
mCheckShortcutAvailabilityTask.cancel(true);
mCheckShortcutAvailabilityTask = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... arg0) {
List<ShortcutDbAdapter.Shortcut> shortcuts = mAdapter.getShortcuts();
List<String> shares = mAdapter.getAvailableShares();
List<String> forcedShortcuts = mAdapter.getForcedEnabledShortcuts();
if(shortcuts==null)
return null;
for (ShortcutDbAdapter.Shortcut shortcut : shortcuts) {
Uri uri = Uri.parse(shortcut.getUri());
if ((shares == null || !shares.contains(uri.getHost().toLowerCase()))
&&!forcedShortcuts.contains(shortcut.getUri())
&& FileEditorFactory.getFileEditorForUrl(uri, getActivity()).exists()) {
mAdapter.forceShortcutDisplay(shortcut.getUri());
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
mAdapter.notifyDataSetChanged();
}
}.execute();
}
示例5: deleteFileAndAssociatedFiles
import com.archos.filecorelibrary.FileEditorFactory; //导入依赖的package包/类
public static boolean deleteFileAndAssociatedFiles(Context context, Uri fileUri) {
// Get list of all files (video and associated)
List<Uri> associatedFiles = getAssociatedFiles(fileUri);
// Do not forget to add the video file!
List<Uri> allFiles = new ArrayList<>(associatedFiles.size()+1);
allFiles.add(fileUri);
allFiles.addAll(associatedFiles);
// Delete found associated files
for (Uri uri : allFiles) {
FileEditor editor = FileEditorFactory.getFileEditorForUrl(uri,context);
try {
if(editor instanceof LocalStorageFileEditor) //delete from database
((LocalStorageFileEditor)editor).deleteFileAndDatabase(context);
else {
NetworkScanner.removeVideos(context, uri);
editor.delete();
}
} catch (Exception e) {
Log.e(TAG, "Failed to delete file " + uri, e);
if(uri == fileUri) // if failure is on main file
return false;
}
}
//delete subs
if(!Utils.isSlowRemote(fileUri)) {
SubtitleManager.deleteAssociatedSubs(fileUri,context);
XmlDb.deleteAssociatedResumeDatabase(fileUri);
}
return true;
}
示例6: getFileEditorForUrl
import com.archos.filecorelibrary.FileEditorFactory; //导入依赖的package包/类
public static FileEditor getFileEditorForUrl(Uri uri, Context ct) {
if ("upnp".equals(uri.getScheme())) {
return new UpnpFileEditor(uri);
}
if ("http".equals(uri.getScheme())||"https".equals(uri.getScheme())) {
return new HttpFileEditor(uri);
}
else {
return FileEditorFactory.getFileEditorForUrl(uri,ct);
}
}
示例7: clearOldSubDir
import com.archos.filecorelibrary.FileEditorFactory; //导入依赖的package包/类
public static void clearOldSubDir(Context context){
try {
File subdir = getOldSubsDir(context);
if (subdir.exists()) {
FileEditorFactory.getFileEditorForUrl(Uri.fromFile(subdir), context).delete();
}
}catch (Exception e){e.printStackTrace();}
}
示例8: onReceive
import com.archos.filecorelibrary.FileEditorFactory; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive");
if(ACTION_CHECK_POSTER.equals(intent.getAction())&&intent.getLongExtra("VIDEO_ID",-1)!=-1){
Log.d(TAG, "onReceive2");
StringBuilder sb = new StringBuilder();
if (LoaderUtils.mustHideUserHiddenObjects()) {
sb.append(LoaderUtils.HIDE_USER_HIDDEN_FILTER);
sb.append(" AND ");
}
sb.append(VideoStore.Video.VideoColumns._ID + " = ? ");
String[] arg = new String[]{Long.toString(intent.getLongExtra("VIDEO_ID",-1))};
String where = sb.toString();
Cursor c = context.getContentResolver().query(VideoStore.Video.Media.EXTERNAL_CONTENT_URI, new String[]{COLUMN_COVER_PATH,VideoStore.Video.VideoColumns.TITLE, VideoStore.Video.VideoColumns.SCRAPER_SHOW_ID, VideoStore.Video.VideoColumns.SCRAPER_MOVIE_ID,VideoStore.Video.VideoColumns.ARCHOS_MEDIA_SCRAPER_TYPE}, where, arg, null);
if(c!=null&&c.getCount()>0){
c.moveToFirst();
int coverColumn = c.getColumnIndex(COLUMN_COVER_PATH);
int titleColumn = c.getColumnIndex(VideoStore.Video.VideoColumns.TITLE);
int idMovieColumn = c.getColumnIndex(VideoStore.Video.VideoColumns.SCRAPER_MOVIE_ID);
int idShowColumn= c.getColumnIndex(VideoStore.Video.VideoColumns.SCRAPER_SHOW_ID);
final int scraperType = c.getInt(c.getColumnIndex(VideoStore.Video.VideoColumns.ARCHOS_MEDIA_SCRAPER_TYPE));
if(c.getString(coverColumn)!=null){
String path = c.getString(coverColumn);
if(!FileEditorFactory.getFileEditorForUrl(Uri.parse(path), null).exists()){
//remove
Log.d(TAG, path + " does not exists : removing for "+c.getString(titleColumn));
ContentValues cv = new ContentValues();
Uri uri;
if (scraperType == BaseTags.TV_SHOW) {
uri = ContentUris.withAppendedId(ScraperStore.Episode.URI.ID, c.getLong(idShowColumn));
cv.put(ScraperStore.Episode.POSTER_ID, -1);
cv.putNull(ScraperStore.Episode.COVER);
}
else {
uri = ContentUris.withAppendedId(ScraperStore.Movie.URI.ID, c.getLong(idMovieColumn));
cv.put(ScraperStore.Movie.POSTER_ID, -1);
cv.putNull(ScraperStore.Movie.COVER);
}
int n = context.getContentResolver().update(uri,cv,null,null);
Log.d(TAG,n+ "updated");
}
}
}
if (c!=null)
c.close();
}
}