本文整理汇总了Java中com.liulishuo.filedownloader.util.FileDownloadLog.NEED_LOG属性的典型用法代码示例。如果您正苦于以下问题:Java FileDownloadLog.NEED_LOG属性的具体用法?Java FileDownloadLog.NEED_LOG怎么用?Java FileDownloadLog.NEED_LOG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.liulishuo.filedownloader.util.FileDownloadLog
的用法示例。
在下文中一共展示了FileDownloadLog.NEED_LOG属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publish
@Override
public boolean publish(final IDownloadEvent event) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.v(this, "publish %s", event.getId());
}
Assert.assertNotNull("EventPoolImpl.publish", event);
String eventId = event.getId();
LinkedList<IDownloadListener> listeners = listenersMap.get(eventId);
if (listeners == null) {
synchronized (eventId.intern()) {
listeners = listenersMap.get(eventId);
if (listeners == null) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "No listener for this event %s", eventId);
}
return false;
}
}
}
trigger(listeners, event);
return true;
}
示例2: notifyProgress
@Override
public void notifyProgress(MessageSnapshot snapshot) {
final BaseDownloadTask originTask = mTask.getOrigin();
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "notify progress %s %d %d",
originTask, originTask.getLargeFileSoFarBytes(),
originTask.getLargeFileTotalBytes());
}
if (originTask.getCallbackProgressTimes() <= 0) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "notify progress but client not request notify %s", mTask);
}
return;
}
mLifeCycleCallback.onIng();
process(snapshot);
}
示例3: onOver
@Override
public void onOver() {
final BaseDownloadTask origin = mTask.getRunningTask().getOrigin();
if (FileDownloadMonitor.isValid()) {
FileDownloadMonitor.getMonitor().onTaskOver(origin);
}
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.v(this, "filedownloader:lifecycle:over %s by %d ", toString(),
getStatus());
}
mSpeedMonitor.end(this.mSoFarBytes);
if (mTask.getFinishListenerList() != null) {
@SuppressWarnings("unchecked") final ArrayList<BaseDownloadTask.FinishListener>
listenersCopy =
(ArrayList<BaseDownloadTask.FinishListener>) mTask.getFinishListenerList().clone();
final int numListeners = listenersCopy.size();
for (int i = 0; i < numListeners; ++i) {
listenersCopy.get(i).over(origin);
}
}
FileDownloader.getImpl().getLostConnectedHandler().taskWorkFine(mTask.getRunningTask());
}
示例4: onAssembledTasksToStart
private boolean onAssembledTasksToStart(int attachKey, final List<BaseDownloadTask.IRunningTask> list,
final FileDownloadListener listener, boolean isSerial) {
if (FileDownloadMonitor.isValid()) {
FileDownloadMonitor.getMonitor().onRequestStart(list.size(), true, listener);
}
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.v(FileDownloader.class, "start list attachKey[%d] size[%d] " +
"listener[%s] isSerial[%B]", attachKey, list.size(), listener, isSerial);
}
if (list == null || list.isEmpty()) {
FileDownloadLog.w(FileDownloader.class, "Tasks with the listener can't start, " +
"because can't find any task with the provided listener, maybe tasks " +
"instance has been started in the past, so they are all are inUsing, if " +
"in this case, you can use [BaseDownloadTask#reuse] to reuse theme " +
"first then start again: [%s, %B]",
listener, isSerial);
return true;
}
return false;
}
示例5: goNext
private void goNext(final int nextIndex) {
if (this.mHandler == null || this.mList == null) {
FileDownloadLog.w(this, "need go next %d, but params is not ready %s %s",
nextIndex, this.mHandler, this.mList);
return;
}
Message nextMsg = this.mHandler.obtainMessage();
nextMsg.what = WHAT_SERIAL_NEXT;
nextMsg.arg1 = nextIndex;
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(SerialHandlerCallback.class, "start next %s %s",
this.mList == null ? null : this.mList.get(0) == null ? null :
this.mList.get(0).getOrigin().getListener(), nextMsg.arg1);
}
this.mHandler.sendMessage(nextMsg);
}
示例6: addListener
@Override
public boolean addListener(final String eventId, final IDownloadListener listener) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.v(this, "setListener %s", eventId);
}
Assert.assertNotNull("EventPoolImpl.add", listener);
LinkedList<IDownloadListener> container = listenersMap.get(eventId);
if (container == null) {
synchronized (eventId.intern()) {
container = listenersMap.get(eventId);
if (container == null) {
listenersMap.put(eventId, container = new LinkedList<>());
}
}
}
synchronized (eventId.intern()) {
return container.add(listener);
}
}
示例7: onStatusChanged
private void onStatusChanged(final byte status) {
// In current situation, it maybe invoke this method simultaneously between #onPause() and
// others.
if (model.getStatus() == FileDownloadStatus.paused) {
if (FileDownloadLog.NEED_LOG) {
/**
* Already paused or the current status is paused.
*
* We don't need to call-back to Task in here, because the pause status has
* already handled by {@link BaseDownloadTask#pause()} manually.
*
* In some case, it will arrive here by High concurrent cause. For performance
* more make sense.
*
* High concurrent cause.
*/
FileDownloadLog.d(this, "High concurrent cause, Already paused and we don't " +
"need to call-back to Task in here, %d", model.getId());
}
return;
}
MessageSnapshotFlow.getImpl().inflow(MessageSnapshotTaker.take(status, model, processParams));
}
示例8: onError
@Override
public void onError(Exception exception) {
if (paused) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "the task[%d] has already been paused, so pass the" +
" error callback", model.getId());
}
return;
}
// discard all
@SuppressWarnings("unchecked") ArrayList<DownloadRunnable> discardList =
(ArrayList<DownloadRunnable>) downloadRunnableList.clone();
for (DownloadRunnable runnable : discardList) {
if (runnable != null) {
runnable.discard();
// if runnable is null, then that one must be completed and removed
}
}
statusCallback.onError(exception);
}
示例9: createOutputStreamCreator
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();
}
}
示例10: updateKeepFlow
@Override
public boolean updateKeepFlow(MessageSnapshot snapshot) {
final int currentStatus = getStatus();
final int nextStatus = snapshot.getStatus();
if (FileDownloadStatus.paused == currentStatus && FileDownloadStatus.isIng(nextStatus)) {
if (FileDownloadLog.NEED_LOG) {
/**
* Occur such situation, must be the running-mStatus waiting for turning up in flow
* thread pool(or binder thread) when there is someone invoked the {@link #pause()} .
*
* High concurrent cause.
*/
FileDownloadLog.d(this, "High concurrent cause, callback pending, but has already" +
" be paused %d", getId());
}
return true;
}
if (!FileDownloadStatus.isKeepFlow(currentStatus, nextStatus)) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "can't update mStatus change by keep flow, %d, but the" +
" current mStatus is %d, %d", mStatus, getStatus(), getId());
}
return false;
}
update(snapshot);
return true;
}
示例11: receive
@Override
public void receive(MessageSnapshot snapshot) {
final String updateSyncLock = Integer.toString(snapshot.getId());
synchronized (updateSyncLock.intern()) {
final List<BaseDownloadTask.IRunningTask> taskList = FileDownloadList.getImpl().
getReceiveServiceTaskList(snapshot.getId());
if (taskList.size() > 0) {
final BaseDownloadTask topOriginTask = taskList.get(0).getOrigin();
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "~~~callback %s old[%s] new[%s] %d",
snapshot.getId(), topOriginTask.getStatus(), snapshot.getStatus(),
taskList.size());
}
if (!transmitMessage(taskList, snapshot)) {
StringBuilder log = new StringBuilder("The event isn't consumed, id:" + snapshot.getId() + " status:"
+ snapshot.getStatus() + " task-count:" + taskList.size());
for (BaseDownloadTask.IRunningTask task : taskList) {
log.append(" | ").append(task.getOrigin().getStatus());
}
FileDownloadLog.i(this, log.toString());
}
} else {
FileDownloadLog.i(this, "Receive the event %d, but there isn't any running task in " +
"the upper layer", snapshot.getStatus());
}
}
}
示例12: pauseAll
/**
* Pause all running task
*/
public void pauseAll() {
List<Integer> list = mThreadPool.getAllExactRunningDownloadIds();
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "pause all tasks %d", list.size());
}
for (Integer id : list) {
pause(id);
}
}
示例13: asyncPublishInNewThread
@Override
public void asyncPublishInNewThread(final IDownloadEvent event) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.v(this, "asyncPublishInNewThread %s", event.getId());
}
Assert.assertNotNull("EventPoolImpl.asyncPublish event", event);
threadPool.execute(new Runnable() {
@Override
public void run() {
DownloadEventPoolImpl.this.publish(event);
}
});
}
示例14: notifyPaused
@Override
public void notifyPaused(MessageSnapshot snapshot) {
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "notify paused %s", mTask);
}
mLifeCycleCallback.onOver();
process(snapshot);
}
示例15: bindStartByContext
@Override
public void bindStartByContext(final Context context, final Runnable connectedRunnable) {
if (FileDownloadUtils.isDownloaderProcess(context)) {
throw new IllegalStateException("Fatal-Exception: You can't bind the " +
"FileDownloadService in :filedownloader process.\n It's the invalid operation, " +
"and is likely to cause unexpected problems.\n Maybe you want to use" +
" non-separate process mode for FileDownloader, More detail about " +
"non-separate mode, please move to wiki manually:" +
" https://github.com/lingochamp/FileDownloader/wiki/filedownloader.properties");
}
if (FileDownloadLog.NEED_LOG) {
FileDownloadLog.d(this, "bindStartByContext %s", context.getClass().getSimpleName());
}
Intent i = new Intent(context, serviceClass);
if (connectedRunnable != null) {
if (!connectedRunnableList.contains(connectedRunnable)) {
connectedRunnableList.add(connectedRunnable);
}
}
if (!BIND_CONTEXTS.contains(context)) {
// 对称,只有一次remove,防止内存泄漏
BIND_CONTEXTS.add(context);
}
context.bindService(i, this, Context.BIND_AUTO_CREATE);
context.startService(i);
}