本文整理汇总了Java中com.liulishuo.filedownloader.util.FileDownloadHelper类的典型用法代码示例。如果您正苦于以下问题:Java FileDownloadHelper类的具体用法?Java FileDownloadHelper怎么用?Java FileDownloadHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileDownloadHelper类属于com.liulishuo.filedownloader.util包,在下文中一共展示了FileDownloadHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NotificationItem
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
private NotificationItem(int id, String title, String desc) {
super(id, title, desc);
Intent[] intents = new Intent[2];
intents[0] = Intent.makeMainActivity(new ComponentName(DemoApplication.CONTEXT,
MainActivity.class));
intents[1] = new Intent(DemoApplication.CONTEXT, NotificationSampleActivity.class);
this.pendingIntent = PendingIntent.getActivities(DemoApplication.CONTEXT, 0, intents,
PendingIntent.FLAG_UPDATE_CURRENT);
builder = new NotificationCompat.
Builder(FileDownloadHelper.getAppContext());
builder.setDefaults(Notification.DEFAULT_LIGHTS)
.setOngoing(true)
.setPriority(NotificationCompat.PRIORITY_MIN)
.setContentTitle(getTitle())
.setContentText(desc)
.setContentIntent(pendingIntent)
.setSmallIcon(R.mipmap.ic_launcher);
}
示例2: pauseAll
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
* Pause all tasks running in FileDownloader.
*/
public void pauseAll() {
FileDownloadTaskLauncher.getImpl().expireAll();
final BaseDownloadTask.IRunningTask[] downloadList = FileDownloadList.getImpl().copy();
for (BaseDownloadTask.IRunningTask task : downloadList) {
task.getOrigin().pause();
}
// double check, for case: File Download progress alive but ui progress has died and relived,
// so FileDownloadList not always contain all running task exactly.
if (FileDownloadServiceProxy.getImpl().isConnected()) {
FileDownloadServiceProxy.getImpl().pauseAllTasks();
} else {
if (pauseAllRunnable == null) {
pauseAllRunnable = new Runnable() {
@Override
public void run() {
FileDownloadServiceProxy.getImpl().pauseAllTasks();
}
};
}
FileDownloadServiceProxy.getImpl().bindStartByContext(FileDownloadHelper.getAppContext(), pauseAllRunnable);
}
}
示例3: getStatus
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
* @param id The downloadId.
* @param path The target file path.
* @return the downloading status.
* @see FileDownloadStatus
* @see #getStatus(String, String)
* @see #getStatusIgnoreCompleted(int)
*/
public byte getStatus(final int id, final String path) {
byte status;
BaseDownloadTask.IRunningTask task = FileDownloadList.getImpl().get(id);
if (task == null) {
status = FileDownloadServiceProxy.getImpl().getStatus(id);
} else {
status = task.getOrigin().getStatus();
}
if (path != null && status == FileDownloadStatus.INVALID_STATUS) {
if (FileDownloadUtils.isFilenameConverted(FileDownloadHelper.getAppContext()) &&
new File(path).exists()) {
status = FileDownloadStatus.completed;
}
}
return status;
}
示例4: sendCompletedBroadcast
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public static void sendCompletedBroadcast(FileDownloadModel model) {
if (model == null) throw new IllegalArgumentException();
if (model.getStatus() != FileDownloadStatus.completed) throw new IllegalStateException();
final Intent intent = new Intent(ACTION_COMPLETED);
intent.putExtra(KEY_MODEL, model);
FileDownloadHelper.getAppContext().sendBroadcast(intent);
}
示例5: onCreate
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
FileDownloadHelper.holdContext(this);
try {
FileDownloadUtils.setMinProgressStep(FileDownloadProperties.getImpl().DOWNLOAD_MIN_PROGRESS_STEP);
FileDownloadUtils.setMinProgressTime(FileDownloadProperties.getImpl().DOWNLOAD_MIN_PROGRESS_TIME);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
final FileDownloadManager manager = new FileDownloadManager();
if (FileDownloadProperties.getImpl().PROCESS_NON_SEPARATE) {
handler = new FDServiceSharedHandler(new WeakReference<>(this), manager);
} else {
handler = new FDServiceSeparateHandler(new WeakReference<>(this), manager);
}
}
示例6: createOutputStreamCreator
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public FileDownloadHelper.OutputStreamCreator createOutputStreamCreator() {
if (mMaker == null) {
return createDefaultOutputStreamCreator();
}
final FileDownloadHelper.OutputStreamCreator outputStreamCreator = mMaker.mOutputStreamCreator;
if (outputStreamCreator != null) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "initial FileDownloader manager with the customize " +
"output stream: %s", outputStreamCreator);
}
return outputStreamCreator;
} else {
return createDefaultOutputStreamCreator();
}
}
示例7: createConnectionCreator
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public FileDownloadHelper.ConnectionCreator createConnectionCreator() {
if (mMaker == null) {
return createDefaultConnectionCreator();
}
final FileDownloadHelper.ConnectionCreator connectionCreator = mMaker.mConnectionCreator;
if (connectionCreator != null) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "initial FileDownloader manager with the customize " +
"connection creator: %s", connectionCreator);
}
return connectionCreator;
} else {
return createDefaultConnectionCreator();
}
}
示例8: createConnectionCountAdapter
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public FileDownloadHelper.ConnectionCountAdapter createConnectionCountAdapter() {
if (mMaker == null) {
return createDefaultConnectionCountAdapter();
}
final FileDownloadHelper.ConnectionCountAdapter adapter = mMaker.mConnectionCountAdapter;
if (adapter != null) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "initial FileDownloader manager with the customize " +
"connection count adapter: %s", adapter);
}
return adapter;
} else {
return createDefaultConnectionCountAdapter();
}
}
示例9: createIdGenerator
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
public FileDownloadHelper.IdGenerator createIdGenerator() {
if (mMaker == null) {
return createDefaultIdGenerator();
}
final FileDownloadHelper.IdGenerator idGenerator = mMaker.mIdGenerator;
if (idGenerator != null) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "initial FileDownloader manager with the customize " +
"id generator: %s", idGenerator);
}
return idGenerator;
} else {
return createDefaultIdGenerator();
}
}
示例10: outputStreamCreator
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
* Customize the output stream component.
* <p>
* If you don't customize the output stream component, we use the result of
* {@link #createDefaultOutputStreamCreator()} as the default one.
*
* @param creator The output stream creator is used for creating {@link FileDownloadOutputStream}
* which is used to write the input stream to the file for downloading.
*/
public InitCustomMaker outputStreamCreator(FileDownloadHelper.OutputStreamCreator creator) {
this.mOutputStreamCreator = creator;
if (mOutputStreamCreator != null && !mOutputStreamCreator.supportSeek()) {
if (!FileDownloadProperties.getImpl().FILE_NON_PRE_ALLOCATION) {
throw new IllegalArgumentException("Since the provided FileDownloadOutputStream " +
"does not support the seek function, if FileDownloader pre-allocates " +
"file size at the beginning of the download, it will can not be resumed" +
" from the breakpoint. If you need to ensure that the resumption is" +
" available, please add and set the value of 'file.non-pre-allocation' " +
"field to 'true' in the 'filedownloader.properties' file which is in your" +
" application assets folder manually for resolving this problem.");
}
}
return this;
}
示例11: dispatchTaskStart
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
@Override
public boolean dispatchTaskStart(BaseDownloadTask.IRunningTask task) {
if (!FileDownloader.getImpl().isServiceConnected()) {
synchronized (mWaitingList) {
if (!FileDownloader.getImpl().isServiceConnected()) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "Waiting for connecting with the downloader " +
"service... %d", task.getOrigin().getId());
}
FileDownloadServiceProxy.getImpl().
bindStartByContext(FileDownloadHelper.getAppContext());
if (!mWaitingList.contains(task)) {
task.free();
mWaitingList.add(task);
}
return true;
}
}
}
taskWorkFine(task);
return false;
}
示例12: init
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
* @deprecated please using {@link #setupOnApplicationOnCreate(Application)} instead.
*/
public static void init(final Context context,
final DownloadMgrInitialParams.InitCustomMaker maker) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(FileDownloader.class, "init Downloader with params: %s %s",
context, maker);
}
if (context == null) {
throw new IllegalArgumentException("the provided context must not be null!");
}
FileDownloadHelper.holdContext(context.getApplicationContext());
CustomComponentHolder.getImpl().setInitCustomMaker(maker);
}
示例13: pauseAll
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
* Pause all tasks running in FileDownloader.
*/
public void pauseAll() {
FileDownloadTaskLauncher.getImpl().expireAll();
final BaseDownloadTask.IRunningTask[] downloadList = FileDownloadList.getImpl().copy();
for (BaseDownloadTask.IRunningTask task : downloadList) {
task.getOrigin().pause();
}
// double check, for case: File Download progress alive but ui progress has died and relived
// so FileDownloadList not always contain all running task exactly.
if (FileDownloadServiceProxy.getImpl().isConnected()) {
FileDownloadServiceProxy.getImpl().pauseAllTasks();
} else {
if (pauseAllRunnable == null) {
pauseAllRunnable = new Runnable() {
@Override
public void run() {
FileDownloadServiceProxy.getImpl().pauseAllTasks();
}
};
}
FileDownloadServiceProxy.getImpl()
.bindStartByContext(FileDownloadHelper.getAppContext(), pauseAllRunnable);
}
}
示例14: getStatus
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
/**
* @param id The downloadId.
* @param path The target file path.
* @return the downloading status.
* @see FileDownloadStatus
* @see #getStatus(String, String)
* @see #getStatusIgnoreCompleted(int)
*/
public byte getStatus(final int id, final String path) {
byte status;
BaseDownloadTask.IRunningTask task = FileDownloadList.getImpl().get(id);
if (task == null) {
status = FileDownloadServiceProxy.getImpl().getStatus(id);
} else {
status = task.getOrigin().getStatus();
}
if (path != null && status == FileDownloadStatus.INVALID_STATUS) {
if (FileDownloadUtils.isFilenameConverted(FileDownloadHelper.getAppContext())
&& new File(path).exists()) {
status = FileDownloadStatus.completed;
}
}
return status;
}
示例15: onCreate
import com.liulishuo.filedownloader.util.FileDownloadHelper; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
FileDownloadHelper.holdContext(this);
try {
FileDownloadUtils.setMinProgressStep(
FileDownloadProperties.getImpl().downloadMinProgressStep);
FileDownloadUtils.setMinProgressTime(
FileDownloadProperties.getImpl().downloadMinProgressTime);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
final FileDownloadManager manager = new FileDownloadManager();
if (FileDownloadProperties.getImpl().processNonSeparate) {
handler = new FDServiceSharedHandler(new WeakReference<>(this), manager);
} else {
handler = new FDServiceSeparateHandler(new WeakReference<>(this), manager);
}
}