public class FileDownloader
extends java.lang.Object
| Constructor and Description |
|---|
FileDownloader() |
| Modifier and Type | Method and Description |
|---|---|
void |
addServiceConnectListener(FileDownloadConnectListener connectListener)
Deprecated.
|
void |
bindService()
Deprecated.
|
void |
bindService(java.lang.Runnable runnable)
Deprecated.
|
boolean |
clear(int id,
java.lang.String targetFilePath)
Clear the data with the provided
id. |
void |
clearAllTaskData()
Deprecated.
|
DownloadTaskAdapter |
create(java.lang.String url) |
static void |
disableAvoidDropFrame()
Disable avoiding missing screen frames, let all callbacks in
FileDownloadListener
can be invoked at once when it achieve. |
void |
discardFileDownloadDatabase(android.content.Context context)
Because the FileDownloader database cannot be compatible with OkDownload database,
provide this method to discard the database of FileDownloader.
|
static void |
enableAvoidDropFrame()
Avoid missing screen frames, this leads to all callbacks in
FileDownloadListener do
not be invoked at once when it has already achieved to ensure callbacks don't be too frequent |
static FileDownloader |
getImpl() |
long |
getSoFar(int downloadId)
Get downloaded bytes so far by the downloadId.
|
byte |
getStatus(int id,
java.lang.String path)
Deprecated.
|
byte |
getStatus(java.lang.String url,
java.lang.String path) |
byte |
getStatusIgnoreCompleted(int id)
Deprecated.
|
long |
getTotal(int id)
Get the total bytes of the target file for the task with the {code id}.
|
static void |
init(android.content.Context context) |
static void |
init(android.content.Context context,
FileDownloadHelper.OkHttpClientCustomMaker okHttpClientCustomMaker) |
static void |
init(android.content.Context context,
FileDownloadHelper.OkHttpClientCustomMaker okHttpClientCustomMaker,
int maxNetworkThreadCount)
Initial a OkDownload instance.
|
FileDownloadLine |
insureServiceBind()
Because there is no any service, the FileDownloadLine will not do any wait action.
|
FileDownloadLineAsync |
insureServiceBindAsync()
Deprecated.
|
static boolean |
isEnabledAvoidDropFrame() |
boolean |
isServiceConnected()
Deprecated.
|
static com.liulishuo.okdownload.OkDownload.Builder |
okDownloadBuilder(android.content.Context context,
FileDownloadHelper.OkHttpClientCustomMaker okHttpClientCustomMaker) |
void |
pause(FileDownloadListener listener) |
int |
pause(int id) |
void |
pauseAll() |
void |
removeServiceConnectListener(FileDownloadConnectListener connectListener)
Deprecated.
|
int |
replaceListener(int id,
FileDownloadListener listener)
Find the running task by
id, and replace its listener width the new one
listener. |
int |
replaceListener(java.lang.String url,
FileDownloadListener listener)
Find the running task by
url and default path, and replace its listener with
the new one listener. |
int |
replaceListener(java.lang.String url,
java.lang.String path,
FileDownloadListener listener)
Find the running task by
url and path, and replace its listener with
the new one listener. |
static void |
setGlobalHandleSubPackageSize(int packageSize)
Deprecated.
|
static void |
setGlobalPost2UIInterval(int intervalMillisecond)
For avoiding missing screen frames.
|
boolean |
setMaxNetworkThreadCount(int count)
Deprecated.
|
static void |
setup(android.content.Context context)
You can invoke this method anytime before you using the FileDownloader.
|
static DownloadMgrInitialParams.InitCustomMaker |
setupOnApplicationOnCreate(android.app.Application application)
Using this method to setup the FileDownloader only you want to register your own customize
components for Filedownloader, otherwise just using
setup(Context) instead. |
boolean |
start(FileDownloadListener listener,
boolean isSerial)
Start the download queue by the same listener.
|
void |
startForeground(int id,
android.app.Notification notification)
Deprecated.
|
void |
stopForeground(boolean removeNotification)
Deprecated.
|
void |
unbindService()
Deprecated.
|
void |
unBindServiceIfIdle()
Deprecated.
|
public static FileDownloader getImpl()
public static void init(@NonNull
android.content.Context context)
public static void init(@NonNull
android.content.Context context,
@Nullable
FileDownloadHelper.OkHttpClientCustomMaker okHttpClientCustomMaker)
public static void init(@NonNull
android.content.Context context,
@Nullable
FileDownloadHelper.OkHttpClientCustomMaker okHttpClientCustomMaker,
int maxNetworkThreadCount)
setupOnApplicationOnCreate(Application)
cannot be invoked int the same time.context - Android context.okHttpClientCustomMaker - a maker to build a OkHttpClient.maxNetworkThreadCount - the max thread count of thread pool for downloading.
This parameter is deprecated in OkDownload.@Nullable
public static com.liulishuo.okdownload.OkDownload.Builder okDownloadBuilder(@NonNull
android.content.Context context,
@Nullable
FileDownloadHelper.OkHttpClientCustomMaker okHttpClientCustomMaker)
public static void setup(@NonNull
android.content.Context context)
context - the context of Application or Activity etc..public static DownloadMgrInitialParams.InitCustomMaker setupOnApplicationOnCreate(android.app.Application application)
setup(Context) instead.
Please invoke this method on the Application.onCreate() because of the customize
components must be assigned before FileDownloader is running.
Such as:
class MyApplication extends Application {
...
public void onCreate() {
...
FileDownloader.setupOnApplicationOnCreate(this)
.idGenerator(new MyIdGenerator())
.database(new MyDatabase())
...
.commit();
...
}
...
}application - the application.public DownloadTaskAdapter create(java.lang.String url)
public boolean start(FileDownloadListener listener, boolean isSerial)
listener - Used to assemble tasks which is bound by the same listenerisSerial - Whether start tasks one by one rather than parallel.true if start tasks successfully.@Deprecated public void bindService()
@Deprecated public void unbindService()
@Deprecated public void unBindServiceIfIdle()
@Deprecated public boolean isServiceConnected()
@Deprecated public void addServiceConnectListener(FileDownloadConnectListener connectListener)
@Deprecated public void removeServiceConnectListener(FileDownloadConnectListener connectListener)
@Deprecated
public void startForeground(int id,
android.app.Notification notification)
@Deprecated public void stopForeground(boolean removeNotification)
@Deprecated public boolean setMaxNetworkThreadCount(int count)
@Deprecated public void bindService(java.lang.Runnable runnable)
public void pause(FileDownloadListener listener)
public void pauseAll()
public int pause(int id)
public static void setGlobalPost2UIInterval(int intervalMillisecond)
FileDownloadListener is invoked too
frequent in result the system missing screen frames in the main thread.
@Deprecated public static void setGlobalHandleSubPackageSize(int packageSize)
BaseDownloadTask.setCallbackProgressMinInterval(int) in OkDownload.public static void enableAvoidDropFrame()
FileDownloadListener do
not be invoked at once when it has already achieved to ensure callbacks don't be too frequentpublic static void disableAvoidDropFrame()
FileDownloadListener
can be invoked at once when it achieve.public static boolean isEnabledAvoidDropFrame()
true if enabled the function of avoiding missing screen frames.public long getSoFar(int downloadId)
public long getTotal(int id)
@Deprecated public void clearAllTaskData()
BreakpointStore doesn't provide clear all
data api, and it's no need to clear database manually in fact.public boolean clear(int id,
java.lang.String targetFilePath)
id.
Normally used to deleting the data in OkDownload database, when it is paused or in
downloading status. If you want to re-download it clearly.
Note: YOU NO NEED to clear the data when it is already completed downloading
because the data would be deleted when it completed downloading automatically by
OkDownload.
@Deprecated public byte getStatusIgnoreCompleted(int id)
FileDownloadStatus.INVALID_STATUS ).public byte getStatus(java.lang.String url,
java.lang.String path)
url - The downloading URL.path - The downloading file's path.getStatus(int, String),
getStatusIgnoreCompleted(int)@Deprecated
public byte getStatus(int id,
java.lang.String path)
public int replaceListener(java.lang.String url,
FileDownloadListener listener)
url and default path, and replace its listener with
the new one listener.replaceListener(int, FileDownloadListener),
replaceListener(String, String, FileDownloadListener)public int replaceListener(java.lang.String url,
java.lang.String path,
FileDownloadListener listener)
url and path, and replace its listener with
the new one listener.replaceListener(String, FileDownloadListener),
replaceListener(int, FileDownloadListener)public int replaceListener(int id,
FileDownloadListener listener)
id, and replace its listener width the new one
listener.replaceListener(String, FileDownloadListener),
replaceListener(String, String, FileDownloadListener)public FileDownloadLine insureServiceBind()
FileDownloadLine,
bindService(Runnable)@Deprecated public FileDownloadLineAsync insureServiceBindAsync()
public void discardFileDownloadDatabase(android.content.Context context)