com.blankj.utilcode.util.FileUtils Java Examples
The following examples show how to use
com.blankj.utilcode.util.FileUtils.
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: CameraHandler.java From FastWaiMai with MIT License | 6 votes |
private void takePhoto() { final String currentPhotoName = getPhotoName(); final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final File tempFile = new File(FileUtil.CAMERA_PHOTO_DIR, currentPhotoName); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { final ContentValues contentValues = new ContentValues(1); contentValues.put(MediaStore.Images.Media.DATA, tempFile.getPath()); final Uri uri = DELEGATE.getContext().getContentResolver(). insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues); //需要将Uri路径转化为实际路径 final File realFile = FileUtils.getFileByPath(FileUtil.getRealFilePath(DELEGATE.getContext(), uri)); final Uri realUri = Uri.fromFile(realFile); CameraImageBean.getInstance().setPath(realUri); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); } else { final Uri fileUri = Uri.fromFile(tempFile); CameraImageBean.getInstance().setPath(fileUri); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); } DELEGATE.startActivityForResult(intent, CameraRequestCodes.TAKE_PHOTO); }
Example #2
Source File: FileHelper.java From AndroidUtilCode with Apache License 2.0 | 6 votes |
@FileType public static int getFileType(File file) { if (!FileUtils.isFileExists(file)) return UNKNOWN; if (ImageUtils.isImage(file)) { return IMAGE; } if (FileUtils.getFileExtension(file).equals("xml")) { File parentFile = file.getParentFile(); if (parentFile != null) { if (StringUtils.equals(parentFile.getName(), "shared_prefs")) { return SP; } } } if (FileUtils.isUtf8(file)) { return UTF8; } return UNKNOWN; }
Example #3
Source File: ImageLoader.java From AndroidUtilCode with Apache License 2.0 | 6 votes |
public static void load(final File file, final ImageView imageView) { if (!FileUtils.isFileExists(file)) return; imageView.post(new Runnable() { @Override public void run() { ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<Bitmap>() { @Override public Bitmap doInBackground() throws Throwable { return ImageUtils.getBitmap(file, imageView.getWidth(), imageView.getHeight()); } @Override public void onSuccess(final Bitmap result) { imageView.setImageBitmap(result); } }); } }); }
Example #4
Source File: FileItem.java From AndroidUtilCode with Apache License 2.0 | 6 votes |
public static List<FileItem> getFileItems(final FileItem parent) { if (parent == null) return getFileItems(); List<File> files = FileUtils.listFilesInDir(parent.getFile(), new Comparator<File>() { @Override public int compare(File o1, File o2) { if (o1.isDirectory() && o2.isFile()) { return -1; } else if (o1.isFile() && o2.isDirectory()) { return 1; } else { return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase()); } } }); return (List<FileItem>) CollectionUtils.collect(files, new CollectionUtils.Transformer<File, FileItem>() { @Override public FileItem transform(File input) { return new FileItem(parent, input); } }); }
Example #5
Source File: ImagePresenter.java From SuperNote with GNU General Public License v3.0 | 6 votes |
private void deleteFile(final Activity activity){ new AsyncTask<String,Integer,Boolean>(){ @Override protected void onPreExecute() { mView.showLoading("删除中..."); } @Override protected Boolean doInBackground(String... params) { return FileUtils.deleteFile(getImageFile(activity)); } @Override protected void onPostExecute(Boolean aBoolean) { mView.unShowLoading(); if(aBoolean){ mView.setResultAndFinish(); } else { ToastUtils.showShort("删除失败"); } } }.execute(); }
Example #6
Source File: ImagePresenter.java From SuperNote with GNU General Public License v3.0 | 6 votes |
private void copyFile( final Activity activity){ new AsyncTask<String,Integer,Boolean>(){ @Override protected void onPreExecute() { mView.showLoading("保存中..."); } @Override protected Boolean doInBackground(String... params) { return FileUtils.copyFile(getImageFile(activity), new File(Constans.imageSaveFolder+mImageName)); } @Override protected void onPostExecute(Boolean aBoolean) { mView.unShowLoading(); if(aBoolean){ ToastUtils.showLong("已保存至/SuperNote/image/中"); } else { ToastUtils.showLong("保存失败,请查看图片是否已存在"); } } }.execute(); }
Example #7
Source File: EditNotePresenter.java From SuperNote with GNU General Public License v3.0 | 6 votes |
private void copyFileInOtherThread(String imagePath) { final String imagePaths = imagePath; new AsyncTask<String, Integer, Boolean>() { @Override protected void onPreExecute() { mView.showLoading("加载中..."); } @Override protected Boolean doInBackground(String... params) { return FileUtils.copyFile(new File(imagePaths), mImageFile); } @Override protected void onPostExecute(Boolean aBoolean) { mView.unShowLoading(); if (aBoolean) { displayImage(); } else { ToastUtils.showShort("图片读取失败"); } } }.execute(); }
Example #8
Source File: SmbFilePresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
private String checkZimuExist(List<SmbFileInfo> smbFileInfoList, String fullVideoName) { //获取smb视频文件名:test.mp4 -> test. String videoName = FileUtils.getFileNameNoExtension(fullVideoName) + "."; for (SmbFileInfo fileInfo : smbFileInfoList) { String fileName = fileInfo.getFileName(); //是否以视频文件名开头:可test.ass,不可test1.ass if (fileName.startsWith(videoName)) { //是否为可解析字幕:可.ass,不可.1ass for (String ext : CommonPlayerUtils.subtitleExtension) { if (fileName.toUpperCase().endsWith("." + ext)) { //是否只包含最多两个点:可test.ass、test.sc.ass,不可test.1.sc.ass int pointCount = fileName.split(".").length - 1; if (pointCount <= 2) { return fileName; } } } } } return null; }
Example #9
Source File: TaskDownloadingFileItem.java From DanDanPlayForAndroid with MIT License | 6 votes |
@SuppressLint("SetTextI18n") @Override public void onUpdateViews(TorrentChildFile model, int position) { String fileName = FileUtils.getFileName(model.getFileName()); fileNameTv.setText(fileName); //文件是否忽略下载 if (model.isChecked()) { fileNameTv.setTextColor(CommonUtils.getResColor(R.color.text_black)); int progress = model.getFileSize() == 0 ? 0 : (int) (model.getFileReceived() * 100 / model.getFileSize()); downloadDurationPb.setProgress(progress); String duration = CommonUtils.convertFileSize(model.getFileReceived()) + "/" + CommonUtils.convertFileSize(model.getFileSize()); duration += " (" + progress + "%)"; durationTv.setText(duration); } else { fileNameTv.setTextColor(CommonUtils.getResColor(R.color.text_gray)); downloadDurationPb.setProgress(0); durationTv.setText("已忽略"); } }
Example #10
Source File: DownloadedFragment.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void onTaskDelete(int position, String taskHash, boolean withFile) { //删除系统中文件 if (withFile) { FileUtils.deleteDir(taskList.get(position).getSaveDirPath()); } //删除数据库中信息 DataBaseManager.getInstance() .selectTable("downloaded_task") .delete() .where("torrent_hash", taskHash) .postExecute(); DataBaseManager.getInstance() .selectTable("downloaded_file") .delete() .where("task_torrent_hash", taskHash) .postExecute(); //刷新媒体库数据 EventBus.getDefault().post(UpdateFragmentEvent.updatePlay(PlayFragment.UPDATE_SYSTEM_DATA)); //更新界面数据 if (position > -1 && position < taskList.size()) taskRvAdapter.removeItem(position); }
Example #11
Source File: MainPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void initTracker() { IApplication.getExecutor().execute(() -> { //trackers数据 File configFolder = new File(FileUtils.getDirName(Constants.DefaultConfig.configPath)); if (configFolder.isFile()) configFolder.delete(); if (!configFolder.exists()) configFolder.mkdirs(); File trackerFile = new File(Constants.DefaultConfig.configPath); //文件不存在,读取asset中默认的trackers,并写入文件 if (!trackerFile.exists()) { TrackerManager.resetTracker(); } //文件存在,直接读取 else { TrackerManager.queryTracker(); } }); }
Example #12
Source File: NetWorkMonitorFragment.java From DoraemonKit with Apache License 2.0 | 6 votes |
@Override public void onDestroy() { super.onDestroy(); //保存白名单 List<WhiteHostBean> hostBeans = mHostAdapter.getData(); if (hostBeans.size() == 1 && TextUtils.isEmpty(hostBeans.get(0).getHost())) { DokitConstant.WHITE_HOSTS.clear(); FileUtils.delete(whiteHostPath); return; } DokitConstant.WHITE_HOSTS.clear(); DokitConstant.WHITE_HOSTS.addAll(hostBeans); String hostArray = GsonUtils.toJson(hostBeans); //保存到本地 FileUtils.delete(whiteHostPath); FileIOUtils.writeFileFromString(whiteHostPath, hostArray); //ToastUtils.showShort("host白名单已保存"); }
Example #13
Source File: MD5Util.java From DanDanPlayForAndroid with MIT License | 6 votes |
public static String getVideoFileHash(String filePath) { try { File file = FileUtils.getFileByPath(filePath); if (file != null) { if (file.length() < 16 * 1024 * 1024) { return getFileMD5String(file); } else { RandomAccessFile r = new RandomAccessFile(file, "r"); r.seek(0); byte[] bs = new byte[16 * 1024 * 1024]; r.read(bs); return getMD5String(bs); } } } catch (IOException e) { e.printStackTrace(); } return ""; }
Example #14
Source File: SubtitleConverter.java From DanDanPlayForAndroid with MIT License | 6 votes |
private static List<SubtitleBean> shooter2subtitle(List<SubtitleBean.Shooter> shooterList, String filePath){ if (shooterList == null || shooterList.size() == 0){ return new ArrayList<>(); } List<SubtitleBean> subtitleList = new ArrayList<>(); for (SubtitleBean.Shooter shooterBean : shooterList){ for (SubtitleBean.Shooter.FilesBean shooterFile : shooterBean.getFiles()){ if (StringUtils.isEmpty(shooterFile.getLink())) continue; SubtitleBean subtitleBean = new SubtitleBean(); subtitleBean.setOrigin(SubtitleBean.Shooter.SHOOTER); subtitleBean.setName(FileUtils.getFileNameNoExtension(filePath) + "." + shooterFile.getExt()); subtitleBean.setRank(-1); subtitleBean.setUrl(shooterFile.getLink()); subtitleList.add(subtitleBean); } } return subtitleList; }
Example #15
Source File: FolderActivity.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void openIntentVideo(VideoBean videoBean) { boolean isExoPlayer = AppConfig.getInstance().getPlayerType() == com.xyoye.player.commom.utils.Constants.EXO_PLAYER; if (!isExoPlayer && FileUtils.getFileExtension(videoBean.getVideoPath()).toLowerCase().equals(".MKV") && AppConfig.getInstance().isShowMkvTips()) { new CommonDialog.Builder(this) .setAutoDismiss() .setOkListener(dialog -> launchPlay(videoBean)) .setCancelListener(dialog -> launchActivity(PlayerSettingActivity.class)) .setDismissListener(dialog -> AppConfig.getInstance().hideMkvTips()) .build() .show(getResources().getString(R.string.mkv_tips), "关于MKV格式", "我知道了", "前往设置"); } else { launchPlay(videoBean); } }
Example #16
Source File: PictureActivity.java From AndroidSamples with Apache License 2.0 | 5 votes |
/** * 使用UCrop进行图片剪裁 * * @param uri */ public void cropRawPhoto(Uri uri) { UCrop.Options options = new UCrop.Options(); // 修改标题栏颜色 options.setToolbarColor(getResources().getColor(R.color.colorPrimary)); // 修改状态栏颜色 options.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark)); // 隐藏底部工具 options.setHideBottomControls(true); // 图片格式 options.setCompressionFormat(Bitmap.CompressFormat.JPEG); // 设置图片压缩质量 options.setCompressionQuality(100); // 是否让用户调整范围(默认false),如果开启,可能会造成剪切的图片的长宽比不是设定的 // 如果不开启,用户不能拖动选框,只能缩放图片 options.setFreeStyleCropEnabled(true); // 设置图片压缩质量 options.setCompressionQuality(100); // 圆 options.setCircleDimmedLayer(true); // 不显示网格线 options.setShowCropGrid(false); FileUtils.createOrExistsDir(Config.SAVE_REAL_PATH); // 设置源uri及目标uri UCrop.of(uri, Uri.fromFile(new File(Config.SAVE_REAL_PATH, System.currentTimeMillis() + ".jpg"))) // 长宽比 .withAspectRatio(1, 1) // 图片大小 .withMaxResultSize(200, 200) // 配置参数 .withOptions(options) .start(this); }
Example #17
Source File: FileOperator.java From Pixiv-Shaft with MIT License | 5 votes |
@Override public void clearAll() { if (FileUtils.delete(PathUtils.getInternalAppCachePath())) { ToastUtils.showShort("清除成功!"); } else { ToastUtils.showShort("清除失败!"); } }
Example #18
Source File: ClearCacheDebug.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
private ThreadUtils.SimpleTask<Long> createClearCacheTask() { return new ThreadUtils.SimpleTask<Long>() { @Override public Long doInBackground() throws Throwable { try { long len = 0; File appDataDir = new File(PathUtils.getInternalAppDataPath()); if (appDataDir.exists()) { String[] names = appDataDir.list(); for (String name : names) { if (!name.equals("lib")) { File file = new File(appDataDir, name); len += FileUtils.getLength(file); FileUtils.delete(file); LogUtils.i("「" + file + "」 was deleted."); } } } String externalAppCachePath = PathUtils.getExternalAppCachePath(); len += FileUtils.getLength(externalAppCachePath); FileUtils.delete(externalAppCachePath); LogUtils.i("「" + externalAppCachePath + "」 was deleted."); return len; } catch (Exception e) { ToastUtils.showLong(e.toString()); return -1L; } } @Override public void onSuccess(Long result) { if (result != -1) { ToastUtils.showLong("Clear Cache: " + ConvertUtils.byte2FitMemorySize(result)); } } }; }
Example #19
Source File: UtilsApp.java From Android-UtilCode with Apache License 2.0 | 5 votes |
private void initAssets() { if (!FileUtils.isFileExists(Config.getTestApkPath())) { try { FileIOUtils.writeFileFromIS(Config.getTestApkPath(), getAssets().open("test_install.apk"), false); } catch (IOException e) { e.printStackTrace(); } } }
Example #20
Source File: ExoPlayerView.java From DanDanPlayForAndroid with MIT License | 5 votes |
/** * 设置弹幕资源 */ public ExoPlayerView setDanmakuSource(String danmuPath) { if (TextUtils.isEmpty(danmuPath) || !FileUtils.isFileExists(danmuPath)) { return this; } try { mDanmakuLoader.load(danmuPath); IDataSource<?> dataSource = mDanmakuLoader.getDataSource(); mDanmakuParser.load(dataSource); } catch (IllegalDataException e) { e.printStackTrace(); ToastUtils.showShort("弹幕加载失败"); } return this; }
Example #21
Source File: IjkPlayerView.java From DanDanPlayForAndroid with MIT License | 5 votes |
/** * 设置弹幕资源 */ public IjkPlayerView setDanmakuSource(String danmuPath) { if (TextUtils.isEmpty(danmuPath) || !FileUtils.isFileExists(danmuPath)) { return this; } try { mDanmakuLoader.load(danmuPath); IDataSource<?> dataSource = mDanmakuLoader.getDataSource(); mDanmakuParser.load(dataSource); } catch (IllegalDataException e) { e.printStackTrace(); ToastUtils.showShort("弹幕加载失败"); } return this; }
Example #22
Source File: FolderActivity.java From DanDanPlayForAndroid with MIT License | 5 votes |
/** * 启动播放器 * * @param videoBean 数据 */ private void launchPlay(VideoBean videoBean) { //记录此次播放 AppConfig.getInstance().setLastPlayVideo(videoBean.getVideoPath()); EventBus.getDefault().post(UpdateFragmentEvent.updatePlay(PlayFragment.UPDATE_ADAPTER_DATA)); PlayerManagerActivity.launchPlayerLocal( this, FileUtils.getFileNameNoExtension(videoBean.getVideoPath()), videoBean.getVideoPath(), videoBean.getDanmuPath(), videoBean.getZimuPath(), videoBean.getCurrentPosition(), videoBean.getEpisodeId()); }
Example #23
Source File: FolderActivity.java From DanDanPlayForAndroid with MIT License | 5 votes |
@SuppressLint("CheckResult") @Override public void downloadDanmu(DanmuMatchBean.MatchesBean matchesBean) { new DanmuDownloadDialog(this, selectVideoBean.getVideoPath(), matchesBean, (danmuPath, episodeId) -> { selectVideoBean.setDanmuPath(danmuPath); selectVideoBean.setEpisodeId(episodeId); String folderPath = FileUtils.getDirName(selectVideoBean.getVideoPath()); presenter.updateDanmu(danmuPath, episodeId, new String[]{folderPath, selectVideoBean.getVideoPath()}); adapter.notifyItemChanged(selectPosition); openIntentVideo(selectVideoBean); }).show(); }
Example #24
Source File: SmbFileActivity.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void launchPlayerActivity(String videoUrl, String zimu) { PlayerManagerActivity.launchPlayerSmb( SmbFileActivity.this, FileUtils.getFileNameNoExtension(videoUrl), videoUrl, zimu ); }
Example #25
Source File: ScanManagerPresenterImpl.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void saveNewVideo(List<String> pathList) { newAddCount = 0; IApplication.getSqlThreadPool().execute(() -> { for (String videoPath : pathList) { String folderPath = FileUtils.getDirName(videoPath); DataBaseManager.getInstance() .selectTable("file") .query() .where("folder_path", folderPath) .where("file_path", videoPath) .executeAsync(cursor -> { if (!cursor.moveToNext()) { VideoBean videoBean = queryFormSystem(videoPath); DataBaseManager.getInstance() .selectTable("file") .insert() .param("folder_path", folderPath) .param("file_path", videoBean.getVideoPath()) .param("duration", String.valueOf(videoBean.getVideoDuration())) .param("file_size", String.valueOf(videoBean.getVideoSize())) .param("file_id", videoBean.get_id()) .executeAsync(); EventBus.getDefault().post(UpdateFragmentEvent.updatePlay(PlayFragment.UPDATE_DATABASE_DATA)); newAddCount++; } }); } ToastUtils.showShort("扫描完成,新增:" + newAddCount); }); }
Example #26
Source File: FolderItem.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void onUpdateViews(FolderBean model, int position) { String folder = model.getFolderPath(); String title = CommonUtils.getFolderName(folder); folderTitle.setText(title); fileNumber.setText(String.format("%s 视频", model.getFileNumber())); //是否为上次播放的文件夹 boolean isLastPlayFolder = false; String lastVideoPath = AppConfig.getInstance().getLastPlayVideo(); if (!StringUtils.isEmpty(lastVideoPath)) { String folderPath = FileUtils.getDirName(lastVideoPath); isLastPlayFolder = folderPath.equals(model.getFolderPath()); } folderTitle.setTextColor(isLastPlayFolder ? CommonUtils.getResColor(R.color.immutable_text_theme) : CommonUtils.getResColor(R.color.text_black)); fileNumber.setTextColor(isLastPlayFolder ? CommonUtils.getResColor(R.color.immutable_text_theme) : CommonUtils.getResColor(R.color.text_gray)); contentLayout.setOnClickListener(v -> listener.onClick(model.getFolderPath())); shieldFolderTv.setOnClickListener(v -> listener.onShield(model.getFolderPath(), title)); deleteFolderTv.setOnClickListener(v -> listener.onDelete(model.getFolderPath(), title)); }
Example #27
Source File: ShooterSubDetailDialog.java From DanDanPlayForAndroid with MIT License | 5 votes |
@SuppressLint("SetTextI18n") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_shooter_subtitle_detail); ButterKnife.bind(this); String fileName = detailBean.getFilename() == null ? "" : detailBean.getFilename(); String fileExtension = FileUtils.getFileExtension(fileName).toLowerCase(); //不是可解压的文件 if (SevenZipUtils.getArchiveFormat(fileExtension) == null){ downloadUnzipTv.setVisibility(View.GONE); downloadTv.setBackground(CommonUtils.getResDrawable(R.drawable.background_dialog_button_positive)); } subtitleFileNameEt.setText(fileName); subtitleFileNameEt.setSelection(fileName.length()); subtitleFileSizeTv.setText(CommonUtils.convertFileSize(detailBean.getSize())); subtitleLanguageTv.setText(detailBean.getLang() == null ? "无" : detailBean.getLang().getDesc()); if (detailBean.getProducer() == null || TextUtils.isEmpty(detailBean.getProducer().getSource())) { subtitleSourceTv.setVisibility(View.GONE); } else { subtitleSourceTv.setVisibility(View.VISIBLE); subtitleSourceTv.setText("制作: " + detailBean.getProducer().getProducer()); } }
Example #28
Source File: SubtitleRequester.java From DanDanPlayForAndroid with MIT License | 5 votes |
public static void querySubtitle(String videoPath, CommOtherDataObserver<List<SubtitleBean>> subtitleObserver) { //只查找本地视频字幕 String localPath = Environment.getExternalStorageDirectory().getAbsolutePath(); if (!videoPath.startsWith(localPath)) return; String thunderHash = HashUtils.getFileSHA1(videoPath); String shooterHash = HashUtils.getFileHash(videoPath); if (!StringUtils.isEmpty(thunderHash) && !StringUtils.isEmpty(shooterHash)) { Map<String, String> shooterParams = new HashMap<>(); shooterParams.put("filehash", shooterHash); shooterParams.put("pathinfo", FileUtils.getFileName(videoPath)); shooterParams.put("format", "json"); shooterParams.put("lang", "Chn"); SubtitleRetrofitService service = RetroFactory.getSubtitleInstance(); Observable<List<SubtitleBean.Shooter>> shooterObservable = service.queryShooter(shooterParams) .onErrorReturnItem(new ArrayList<>()); service.queryThunder(thunderHash) .onErrorReturnItem(new SubtitleBean.Thunder()) .zipWith(shooterObservable, (thunder, shooters) -> SubtitleConverter.transform(thunder, shooters, videoPath)) .doOnSubscribe(new NetworkConsumer()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(subtitleObserver); } }
Example #29
Source File: BindDanmuPresenterImpl.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void matchDanmu(String videoPath) { if (StringUtils.isEmpty(videoPath)) { ToastUtils.showShort("无匹配弹幕"); return; } String title = FileUtils.getFileName(videoPath); String hash = MD5Util.getVideoFileHash(videoPath); long length = new File(videoPath).length(); long duration = MD5Util.getVideoDuration(videoPath); DanmuMatchParam param = new DanmuMatchParam(); param.setFileName(title); param.setFileHash(hash); param.setFileSize(length); param.setVideoDuration(duration); param.setMatchMode("hashAndFileName"); getView().showLoading(); DanmuMatchBean.matchDanmu(param, new CommJsonObserver<DanmuMatchBean>(getLifecycle()) { @Override public void onSuccess(DanmuMatchBean danmuMatchBean) { getView().hideLoading(); if (danmuMatchBean.getMatches().size() > 0) getView().refreshDanmuAdapter(danmuMatchBean.getMatches()); else ToastUtils.showShort("无匹配弹幕"); } @Override public void onError(int errorCode, String message) { getView().hideLoading(); ToastUtils.showShort(message); } }, new NetworkConsumer()); }
Example #30
Source File: FolderPresenterImpl.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void getDanmu(String videoPath) { getView().showLoading(); String title = FileUtils.getFileName(videoPath); DanmuMatchParam param = new DanmuMatchParam(); String hash = MD5Util.getVideoFileHash(videoPath); long length = new File(videoPath).length(); long duration = MD5Util.getVideoDuration(videoPath); param.setFileName(title); param.setFileHash(hash); param.setFileSize(length); param.setVideoDuration(duration); param.setMatchMode("hashAndFileName"); DanmuMatchBean.matchDanmu(param, new CommJsonObserver<DanmuMatchBean>(getLifecycle()) { @Override public void onSuccess(DanmuMatchBean danmuMatchBean) { getView().hideLoading(); if (danmuMatchBean.getMatches().size() > 0) getView().downloadDanmu(danmuMatchBean.getMatches().get(0)); else getView().noMatchDanmu(videoPath); } @Override public void onError(int errorCode, String message) { getView().hideLoading(); getView().noMatchDanmu(videoPath); } }, new NetworkConsumer()); }