Java Code Examples for com.hippo.unifile.UniFile#findFile()
The following examples show how to use
com.hippo.unifile.UniFile#findFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageProvider.java From Nimingban with Apache License 2.0 | 6 votes |
@Override public UniFile getFile(Uri uri) { // Get dir UniFile dir = Settings.getImageSaveLocation(); if (dir == null) { return null; } // Get filename List<String> path = uri.getPathSegments(); if (path == null || path.size() != 1) { return null; } return dir.findFile(path.get(0)); }
Example 2
Source File: SpiderQueen.java From MHViewer with Apache License 2.0 | 5 votes |
private synchronized SpiderInfo readSpiderInfoFromLocal() { SpiderInfo spiderInfo = mSpiderInfo.get(); if (spiderInfo != null) { return spiderInfo; } // Read from download dir UniFile downloadDir = mSpiderDen.getDownloadDir(); if (downloadDir != null) { UniFile file = downloadDir.findFile(SPIDER_INFO_FILENAME); spiderInfo = SpiderInfo.read(file); if (spiderInfo != null && spiderInfo.gid.equals(mGalleryInfo.getCid()) && spiderInfo.token.equals(mGalleryInfo.token)) { return spiderInfo; } } // Read from cache InputStreamPipe pipe = mSpiderInfoCache.getInputStreamPipe(mGalleryInfo.getCid()); if (null != pipe) { try { pipe.obtain(); spiderInfo = SpiderInfo.read(pipe.open()); if (spiderInfo != null && spiderInfo.gid.equals(mGalleryInfo.getCid()) && spiderInfo.token.equals(mGalleryInfo.token)) { return spiderInfo; } } catch (IOException e) { // Ignore } finally { pipe.close(); pipe.release(); } } return null; }
Example 3
Source File: SpiderDen.java From MHViewer with Apache License 2.0 | 5 votes |
@Nullable private static UniFile findImageFile(UniFile dir, int index) { for (String extension : GalleryProvider2.SUPPORT_IMAGE_EXTENSIONS) { String filename = generateImageFilename(index, extension); UniFile file = dir.findFile(filename); if (file != null) { return file; } } return null; }
Example 4
Source File: RestoreDownloadPreference.java From MHViewer with Apache License 2.0 | 5 votes |
private RestoreItem getRestoreItem(UniFile file) { if (null == file || !file.isDirectory()) { return null; } UniFile siFile = file.findFile(SpiderQueen.SPIDER_INFO_FILENAME); if (null == siFile) { return null; } InputStream is = null; try { is = siFile.openInputStream(); SpiderInfo spiderInfo = SpiderInfo.read(is); if (spiderInfo == null) { return null; } String gid = spiderInfo.gid; if (mManager.containDownloadInfo(gid)) { return null; } String token = spiderInfo.token; RestoreItem restoreItem = new RestoreItem(); restoreItem.gid = gid; restoreItem.token = token; restoreItem.dirname = file.getName(); return restoreItem; } catch (IOException e) { return null; } finally { IOUtils.closeQuietly(is); } }
Example 5
Source File: GalleryActivity2.java From Nimingban with Apache License 2.0 | 5 votes |
@Override public void reloadCurrentImage() { GalleryHolder holder = getPagerHolder(0); if (holder == null) { return; } // Unload holder.galleryPage.unload(); // Remove in cache NMBApplication.getConaco(GalleryActivity2.this).getBeerBelly().remove(mImage); // Remove all in save location UniFile dir = Settings.getImageSaveLocation(); if (dir != null) { String name = mSite.getReadableName(GalleryActivity2.this) + "-" + mId; for (String extension : IMAGE_EXTENSIONS) { UniFile file = dir.findFile(name + '.' + extension); if (file != null) { file.delete(); } } } // Load bindPagerHolder(holder, 0); }
Example 6
Source File: GalleryActivity2.java From Nimingban with Apache License 2.0 | 5 votes |
private static UniFile findFileForName(UniFile dir, String name, String[] extensions, String[] resultExtension) { for (String extension : extensions) { UniFile file = dir.findFile(name + '.' + extension); if (file != null) { if (resultExtension != null && resultExtension.length > 0) { resultExtension[0] = extension; } return file; } } return null; }
Example 7
Source File: SpiderQueen.java From EhViewer with Apache License 2.0 | 5 votes |
private synchronized SpiderInfo readSpiderInfoFromLocal() { SpiderInfo spiderInfo = mSpiderInfo.get(); if (spiderInfo != null) { return spiderInfo; } // Read from download dir UniFile downloadDir = mSpiderDen.getDownloadDir(); if (downloadDir != null) { UniFile file = downloadDir.findFile(SPIDER_INFO_FILENAME); spiderInfo = SpiderInfo.read(file); if (spiderInfo != null && spiderInfo.gid == mGalleryInfo.gid && spiderInfo.token.equals(mGalleryInfo.token)) { return spiderInfo; } } // Read from cache InputStreamPipe pipe = mSpiderInfoCache.getInputStreamPipe(Long.toString(mGalleryInfo.gid)); if (null != pipe) { try { pipe.obtain(); spiderInfo = SpiderInfo.read(pipe.open()); if (spiderInfo != null && spiderInfo.gid == mGalleryInfo.gid && spiderInfo.token.equals(mGalleryInfo.token)) { return spiderInfo; } } catch (IOException e) { // Ignore } finally { pipe.close(); pipe.release(); } } return null; }
Example 8
Source File: SpiderDen.java From EhViewer with Apache License 2.0 | 5 votes |
@Nullable private static UniFile findImageFile(UniFile dir, int index) { for (String extension : GalleryProvider2.SUPPORT_IMAGE_EXTENSIONS) { String filename = generateImageFilename(index, extension); UniFile file = dir.findFile(filename); if (file != null) { return file; } } return null; }
Example 9
Source File: RestoreDownloadPreference.java From EhViewer with Apache License 2.0 | 5 votes |
private RestoreItem getRestoreItem(UniFile file) { if (null == file || !file.isDirectory()) { return null; } UniFile siFile = file.findFile(SpiderQueen.SPIDER_INFO_FILENAME); if (null == siFile) { return null; } InputStream is = null; try { is = siFile.openInputStream(); SpiderInfo spiderInfo = SpiderInfo.read(is); if (spiderInfo == null) { return null; } long gid = spiderInfo.gid; if (mManager.containDownloadInfo(gid)) { return null; } String token = spiderInfo.token; RestoreItem restoreItem = new RestoreItem(); restoreItem.gid = gid; restoreItem.token = token; restoreItem.dirname = file.getName(); return restoreItem; } catch (IOException e) { return null; } finally { IOUtils.closeQuietly(is); } }