Back to project page foreman.
The source code is released under:
GNU General Public License
If you think the Android project foreman listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ajaso.android.foreman; //from www.ja v a 2 s . co m import com.ajaso.android.stream.StreamProgress; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; /** * Author: Adam J Jaso, Jr * Copyright: Adam J Jaso, Jr 2014 */ public abstract class Job { private Map<String, Object> meta = Collections.synchronizedMap(new LinkedHashMap<String, Object>(8, 0.75f, true)); private Connect connect; private StreamProgress remoteProgress; private StreamProgress progress; private Cancel cancel; private Complete callback; public Job meta(String key, Object val) { this.meta.put(key, val); return this; } public Object meta(String key) { return this.meta.get(key); } public Job connect(Connect connect) { this.connect = connect; return this; } public void connecting() { if (this.connect != null) { this.connect.onConnecting(this); } } public void connected() { if (this.connect != null) { this.connect.onConnected(this); } } public Job remoteProgress(StreamProgress progress) { this.remoteProgress = progress; return this; } public Job progress(StreamProgress progress) { this.progress = progress; return this; } public void progress(int progress) { if (this.progress != null) { this.progress.onProgress(this, progress); } } protected StreamProgress remoteProgress() { return remoteProgress; } public abstract Result handleRequest(); public Job callback(Complete callback) { this.callback = callback; return this; } public void callback(Result result) { this.callback.onResult(this, result); } public Job cancel(Cancel cancel) { this.cancel = cancel; return this; } public void cancelled() { if (this.cancel != null) { this.cancel.onCancelled(this); } } }