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


Java DownloadFileInfo.getDownloadedSizeLong方法代码示例

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


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

示例1: createByDownloadFile

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
public static FileDownloadTaskParam createByDownloadFile(DownloadFileInfo downloadFileInfo, String requestMethod,
                                                         Map<String, String> headers) {

    if (downloadFileInfo == null) {
        return null;
    }

    FileDownloadTaskParam fileDownloadTaskParam = new FileDownloadTaskParam(downloadFileInfo.getUrl(), 
            downloadFileInfo.getDownloadedSizeLong(), downloadFileInfo.getFileSizeLong(), downloadFileInfo
            .getETag(), downloadFileInfo.getLastModified(), downloadFileInfo.getAcceptRangeType(), 
            downloadFileInfo.getTempFilePath(), downloadFileInfo.getFilePath());
    fileDownloadTaskParam.mRequestMethod = requestMethod;
    fileDownloadTaskParam.mHeaders = headers;

    return fileDownloadTaskParam;
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:17,代码来源:FileDownloadTaskParam.java

示例2: onFileDownloadStatusPrepared

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusPrepared(DownloadFileInfo downloadFileInfo) {
    // if cur task stopped,stop internal impl, wait notifyTaskFinish()
    if (mIsTaskStop) {
        // stop internal impl
        stopInternalImpl();
        // wait for the task run method finished, notifyTaskFinish()
        return;
    }
    if (mOnFileDownloadStatusListener != null) {
        mOnFileDownloadStatusListener.onFileDownloadStatusPrepared(downloadFileInfo);
    }

    if (DownloadFileUtil.isLegal(downloadFileInfo)) {
        // record download range
        mRecordedRange = new Range(downloadFileInfo.getDownloadedSizeLong(), mRecordedRange.endPos);
    }
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:19,代码来源:RetryableDownloadTaskImpl.java

示例3: onFileDownloadStatusDownloading

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusDownloading(DownloadFileInfo downloadFileInfo, float downloadSpeed, long 
        remainingTime) {

    if (downloadFileInfo == null) {
        return;
    }

    WeakReference<View> weakCacheConvertView = mConvertViews.get(downloadFileInfo.getUrl());
    if (weakCacheConvertView == null || weakCacheConvertView.get() == null) {
        return;
    }

    View cacheConvertView = weakCacheConvertView.get();
    CircleProgressBar barProgress = (CircleProgressBar) cacheConvertView.findViewById(R.id.barProgress);
    if (barProgress == null) {
        return;
    }

    double percent = ((double) downloadFileInfo.getDownloadedSizeLong()) / ((double) downloadFileInfo
            .getFileSizeLong());
    barProgress.setProgress((int) (percent * 100));

    Log.i("wlf", "update barProgress:" + percent);
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:26,代码来源:CustomDownloadFileListAdapter.java

示例4: onFileDownloadStatusPreparing

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusPreparing(DownloadFileInfo downloadFileInfo) {
    // 准备中(即,正在连接资源)
    DownloadTask downloadTask = new DownloadTask(downloadFileInfo.getUrl().hashCode() , downloadFileInfo.getUrl() , downloadFileInfo.getFilePath() ,
            downloadFileInfo.getFileSizeLong() , downloadFileInfo.getDownloadedSizeLong() , System.currentTimeMillis());
    if(mDownloadChangedListener != null){
        mDownloadChangedListener.update(downloadTask);
    }
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:10,代码来源:WCFileDownloader.java

示例5: onFileDownloadStatusCompleted

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusCompleted(DownloadFileInfo downloadFileInfo) {
    // 下载完成(整个文件已经全部下载完成)
    DownloadTask downloadTask = new DownloadTask(downloadFileInfo.getUrl().hashCode() , downloadFileInfo.getUrl() , downloadFileInfo.getFilePath() ,
            downloadFileInfo.getFileSizeLong() , downloadFileInfo.getDownloadedSizeLong() ,-1);
    downloadTask.setFinish(true);
    if(mDownloadChangedListener != null){
        mDownloadChangedListener.update(downloadTask);
    }
    File file = new File(downloadFileInfo.getFilePath());
    if(file != null && file.exists()){
        file.delete();
    }
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:15,代码来源:WCFileDownloader.java

示例6: onFileDownloadStatusFailed

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusFailed(String url, DownloadFileInfo downloadFileInfo, FileDownloadStatusFailReason failReason) {
    // 下载失败了,详细查看失败原因failReason,有些失败原因你可能必须关心
    DownloadTask downloadTask = new DownloadTask(downloadFileInfo.getUrl().hashCode() , downloadFileInfo.getUrl() , downloadFileInfo.getFilePath() ,
            downloadFileInfo.getFileSizeLong() , downloadFileInfo.getDownloadedSizeLong() ,-1);
    downloadTask.setFinish(true);
    if(mDownloadChangedListener != null){
        mDownloadChangedListener.update(downloadTask);
    }
    String failType = failReason.getType();
    String failUrl = failReason.getUrl();// 或:failUrl = url,url和failReason.getUrl()会是一样的

    if(FileDownloadStatusFailReason.TYPE_URL_ILLEGAL.equals(failType)){
        // 下载failUrl时出现url错误
    }else if(FileDownloadStatusFailReason.TYPE_STORAGE_SPACE_IS_FULL.equals(failType)){
        // 下载failUrl时出现本地存储空间不足
    }else if(FileDownloadStatusFailReason.TYPE_NETWORK_DENIED.equals(failType)){
        // 下载failUrl时出现无法访问网络
    }else if(FileDownloadStatusFailReason.TYPE_NETWORK_TIMEOUT.equals(failType)){
        // 下载failUrl时出现连接超时
    }else{
        // 更多错误....
    }

    // 查看详细异常信息
    Throwable failCause = failReason.getCause();// 或:failReason.getOriginalCause()

    // 查看异常描述信息
    String failMsg = failReason.getMessage();// 或:failReason.getOriginalCause().getMessage()
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:31,代码来源:WCFileDownloader.java

示例7: onDownloadFileUpdated

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onDownloadFileUpdated(DownloadFileInfo downloadFileInfo, Type type) {
    // 一个下载文件被更新,也许你需要同步你自己的数据存储,比如在你的业务数据库中更新一条记录
    DownloadTask downloadTask = new DownloadTask(downloadFileInfo.getUrl().hashCode() , downloadFileInfo.getUrl() , downloadFileInfo.getFilePath() ,
            downloadFileInfo.getFileSizeLong() , downloadFileInfo.getDownloadedSizeLong() ,-1);
    if(mDownloadChangedListener != null){
        mDownloadChangedListener.update(downloadTask);
    }
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:10,代码来源:WCFileDownloader.java

示例8: onFileDownloadStatusPaused

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusPaused(DownloadFileInfo downloadFileInfo) {
    // record the state and not notify caller, wait notifyTaskFinish()
    mFinishState = new FinishState(Status.DOWNLOAD_STATUS_PAUSED);

    if (DownloadFileUtil.isLegal(downloadFileInfo)) {
        // record download range
        mRecordedRange = new Range(mRecordedRange.startPos, downloadFileInfo.getDownloadedSizeLong());
    }
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:11,代码来源:RetryableDownloadTaskImpl.java

示例9: onFileDownloadStatusCompleted

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusCompleted(DownloadFileInfo downloadFileInfo) {
    // record the state and not notify caller, wait notifyTaskFinish()
    mFinishState = new FinishState(Status.DOWNLOAD_STATUS_COMPLETED);

    if (DownloadFileUtil.isLegal(downloadFileInfo)) {
        // record download range
        mRecordedRange = new Range(mRecordedRange.startPos, downloadFileInfo.getDownloadedSizeLong());
    }
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:11,代码来源:RetryableDownloadTaskImpl.java

示例10: onFileDownloadStatusFailed

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusFailed(String url, DownloadFileInfo downloadFileInfo,
                                       FileDownloadStatusFailReason failReason) {
    if (DownloadFileUtil.isLegal(downloadFileInfo)) {
        if (downloadFileInfo.getStatus() == Status.DOWNLOAD_STATUS_FILE_NOT_EXIST) {
            // record the state and not notify caller, wait notifyTaskFinish()
            mFinishState = new FinishState(Status.DOWNLOAD_STATUS_FILE_NOT_EXIST, failReason);
        } else {
            // record the state and not notify caller, wait notifyTaskFinish()
            mFinishState = new FinishState(Status.DOWNLOAD_STATUS_ERROR, failReason);
        }
        // record download range
        mRecordedRange = new Range(mRecordedRange.startPos, downloadFileInfo.getDownloadedSizeLong());
    }
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:16,代码来源:RetryableDownloadTaskImpl.java

示例11: isTempFileExist

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
/**
 * whether the temp file is exist
 *
 * @param downloadFileInfo download file
 * @return true means the saved file is exist
 */
public static boolean isTempFileExist(DownloadFileInfo downloadFileInfo) {

    if (!DownloadFileUtil.isLegal(downloadFileInfo)) {
        return false;
    }

    if (downloadFileInfo.getDownloadedSizeLong() >= 0) {
        return FileUtil.isFileExist(downloadFileInfo.getTempFilePath());
    }
    return false;
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:18,代码来源:DownloadFileUtil.java

示例12: onFileDownloadStatusDownloading

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
@Override
public void onFileDownloadStatusDownloading(DownloadFileInfo downloadFileInfo, float downloadSpeed, long 
        remainingTime) {

    if (downloadFileInfo == null) {
        return;
    }

    String url = downloadFileInfo.getUrl();
    View cacheConvertView = mConvertViews.get(url);
    if (cacheConvertView != null) {

        LinearLayout lnlyDownloadItem = (LinearLayout) cacheConvertView.findViewById(R.id.lnlyDownloadItem);
        ProgressBar pbProgress = (ProgressBar) cacheConvertView.findViewById(R.id.pbProgress);
        TextView tvDownloadSize = (TextView) cacheConvertView.findViewById(R.id.tvDownloadSize);
        TextView tvTotalSize = (TextView) cacheConvertView.findViewById(R.id.tvTotalSize);
        TextView tvPercent = (TextView) cacheConvertView.findViewById(R.id.tvPercent);
        TextView tvText = (TextView) cacheConvertView.findViewById(R.id.tvText);

        // download progress
        int totalSize = (int) downloadFileInfo.getFileSizeLong();
        int downloaded = (int) downloadFileInfo.getDownloadedSizeLong();
        double rate = (double) totalSize / Integer.MAX_VALUE;
        if (rate > 1.0) {
            totalSize = Integer.MAX_VALUE;
            downloaded = (int) (downloaded / rate);
        }
        // pbProgress.setMax(totalSize);
        pbProgress.setProgress(downloaded);

        // download size
        double downloadSize = downloadFileInfo.getDownloadedSizeLong() / 1024f / 1024f;
        double fileSize = downloadFileInfo.getFileSizeLong() / 1024f / 1024f;

        tvDownloadSize.setText(((float) (Math.round(downloadSize * 100)) / 100) + "M/");
        tvTotalSize.setText(((float) (Math.round(fileSize * 100)) / 100) + "M");

        // download percent
        double percent = downloadSize / fileSize * 100;
        tvPercent.setText(((float) (Math.round(percent * 100)) / 100) + "%");

        // download speed and remain times
        String speed = ((float) (Math.round(downloadSpeed * 100)) / 100) + "KB/s" + "  " + TimeUtil
                .seconds2HH_mm_ss(remainingTime);
        tvText.setText(speed);
        tvText.setTag(speed);

        setBackgroundOnClickListener(lnlyDownloadItem, downloadFileInfo);
    } else {
        updateShow();
    }

    Log.d(TAG, "onFileDownloadStatusDownloading url:" + url + ",status(正常应该是" + Status
            .DOWNLOAD_STATUS_DOWNLOADING + "):" + downloadFileInfo.getStatus());
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:56,代码来源:DownloadFileListAdapter.java

示例13: notifyStatusDownloading

import org.wlf.filedownloader.DownloadFileInfo; //导入方法依赖的package包/类
/**
 * notify downloading status to callback
 *
 * @return true means can go on,otherwise need to stop all the operations that will occur
 */
private boolean notifyStatusDownloading(int increaseSize) {
    try {
        mDownloadRecorder.recordStatus(getUrl(), Status.DOWNLOAD_STATUS_DOWNLOADING, increaseSize);

        DownloadFileInfo downloadFileInfo = getDownloadFile();
        if (downloadFileInfo == null) {
            // if error, make sure the increaseSize is zero
            increaseSize = 0;
            FileDownloadStatusFailReason failReason = new OnFileDownloadStatusFailReason(getUrl(), "the " +
                    "DownloadFile is " + "null!", OnFileDownloadStatusFailReason.TYPE_NULL_POINTER);
            mFinishState = new FinishState(Status.DOWNLOAD_STATUS_ERROR, increaseSize, failReason);

            return false;
        }

        if (mOnFileDownloadStatusListener != null) {
            double downloadSpeed = 0;
            long remainingTime = -1;
            long curDownloadingTime = SystemClock.elapsedRealtime();// current time
            // calculate download speed
            if (mLastDownloadingTime != -1) {
                double increaseKbs = (double) increaseSize / 1024;
                double increaseSeconds = (curDownloadingTime - mLastDownloadingTime) / (double) 1000;
                downloadSpeed = increaseKbs / increaseSeconds;// download speed, KB/s
            }
            // calculate remain time
            if (downloadSpeed > 0) {
                long remainingSize = downloadFileInfo.getFileSizeLong() - downloadFileInfo.getDownloadedSizeLong();
                if (remainingSize > 0) {
                    remainingTime = (long) (((double) remainingSize / 1024) / downloadSpeed);
                }
            }
            mLastDownloadingTime = curDownloadingTime;

            if (mOnFileDownloadStatusListener != null) {
                mOnFileDownloadStatusListener.onFileDownloadStatusDownloading(downloadFileInfo, (float)
                        downloadSpeed, remainingTime);
            }
        }

        Log.i(TAG, "file-downloader-status 记录【正在下载状态】成功,url:" + getUrl());

        return true;
    } catch (Exception e) {
        e.printStackTrace();
        // if error, make sure the increaseSize is zero
        increaseSize = 0;
        mFinishState = new FinishState(Status.DOWNLOAD_STATUS_ERROR, increaseSize, new
                OnFileDownloadStatusFailReason(getUrl(), e));
        return false;
    }
}
 
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:58,代码来源:DownloadTaskImpl.java


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