当前位置: 首页>>代码示例>>Java>>正文


Java UniFile.createFile方法代码示例

本文整理汇总了Java中com.hippo.unifile.UniFile.createFile方法的典型用法代码示例。如果您正苦于以下问题:Java UniFile.createFile方法的具体用法?Java UniFile.createFile怎么用?Java UniFile.createFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hippo.unifile.UniFile的用法示例。


在下文中一共展示了UniFile.createFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openDownloadOutputStreamPipe

import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
/**
 * @param extension without dot
 */
@Nullable
private OutputStreamPipe openDownloadOutputStreamPipe(int index, @Nullable String extension) {
    UniFile dir = getDownloadDir();
    if (dir == null) {
        return null;
    }

    extension = fixExtension('.' + extension);
    UniFile file = dir.createFile(generateImageFilename(index, extension));
    if (file != null) {
        return new UniFileOutputStreamPipe(file);
    } else {
        return null;
    }
}
 
开发者ID:seven332,项目名称:EhViewer,代码行数:19,代码来源:SpiderDen.java

示例2: ensureNoMediaFile

import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
public static void ensureNoMediaFile(UniFile file) {
    if (null == file) {
        return;
    }

    UniFile noMedia = file.createFile(".nomedia");
    if (null == noMedia) {
        return;
    }

    InputStream is = null;
    try {
        is = noMedia.openInputStream();
    } catch (IOException e) {
        // Ignore
    } finally {
        IOUtils.closeQuietly(is);
    }
}
 
开发者ID:seven332,项目名称:EhViewer,代码行数:20,代码来源:CommonOperations.java

示例3: save

import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
@Override
public boolean save(InputStream is, long length, String mediaType, ProgressNotify notify) {
    OutputStream os = null;
    try {
        boolean autoSave = Settings.getSaveImageAuto() && mName != null;
        if (autoSave) {
            String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mediaType);
            if (TextUtils.isEmpty(extension)) {
                extension = "jpg";
            }
            String filename = mName + '.' + extension;
            UniFile dir = Settings.getImageSaveLocation();
            if (dir != null) {
                mTempFile = dir.createFile(filename);
            } else {
                mTempFile = UniFile.fromFile(NMBAppConfig.createTempFileWithFilename(filename));
            }
        } else {
            mTempFile = UniFile.fromFile(NMBAppConfig.createTempFile());
        }

        if (mTempFile == null) {
            return false;
        }
        os = mTempFile.openOutputStream();
        IOUtils.copy(is, os);

        // Notify media scanner
        if (autoSave) {
            mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, mTempFile.getUri()));
        }

        return true;
    } catch (IOException e) {
        return false;
    } finally {
        IOUtils.closeQuietly(os);
    }
}
 
开发者ID:seven332,项目名称:Nimingban,代码行数:40,代码来源:HeaderImageView.java

示例4: ensureFile

import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
private void ensureFile() {
    if (mFile == null) {
        UniFile dir = SpiderDen.getGalleryDownloadDir(mInfo);
        if (dir != null && dir.isDirectory()) {
            mFile = dir.createFile(".thumb");
        }
    }
}
 
开发者ID:seven332,项目名称:EhViewer,代码行数:9,代码来源:DownloadsScene.java

示例5: copyFromCacheToDownloadDir

import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
private boolean copyFromCacheToDownloadDir(int index) {
    if (sCache == null) {
        return false;
    }
    UniFile dir = getDownloadDir();
    if (dir == null) {
        return false;
    }
    // Find image file in cache
    String key = EhCacheKeyFactory.getImageKey(mGid, index);
    InputStreamPipe pipe = sCache.getInputStreamPipe(key);
    if (pipe == null) {
        return false;
    }

    OutputStream os = null;
    try {
        // Get extension
        String extension;
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        pipe.obtain();
        BitmapFactory.decodeStream(pipe.open(), null, options);
        pipe.close();
        extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(options.outMimeType);
        if (extension != null) {
            extension = '.' + extension;
        } else {
            return false;
        }
        // Fix extension
        extension = fixExtension(extension);
        // Copy from cache to download dir
        UniFile file = dir.createFile(generateImageFilename(index, extension));
        if (file == null) {
            return false;
        }
        os = file.openOutputStream();
        IOUtils.copy(pipe.open(), os);
        return true;
    } catch (IOException e) {
        return false;
    } finally {
        IOUtils.closeQuietly(os);
        pipe.close();
        pipe.release();
    }
}
 
开发者ID:seven332,项目名称:EhViewer,代码行数:49,代码来源:SpiderDen.java


注:本文中的com.hippo.unifile.UniFile.createFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。