@Override public Intent getIntent() { return mJobWork.getIntent(); }
@Override public Intent getIntent() { return mJobWork.getIntent(); }
private void scheduleWork(final JobParameters params) { if (!threadPool.isShutdown()) { JobWorkItem item; while ((item=params.dequeueWork())!=null) { final int workIndex=item.getIntent().getIntExtra(EXTRA_WORK_INDEX, -1); final String url=item.getIntent().getData().toString(); final JobWorkItem itemToDo=item; threadPool.execute(new Runnable() { @Override public void run() { download(workIndex, url); params.completeWork(itemToDo); scheduleWork(params); } }); } } }
/** * Dequeue some work. */ @Override public TinkerJobIntentService.GenericWorkItem dequeueWork() { JobWorkItem work; synchronized (mLock) { if (mParams == null) { return null; } try { work = mParams.dequeueWork(); } catch (Throwable thr) { Log.w(TAG, "exception occurred.", thr); work = null; } } if (work != null) { work.getIntent().setExtrasClassLoader(mService.getClassLoader()); return new WrapperWorkItem(work); } else { return null; } } }
/** * Dequeue some work. */ @Override public JobIntentService.GenericWorkItem dequeueWork() { JobWorkItem work = null; synchronized (mLock) { if (mParams == null) { return null; } try { work = mParams.dequeueWork(); } catch (SecurityException se) { //ignore se.printStackTrace(); } } if (work != null) { work.getIntent().setExtrasClassLoader(mService.getClassLoader()); return new WrapperWorkItem(work); } else { return null; } } }
@Override public Intent getIntent() { return mJobWork.getIntent(); }
@Override public Intent getIntent() { return mJobWork.getIntent(); }
@Override protected Void doInBackground(Void... params) { boolean cancelled; JobWorkItem work; /** * Iterate over available work. Once dequeueWork() returns null, the * job's work queue is empty and the job has stopped, so we can let this * async task complete. */ while (!(cancelled=isCancelled()) && (work=mParams.dequeueWork()) != null) { String txt = work.getIntent().getStringExtra("Key1"); Log.i("JobWorkService", "Processing work: " + work + ", msg: " + txt); showNotification(txt); // Process work here... we'll pretend by sleeping. try { Thread.sleep(5000); } catch (InterruptedException e) { } hideNotification(); // Tell system we have finished processing the work. Log.i("JobWorkService", "Done with: " + work); mParams.completeWork(work); } if (cancelled) { Log.i("JobWorkService", "CANCELLED!"); } return null; } }
/** * Dequeue some work. */ @Override public JobIntentService.GenericWorkItem dequeueWork() { JobWorkItem work = null; synchronized (mLock) { if (mParams == null) { return null; } try { work = mParams.dequeueWork(); } catch (SecurityException se) { //ignore se.printStackTrace(); } } if (work != null) { work.getIntent().setExtrasClassLoader(mService.getClassLoader()); return new WrapperWorkItem(work); } else { return null; } } }
/** * Dequeue some work. */ @Override public JobIntentService.GenericWorkItem dequeueWork() { JobWorkItem work = null; synchronized (mLock) { if (mParams == null) { return null; } try { work = mParams.dequeueWork(); } catch (SecurityException se) { //ignore se.printStackTrace(); } } if (work != null) { work.getIntent().setExtrasClassLoader(mService.getClassLoader()); return new WrapperWorkItem(work); } else { return null; } } }