com.xunlei.downloadlib.parameter.XLTaskInfo Java Examples

The following examples show how to use com.xunlei.downloadlib.parameter.XLTaskInfo. 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: XLVideoPlayActivity.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected int setProgress() {
    if (isDragging) {
        return 0;
    }

    XLTaskInfo xlTaskInfo = xlDownloadManager.taskInstance().getTaskInfo();

    int position = mVideoView.getCurrentPosition();
    int duration = mVideoView.getDuration();
    if (seekBar != null) {
        if (duration > 0) {
            seekBar.setProgress((position * 100 / duration));
            if(xlTaskInfo != null){
                seekBar.setSecondaryProgress((int)Math.floor((double)xlTaskInfo.mDownloadSize * 100 / xlTaskInfo.mFileSize));
            }
        }
    }

    this.duration = duration;

    $.id(R.id.app_video_currentTime).text(generateTime(position));
    $.id(R.id.app_video_endTime).text(generateTime(this.duration));
    $.id(R.id.app_video_speed).text(FileUtils.convertFileSize(mVideoView.getTcpSpeed()) + "/s");
    return position;
}
 
Example #2
Source File: MainActivity.java    From MiniThunder with Apache License 2.0 6 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    super.handleMessage(msg);
    if(msg.what == 0) {
        long taskId = (long) msg.obj;
        XLTaskInfo taskInfo = XLTaskHelper.instance().getTaskInfo(taskId);
        tvStatus.setText(
                "fileSize:" + taskInfo.mFileSize
                        + " downSize:" + taskInfo.mDownloadSize
                        + " speed:" + convertFileSize(taskInfo.mDownloadSpeed)
                        + "/s dcdnSoeed:" + convertFileSize(taskInfo.mAdditionalResDCDNSpeed)
                        + "/s filePath:" + "/sdcard/" + XLTaskHelper.instance().getFileName(inputUrl.getText().toString())
        );
        handler.sendMessageDelayed(handler.obtainMessage(0,taskId),1000);
    }
}
 
Example #3
Source File: DownLoadModelImp.java    From AndroidDownload with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean startUrlTask(String url) {
    DownloadTaskEntity task=new DownloadTaskEntity();
    task.setTaskType(Const.URL_DOWNLOAD);
    task.setUrl(url);
    task.setLocalPath(AppSettingUtil.getInstance().getFileSavePath());
    try {
        long taskId = XLTaskHelper.instance(x.app().getApplicationContext()).addThunderTask(url,AppSettingUtil.getInstance().getFileSavePath(),null);
        XLTaskInfo taskInfo = XLTaskHelper.instance(x.app().getApplicationContext()).getTaskInfo(taskId);
        task.setmFileName(XLTaskHelper.instance(x.app().getApplicationContext()).getFileName(url));
        task.setmFileSize(taskInfo.mFileSize);
        task.setmTaskStatus(taskInfo.mTaskStatus);
        task.setTaskId(taskId);
        task.setmDCDNSpeed(taskInfo.mAdditionalResDCDNSpeed);
        task.setmDownloadSize(taskInfo.mDownloadSize);
        task.setmDownloadSpeed(taskInfo.mDownloadSpeed);
        task.setFile(true);
        task.setCreateDate(new Date());
        DBTools.getInstance().db().saveBindingId(task);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
Example #4
Source File: XLDownloadManager.java    From MiniThunder with Apache License 2.0 5 votes vote down vote up
public int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo) {
    int i2 = 9900;
    increRefCount();
    if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || xLTaskInfo == null)) {
        i2 = this.mLoader.getTaskInfo(j, i, xLTaskInfo);
    }
    decreRefCount();
    return i2;
}
 
Example #5
Source File: XLDownloadManager.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo) {
    int i2 = 9900;
    increRefCount();
    if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || xLTaskInfo == null)) {
        i2 = this.mLoader.getTaskInfo(j, i, xLTaskInfo);
    }
    decreRefCount();
    return i2;
}
 
Example #6
Source File: DownLoadUtil.java    From BtPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {

        case TASK_UPDATE_PROGRESS: {
            if (progressListener != null) {
                XLTaskInfo taskInfo = XLTaskHelper.instance(globalContext).getTaskInfo(taskID);
                if (taskInfo.mFileSize == taskInfo.mDownloadSize) {
                    if (TextUtils.isEmpty(taskInfo.mFileName)) {
                        progressListener.onDonwloadEnd(preFile);
                    } else {
                        progressListener.onDonwloadEnd(savePath + "/" + taskInfo.mFileName);
                    }
                    return;
                }

                progressListener.onProgressChangeRealSize(taskInfo.mFileSize,
                        taskInfo.mDownloadSize, taskInfo.mDownloadSpeed);

                progressListener.onProgressChange(StorageUtils.convertFileSize(taskInfo.mFileSize)
                        , StorageUtils.convertFileSize(taskInfo.mDownloadSize)
                        , StorageUtils.convertFileSize(taskInfo.mDownloadSpeed));
                progressHandler.sendEmptyMessageDelayed(TASK_UPDATE_PROGRESS, 1000);
            }
            break;
        }


    }
}
 
