diff --git a/app/build.gradle b/app/build.gradle index 39f9cd318..e0bdf4d83 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -84,6 +84,7 @@ dependencies { implementation project(':tvbus') implementation project(':catvod') implementation project(':quickjs') + implementation project(':thunder') implementation project(':jianpian') implementation project(':forcetech') implementation project(':ijkplayer') diff --git a/thunder/build.gradle b/thunder/build.gradle index e6a4d45a7..57fc9f4e4 100644 --- a/thunder/build.gradle +++ b/thunder/build.gradle @@ -8,11 +8,3 @@ android { targetSdkVersion 28 } } - -dependencies { - implementation 'androidx.annotation:annotation:' + annotationVersion - implementation 'com.google.code.gson:gson:' + gsonVersion -} - - - diff --git a/thunder/src/main/java/com/xunlei/downloadlib/XLTaskHelper.java b/thunder/src/main/java/com/xunlei/downloadlib/XLTaskHelper.java index 0f76bdc56..e1e19fa76 100644 --- a/thunder/src/main/java/com/xunlei/downloadlib/XLTaskHelper.java +++ b/thunder/src/main/java/com/xunlei/downloadlib/XLTaskHelper.java @@ -6,8 +6,6 @@ import android.os.Handler; import android.text.TextUtils; import android.util.Pair; -import androidx.annotation.Nullable; - import com.xunlei.downloadlib.parameter.BtIndexSet; import com.xunlei.downloadlib.parameter.BtSubTaskDetail; import com.xunlei.downloadlib.parameter.BtTaskParam; @@ -66,7 +64,7 @@ public class XLTaskHelper { downloadManager.setSpeedLimit(-1, -1); } - public synchronized long addThunderTask(String url, String savePath, @Nullable String fileName) { + public synchronized long addThunderTask(String url, String savePath, String fileName) { if (url.startsWith("thunder://")) url = downloadManager.parserThunderUrl(url); GetTaskId getTaskId = new GetTaskId(); if (TextUtils.isEmpty(fileName)) { @@ -106,29 +104,6 @@ public class XLTaskHelper { return getTaskId.getTaskId(); } - public void addHeader(String key, String value) { - requestHeaders.add(Pair.create(key, value)); - } - - private Collection> getHeaders() { - return Collections.unmodifiableList(this.requestHeaders); - } - - private void addRequestHeadersToXlEngine(long taskId) { - for (Pair pair : this.getHeaders()) { - if (!(pair.first == null || pair.second == null)) { - downloadManager.setHttpHeaderProperty(taskId, pair.first, pair.second); - } - } - } - - public synchronized String getFileName(String url) { - if (url.startsWith("thunder://")) url = downloadManager.parserThunderUrl(url); - GetFileName getFileName = new GetFileName(); - downloadManager.getFileNameFromUrl(url, getFileName); - return getFileName.getFileName(); - } - public synchronized long addMagnetTask(String url, String savePath, String fileName) throws Exception { if (url.startsWith("magnet:?")) { if (TextUtils.isEmpty(fileName)) { @@ -151,12 +126,6 @@ public class XLTaskHelper { } } - public synchronized TorrentInfo getTorrentInfo(String torrentPath) { - TorrentInfo torrentInfo = new TorrentInfo(); - downloadManager.getTorrentInfo(torrentPath, torrentInfo); - return torrentInfo; - } - public synchronized long addTorrentTask(String torrentPath, String savePath, int index) { TorrentInfo torrentInfo = new TorrentInfo(); downloadManager.getTorrentInfo(torrentPath, torrentInfo); @@ -186,6 +155,35 @@ public class XLTaskHelper { return getTaskId.getTaskId(); } + public void addHeader(String key, String value) { + requestHeaders.add(Pair.create(key, value)); + } + + private Collection> getHeaders() { + return Collections.unmodifiableList(this.requestHeaders); + } + + private void addRequestHeadersToXlEngine(long taskId) { + for (Pair pair : this.getHeaders()) { + if (!(pair.first == null || pair.second == null)) { + downloadManager.setHttpHeaderProperty(taskId, pair.first, pair.second); + } + } + } + + public synchronized String getFileName(String url) { + if (url.startsWith("thunder://")) url = downloadManager.parserThunderUrl(url); + GetFileName getFileName = new GetFileName(); + downloadManager.getFileNameFromUrl(url, getFileName); + return getFileName.getFileName(); + } + + public synchronized TorrentInfo getTorrentInfo(String torrentPath) { + TorrentInfo torrentInfo = new TorrentInfo(); + downloadManager.getTorrentInfo(torrentPath, torrentInfo); + return torrentInfo; + } + public synchronized String getLocalUrl(String filePath) { XLTaskLocalUrl localUrl = new XLTaskLocalUrl(); downloadManager.getLocalUrl(filePath, localUrl); diff --git a/thunder/src/main/java/com/xunlei/downloadlib/parameter/TorrentFileInfo.java b/thunder/src/main/java/com/xunlei/downloadlib/parameter/TorrentFileInfo.java index 9d3a8b0de..4d1266da5 100644 --- a/thunder/src/main/java/com/xunlei/downloadlib/parameter/TorrentFileInfo.java +++ b/thunder/src/main/java/com/xunlei/downloadlib/parameter/TorrentFileInfo.java @@ -1,5 +1,7 @@ package com.xunlei.downloadlib.parameter; +import android.text.TextUtils; + public class TorrentFileInfo { public int mFileIndex; @@ -17,7 +19,7 @@ public class TorrentFileInfo { } public String getFileName() { - return mFileName; + return TextUtils.isEmpty(mFileName) ? "" : mFileName; } public long getFileSize() { @@ -47,4 +49,8 @@ public class TorrentFileInfo { public boolean isSelected() { return isSelected; } + + public String getExt() { + return getFileName().contains(".") ? getFileName().substring(getFileName().lastIndexOf(".") + 1) : ""; + } } diff --git a/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLTaskInfo.java b/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLTaskInfo.java index 233ca9bb1..a653941b2 100644 --- a/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLTaskInfo.java +++ b/thunder/src/main/java/com/xunlei/downloadlib/parameter/XLTaskInfo.java @@ -74,10 +74,107 @@ public class XLTaskInfo implements Parcelable { this.mScdnRecvBytes = parcel.readLong(); } - public int describeContents() { - return 0; + public int getAdditionalResCount() { + return mAdditionalResCount; + } + + public long getAdditionalResPeerBytes() { + return mAdditionalResPeerBytes; + } + + public long getAdditionalResPeerSpeed() { + return mAdditionalResPeerSpeed; + } + + public int getAdditionalResType() { + return mAdditionalResType; + } + + public long getAdditionalResVipRecvBytes() { + return mAdditionalResVipRecvBytes; + } + + public long getAdditionalResVipSpeed() { + return mAdditionalResVipSpeed; + } + + public String getCid() { + return mCid; + } + + public long getDownloadSize() { + return mDownloadSize; + } + + public long getDownloadSpeed() { + return mDownloadSpeed; + } + + public int getErrorCode() { + return mErrorCode; + } + + public String getFileName() { + return mFileName; + } + + public long getFileSize() { + return mFileSize; + } + + public String getGcid() { + return mGcid; + } + + public int getInfoLen() { + return mInfoLen; + } + + public long getOriginRecvBytes() { + return mOriginRecvBytes; + } + + public long getOriginSpeed() { + return mOriginSpeed; + } + + public long getP2PRecvBytes() { + return mP2PRecvBytes; } + public long getP2PSpeed() { + return mP2PSpeed; + } + + public long getP2SRecvBytes() { + return mP2SRecvBytes; + } + + public long getP2SSpeed() { + return mP2SSpeed; + } + + public int getQueryIndexStatus() { + return mQueryIndexStatus; + } + + public long getScdnRecvBytes() { + return mScdnRecvBytes; + } + + public long getScdnSpeed() { + return mScdnSpeed; + } + + public long getTaskId() { + return mTaskId; + } + + public int getTaskStatus() { + return mTaskStatus; + } + + @Override public void writeToParcel(Parcel parcel, int i) { parcel.writeLong(this.mTaskId); parcel.writeString(this.mFileName); @@ -105,4 +202,9 @@ public class XLTaskInfo implements Parcelable { parcel.writeLong(this.mScdnSpeed); parcel.writeLong(this.mScdnRecvBytes); } + + @Override + public int describeContents() { + return 0; + } }