本文整理匯總了Java中com.hippo.unifile.UniFile.subFile方法的典型用法代碼示例。如果您正苦於以下問題:Java UniFile.subFile方法的具體用法?Java UniFile.subFile怎麽用?Java UniFile.subFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hippo.unifile.UniFile
的用法示例。
在下文中一共展示了UniFile.subFile方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeFromDownloadDir
import com.hippo.unifile.UniFile; //導入方法依賴的package包/類
private boolean removeFromDownloadDir(int index) {
UniFile dir = getDownloadDir();
if (dir == null) {
return false;
}
boolean result = false;
for (int i = 0, n = GalleryProvider2.SUPPORT_IMAGE_EXTENSIONS.length; i < n; i++) {
String filename = generateImageFilename(index, GalleryProvider2.SUPPORT_IMAGE_EXTENSIONS[i]);
UniFile file = dir.subFile(filename);
if (file != null) {
result |= file.delete();
}
}
return result;
}
示例2: save
import com.hippo.unifile.UniFile; //導入方法依賴的package包/類
@Nullable
public UniFile save(int index, @NonNull UniFile dir, @NonNull String filename) {
int state = getPageState(index);
if (STATE_FINISHED != state) {
return null;
}
InputStreamPipe pipe = mSpiderDen.openInputStreamPipe(index);
if (null == pipe) {
return null;
}
OutputStream os = null;
try {
pipe.obtain();
// Get dst file
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(pipe.open(), null, options);
pipe.close();
String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(options.outMimeType);
UniFile dst = dir.subFile(null != extension ? filename + "." + extension : filename);
if (null == dst) {
return null;
}
// Copy
os = dst.openOutputStream();
IOUtils.copy(pipe.open(), os);
return dst;
} catch (IOException e) {
return null;
} finally {
pipe.close();
pipe.release();
IOUtils.closeQuietly(os);
}
}
示例3: save
import com.hippo.unifile.UniFile; //導入方法依賴的package包/類
@Nullable
@Override
public UniFile save(int index, @NonNull UniFile dir, @NonNull String filename) {
UniFile[] fileList = mFileList.get();
if (null == fileList || index < 0 || index >= fileList.length) {
return null;
}
UniFile src = fileList[index];
String extension = FileUtils.getExtensionFromFilename(src.getName());
UniFile dst = dir.subFile(null != extension ? filename + "." + extension : filename);
if (null == dst) {
return null;
}
InputStream is = null;
OutputStream os = null;
try {
is = src.openInputStream();
os = dst.openOutputStream();
IOUtils.copy(is, os);
return dst;
} catch (IOException e) {
return null;
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
示例4: removeNoMediaFile
import com.hippo.unifile.UniFile; //導入方法依賴的package包/類
public static void removeNoMediaFile(UniFile file) {
if (null == file) {
return;
}
UniFile noMedia = file.subFile(".nomedia");
if (null != noMedia && noMedia.isFile()) {
noMedia.delete();
}
}
示例5: getGalleryDownloadDir
import com.hippo.unifile.UniFile; //導入方法依賴的package包/類
public static UniFile getGalleryDownloadDir(GalleryInfo galleryInfo) {
UniFile dir = Settings.getDownloadLocation();
if (dir != null) {
// Read from DB
String dirname = EhDB.getDownloadDirname(galleryInfo.gid);
if (null != dirname) {
// Some dirname may be invalid in some version
dirname = FileUtils.sanitizeFilename(dirname);
EhDB.putDownloadDirname(galleryInfo.gid, dirname);
}
// Find it
if (null == dirname) {
UniFile[] files = dir.listFiles(new StartWithFilenameFilter(galleryInfo.gid + "-"));
if (null != files) {
// Get max-length-name dir
int maxLength = -1;
for (UniFile file : files) {
if (file.isDirectory()) {
String name = file.getName();
int length = name.length();
if (length > maxLength) {
maxLength = length;
dirname = name;
}
}
}
if (null != dirname) {
EhDB.putDownloadDirname(galleryInfo.gid, dirname);
}
}
}
// Create it
if (null == dirname) {
dirname = FileUtils.sanitizeFilename(galleryInfo.gid + "-" + EhUtils.getSuitableTitle(galleryInfo));
EhDB.putDownloadDirname(galleryInfo.gid, dirname);
}
return dir.subFile(dirname);
} else {
return null;
}
}