Example #7
Source File: XLDownloadManager.java    From AndroidDownload with Apache License 2.0 5 votes vote down vote up
public int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo) {
    int i2 = 9900;
    increRefCount();
    if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || xLTaskInfo == null)) {
        i2 = this.mLoader.getTaskInfo(j, i, xLTaskInfo);
    }
    decreRefCount();
    return i2;
}
 
Example #8
Source File: DownLoadModelImp.java    From AndroidDownload with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean startTask(DownloadTaskEntity task) {
    try {
        long taskId=0;
        if(task.getTaskType()==Const.BT_DOWNLOAD){
            TorrentInfo torrentInfo= XLTaskHelper.instance(x.app().getApplicationContext()).getTorrentInfo(task.getUrl());
            int i=0;
            int[] indexs=new int[torrentInfo.mSubFileInfo.length];
            for(TorrentFileInfo torrent:torrentInfo.mSubFileInfo) {
                indexs[i++]=torrent.mFileIndex;
            }
            taskId = XLTaskHelper.instance(x.app().getApplicationContext()).addTorrentTask(task.getUrl(), task.getLocalPath(),indexs);
        }else if(task.getTaskType()==Const.URL_DOWNLOAD){
            taskId = XLTaskHelper.instance(x.app().getApplicationContext()).addThunderTask(task.getUrl(), task.getLocalPath(), null);
        }
        XLTaskInfo taskInfo = XLTaskHelper.instance(x.app().getApplicationContext()).getTaskInfo(taskId);
        task.setmFileSize(taskInfo.mFileSize);
        task.setTaskId(taskId);
        task.setmTaskStatus(taskInfo.mTaskStatus);
        DBTools.getInstance().db().saveOrUpdate(task);
        if(taskInfo.mTaskId==0)
            return false;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
Example #9
Source File: XLDownloadManager.java    From BtPlayer with Apache License 2.0 5 votes vote down vote up
public int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo) {
    int i2 = 9900;
    increRefCount();
    if (!(mDownloadManagerState != XLManagerStatus.MANAGER_RUNNING || this.mLoader == null || xLTaskInfo == null)) {
        i2 = this.mLoader.getTaskInfo(j, i, xLTaskInfo);
    }
    decreRefCount();
    return i2;
}
 
Example #10
Source File: DownloadTask.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public XLTaskInfo getTaskInfo(){
    return this.taskId == 0L || this.isLocalMedia || this.mIsLiveMedia ? null : XLTaskHelper.instance().getTaskInfo(this.taskId);
}
 
Example #11
Source File: DownLoadModelImp.java    From AndroidDownload with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean startTorrentTask(String btpath, int[] indexs) {
    DownloadTaskEntity task=new DownloadTaskEntity();
    TorrentInfo torrentInfo= XLTaskHelper.instance(x.app().getApplicationContext()).getTorrentInfo(btpath);
    if(indexs==null || indexs.length<=0) {
        int i = 0;
        indexs = new int[torrentInfo.mSubFileInfo.length];
        for (TorrentFileInfo torrent : torrentInfo.mSubFileInfo) {
            indexs[i++] = torrent.mFileIndex;
        }
    }
    String savePath= AppSettingUtil.getInstance().getFileSavePath();
    if(torrentInfo.mIsMultiFiles) {
        savePath += File.separator + torrentInfo.mMultiFileBaseFolder;
        task.setmFileName(torrentInfo.mMultiFileBaseFolder);
    }else{
        if(torrentInfo.mSubFileInfo.length>1) {
            savePath += File.separator + FileTools.getFileNameWithoutSuffix(btpath);
            task.setmFileName(FileTools.getFileNameWithoutSuffix(btpath));
        }else{
            task.setmFileName(torrentInfo.mSubFileInfo[0].mFileName);
        }
    }
    long taskId= 0;
    try {
        taskId = XLTaskHelper.instance(x.app().getApplicationContext()).addTorrentTask(btpath, savePath,indexs);
        XLTaskInfo taskInfo = XLTaskHelper.instance(x.app().getApplicationContext()).getTaskInfo(taskId);
        task.setLocalPath(savePath);
        task.setFile(!torrentInfo.mIsMultiFiles);
        task.setHash(torrentInfo.mInfoHash);
        task.setUrl(btpath);
        task.setmFileSize(taskInfo.mFileSize);
        task.setmTaskStatus(taskInfo.mTaskStatus);
        task.setTaskId(taskId);
        task.setmDCDNSpeed(taskInfo.mAdditionalResDCDNSpeed);
        task.setmDownloadSize(taskInfo.mDownloadSize);
        task.setmDownloadSpeed(taskInfo.mDownloadSpeed);
        task.setTaskType(Const.BT_DOWNLOAD);
        task.setCreateDate(new Date());
        DBTools.getInstance().db().saveBindingId(task);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
Example #12
Source File: DownLoadUtil.java    From BtPlayer with Apache License 2.0 4 votes vote down vote up
public void stopTask() {
    XLTaskInfo taskInfo = XLTaskHelper.instance(globalContext).getTaskInfo(taskID);
    int status = taskInfo.mTaskStatus;
    LogPrinter.i(TAG, "stopTask -- > taskStatus : " + status);
    XLTaskHelper.instance(globalContext).stopTask(taskID);
}
 
Example #13
Source File: XLTaskHelper.java    From BtPlayer with Apache License 2.0 2 votes vote down vote up
/**
 * 获取任务详情, 包含当前状态,下载进度,下载速度,文件大小
 * mDownloadSize:已下载大小  mDownloadSpeed:下载速度 mFileSize:文件总大小 mTaskStatus:当前状态,0连接中1下载中 2下载完成 3失败 mAdditionalResDCDNSpeed DCDN加速 速度
 * @param taskId
 * @return
 */
public synchronized XLTaskInfo getTaskInfo(long taskId) {
    XLTaskInfo taskInfo = new XLTaskInfo();
    XLDownloadManager.getInstance().getTaskInfo(taskId,1,taskInfo);
    return taskInfo;
}
 
Example #14
Source File: XLTaskHelper.java    From AndroidDownload with Apache License 2.0 2 votes vote down vote up
/**
 * 获取任务详情, 包含当前状态,下载进度,下载速度,文件大小
 * mDownloadSize:已下载大小  mDownloadSpeed:下载速度 mFileSize:文件总大小 mTaskStatus:当前状态,0连接中1下载中 2下载完成 3失败 mAdditionalResDCDNSpeed DCDN加速 速度
 * @param taskId
 * @return
 */
public synchronized XLTaskInfo getTaskInfo(long taskId) {
    XLTaskInfo taskInfo = new XLTaskInfo();
    XLDownloadManager.getInstance().getTaskInfo(taskId,1,taskInfo);
    return taskInfo;
}
 
Example #15
Source File: XLTaskHelper.java    From MiniThunder with Apache License 2.0 2 votes vote down vote up
/**
 * 获取任务详情, 包含当前状态,下载进度,下载速度,文件大小
 * mDownloadSize:已下载大小  mDownloadSpeed:下载速度 mFileSize:文件总大小 mTaskStatus:当前状态,0连接中1下载中 2下载完成 3失败 mAdditionalResDCDNSpeed DCDN加速 速度
 * @param taskId
 * @return
 */
public synchronized XLTaskInfo getTaskInfo(long taskId) {
    XLTaskInfo taskInfo = new XLTaskInfo();
    XLDownloadManager.getInstance().getTaskInfo(taskId,1,taskInfo);
    return taskInfo;
}
 
Example #16
Source File: XLTaskHelper.java    From TVRemoteIME with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 获取任务详情, 包含当前状态,下载进度,下载速度,文件大小
 * mDownloadSize:已下载大小  mDownloadSpeed:下载速度 mFileSize:文件总大小 mTaskStatus:当前状态,0连接中1下载中 2下载完成 3失败 mAdditionalResDCDNSpeed DCDN加速 速度
 * @param taskId
 * @return
 */
public synchronized XLTaskInfo getTaskInfo(long taskId) {
    XLTaskInfo taskInfo = new XLTaskInfo();
    XLDownloadManager.getInstance().getTaskInfo(taskId,1,taskInfo);
    return taskInfo;
}
 
Example #17
Source File: XLLoader.java    From BtPlayer with Apache License 2.0 votes vote down vote up
public native int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo); 
Example #18
Source File: XLLoader.java    From AndroidDownload with Apache License 2.0 votes vote down vote up
public native int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo); 
Example #19
Source File: XLLoader.java    From TVRemoteIME with GNU General Public License v2.0 votes vote down vote up
public native int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo); 
Example #20
Source File: XLLoader.java    From MiniThunder with Apache License 2.0 votes vote down vote up
public native int getTaskInfo(long j, int i, XLTaskInfo xLTaskInfo);