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


Java ConnectionModel.setCurrentOffset方法代码示例

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

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

示例1: findConnectionModel

import com.liulishuo.filedownloader.model.ConnectionModel; //导入方法依赖的package包/类
@Override
public List<ConnectionModel> findConnectionModel(int id) {
    final List<ConnectionModel> resultList = new ArrayList<>();

    Cursor c = null;
    try {
        c = db.rawQuery(FileDownloadUtils.formatString("SELECT * FROM %s WHERE %s = ?",
                CONNECTION_TABLE_NAME, ConnectionModel.ID), new String[]{Integer.toString(id)});

        while (c.moveToNext()) {
            final ConnectionModel model = new ConnectionModel();
            model.setId(id);
            model.setIndex(c.getInt(c.getColumnIndex(ConnectionModel.INDEX)));
            model.setStartOffset(c.getInt(c.getColumnIndex(ConnectionModel.START_OFFSET)));
            model.setCurrentOffset(c.getInt(c.getColumnIndex(ConnectionModel.CURRENT_OFFSET)));
            model.setEndOffset(c.getInt(c.getColumnIndex(ConnectionModel.END_OFFSET)));

            resultList.add(model);
        }
    } finally {
        if (c != null)
            c.close();
    }

    return resultList;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:DefaultDatabaseImpl.java


示例2: findConnectionModel

import com.liulishuo.filedownloader.model.ConnectionModel; //导入方法依赖的package包/类
@Override
public List<ConnectionModel> findConnectionModel(int id) {
    final List<ConnectionModel> resultList = new ArrayList<>();

    Cursor c = null;
    try {
        c = db.rawQuery(FileDownloadUtils.formatString("SELECT * FROM %s WHERE %s = ?",
                CONNECTION_TABLE_NAME, ConnectionModel.ID), new String[]{Integer.toString(id)});

        while (c.moveToNext()) {
            final ConnectionModel model = new ConnectionModel();
            model.setId(id);
            model.setIndex(c.getInt(c.getColumnIndex(ConnectionModel.INDEX)));
            model.setStartOffset(c.getLong(c.getColumnIndex(ConnectionModel.START_OFFSET)));
            model.setCurrentOffset(c.getLong(c.getColumnIndex(ConnectionModel.CURRENT_OFFSET)));
            model.setEndOffset(c.getLong(c.getColumnIndex(ConnectionModel.END_OFFSET)));

            resultList.add(model);
        }
    } finally {
        if (c != null)
            c.close();
    }

    return resultList;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:27,代码来源:DefaultDatabaseImpl.java


示例3: findConnectionModel

import com.liulishuo.filedownloader.model.ConnectionModel; //导入方法依赖的package包/类
@Override
public List<ConnectionModel> findConnectionModel(int id) {
    final List<ConnectionModel> resultList = new ArrayList<>();

    Cursor c = null;
    try {
        c = db.rawQuery(FileDownloadUtils.formatString("SELECT * FROM %s WHERE %s = ?",
                CONNECTION_TABLE_NAME, ConnectionModel.ID), new String[]{Integer.toString(id)});

        while (c.moveToNext()) {
            final ConnectionModel model = new ConnectionModel();
            model.setId(id);
            model.setIndex(c.getInt(c.getColumnIndex(ConnectionModel.INDEX)));
            model.setStartOffset(c.getLong(c.getColumnIndex(ConnectionModel.START_OFFSET)));
            model.setCurrentOffset(c.getLong(c.getColumnIndex(ConnectionModel.CURRENT_OFFSET)));
            model.setEndOffset(c.getLong(c.getColumnIndex(ConnectionModel.END_OFFSET)));

            resultList.add(model);
        }
    } finally {
        if (c != null) c.close();
    }

    return resultList;
}
 
开发者ID:lingochamp,项目名称:FileDownloader,代码行数:26,代码来源:SqliteDatabaseImpl.java


示例4: fetchWithMultipleConnectionFromBeginning

import com.liulishuo.filedownloader.model.ConnectionModel; //导入方法依赖的package包/类
private void fetchWithMultipleConnectionFromBeginning(final long totalLength, final int connectionCount) throws InterruptedException {
    long startOffset = 0;
    final long eachRegion = totalLength / connectionCount;
    final int id = model.getId();

    final List<ConnectionModel> connectionModelList = new ArrayList<>();

    for (int i = 0; i < connectionCount; i++) {

        final long endOffset;
        if (i == connectionCount - 1) {
            // avoid float precision error
            endOffset = 0;
        } else {
            // [startOffset, endOffset)
            endOffset = startOffset + eachRegion - 1;
        }

        final ConnectionModel connectionModel = new ConnectionModel();
        connectionModel.setId(id);
        connectionModel.setIndex(i);
        connectionModel.setStartOffset(startOffset);
        connectionModel.setCurrentOffset(startOffset);
        connectionModel.setEndOffset(endOffset);
        connectionModelList.add(connectionModel);

        database.insertConnectionModel(connectionModel);
        startOffset += eachRegion;
    }

    model.setConnectionCount(connectionCount);
    database.updateConnectionCount(id, connectionCount);

    fetchWithMultipleConnection(connectionModelList, totalLength);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:DownloadLaunchRunnable.java


示例5: updateConnectionModel

import com.liulishuo.filedownloader.model.ConnectionModel; //导入方法依赖的package包/类
@Override
public void updateConnectionModel(int id, int index, long currentOffset) {
    final List<ConnectionModel> processList = connectionModelListMap.get(id);
    if (processList == null) return;

    for (ConnectionModel connectionModel : processList) {
        if (connectionModel.getIndex() == index) {
            connectionModel.setCurrentOffset(currentOffset);
            return;
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:NoDatabaseImpl.java


示例6: fetchWithMultiConnectionFromBeginning

import com.liulishuo.filedownloader.model.ConnectionModel; //导入方法依赖的package包/类
private void fetchWithMultiConnectionFromBeginning(final long totalLength,
                                                   final int connectionCount)
        throws InterruptedException {
    long startOffset = 0;
    final long eachRegion = totalLength / connectionCount;
    final int id = model.getId();

    final List<ConnectionModel> connectionModelList = new ArrayList<>();

    for (int i = 0; i < connectionCount; i++) {

        final long endOffset;
        if (i == connectionCount - 1) {
            // avoid float precision error
            endOffset = 0;
        } else {
            // [startOffset, endOffset)
            endOffset = startOffset + eachRegion - 1;
        }

        final ConnectionModel connectionModel = new ConnectionModel();
        connectionModel.setId(id);
        connectionModel.setIndex(i);
        connectionModel.setStartOffset(startOffset);
        connectionModel.setCurrentOffset(startOffset);
        connectionModel.setEndOffset(endOffset);
        connectionModelList.add(connectionModel);

        database.insertConnectionModel(connectionModel);
        startOffset += eachRegion;
    }

    model.setConnectionCount(connectionCount);
    database.updateConnectionCount(id, connectionCount);

    fetchWithMultipleConnection(connectionModelList, totalLength);
}
 
开发者ID:lingochamp,项目名称:FileDownloader,代码行数:38,代码来源:DownloadLaunchRunnable.java



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