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


Java OkGo.REFRESH_TIME属性代码示例

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


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

示例1: changeProgress

public static Progress changeProgress(final Progress progress, long writeSize, long totalSize, final Action action) {
    progress.totalSize = totalSize;
    progress.currentSize += writeSize;
    progress.tempSize += writeSize;

    long currentTime = SystemClock.elapsedRealtime();
    boolean isNotify = (currentTime - progress.lastRefreshTime) >= OkGo.REFRESH_TIME;
    if (isNotify || progress.currentSize == totalSize) {
        long diffTime = currentTime - progress.lastRefreshTime;
        if (diffTime == 0) diffTime = 1;
        progress.fraction = progress.currentSize * 1.0f / totalSize;
        progress.speed = progress.bufferSpeed(progress.tempSize * 1000 / diffTime);
        progress.lastRefreshTime = currentTime;
        progress.tempSize = 0;
        if (action != null) {
            action.call(progress);
        }
    }
    return progress;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:Progress.java

示例2: write

@Override
public void write(Buffer source, long byteCount) throws IOException {
    super.write(source, byteCount);
    if (contentLength <= 0) contentLength = contentLength(); //获得contentLength的值,后续不再调用
    bytesWritten += byteCount;

    long curTime = System.currentTimeMillis();
    //每100毫秒刷新一次数据
    if (curTime - lastRefreshUiTime >= OkGo.REFRESH_TIME || bytesWritten == contentLength) {
        //计算下载速度
        long diffTime = (curTime - lastRefreshUiTime) / 1000;
        if (diffTime == 0) diffTime += 1;
        long diffBytes = bytesWritten - lastWriteBytes;
        long networkSpeed = diffBytes / diffTime;
        if (listener != null) listener.onRequestProgress(bytesWritten, contentLength, networkSpeed);

        lastRefreshUiTime = System.currentTimeMillis();
        lastWriteBytes = bytesWritten;
    }
}
 
开发者ID:feer921,项目名称:BaseProject,代码行数:20,代码来源:ProgressRequestBody.java


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