Skip to content

Commit

Permalink
code cleanup on Fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyofrancis committed Feb 23, 2017
1 parent 4f7c645 commit 3dc8431
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions fetch/src/main/java/com/tonyodev/fetch/Fetch.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
* Fetch is a download manager for the FetchService.
Expand All @@ -59,7 +57,6 @@
public final class Fetch implements FetchConst {

private static final Handler mainHandler = new Handler(Looper.getMainLooper());
private static final Executor executor = Executors.newSingleThreadExecutor();
private static final ConcurrentMap<Request,FetchCallRunnable> callsMap = new ConcurrentHashMap<>();

private final Context context;
Expand Down Expand Up @@ -253,7 +250,6 @@ public void removeFetchListener(@NonNull FetchListener fetchListener) {
public void removeFetchListeners() {

Utils.throwIfNotUsable(this);

listeners.clear();
}

Expand All @@ -268,7 +264,7 @@ public void removeFetchListeners() {
* @throws NullPointerException if the passed in request is null.
* @throws NotUsableException if the release method has been called on Fetch.
* */
public long enqueue(final @NonNull Request request) {
public long enqueue(@NonNull Request request) {

Utils.throwIfNotUsable(this);

Expand Down Expand Up @@ -544,7 +540,7 @@ public void retry(long id) {
* @throws NotUsableException if the release method has been called on Fetch.
* */
@Nullable
public RequestInfo get(final long id) {
public RequestInfo get(long id) {

Utils.throwIfNotUsable(this);

Expand Down Expand Up @@ -583,7 +579,7 @@ public List<RequestInfo> get() {
* @throws NotUsableException if the release method has been called on Fetch.
* */
@NonNull
public List<RequestInfo> getByStatus(final int status) {
public List<RequestInfo> getByStatus(int status) {

Utils.throwIfNotUsable(this);
Utils.throwIfInvalidStatus(status);
Expand Down Expand Up @@ -630,7 +626,7 @@ public RequestInfo get(@NonNull Request request) {
* @throws NotUsableException if the release method has been called on Fetch.
* */
@Nullable
public File getDownloadedFile(final long id) {
public File getDownloadedFile(long id) {

Utils.throwIfNotUsable(this);

Expand Down Expand Up @@ -665,7 +661,7 @@ public File getDownloadedFile(final long id) {
* @throws NotUsableException if the release method has been called on Fetch.
* */
@Nullable
public String getFilePath(final long id) {
public String getFilePath(long id) {

Utils.throwIfNotUsable(this);

Expand All @@ -691,7 +687,7 @@ public String getFilePath(final long id) {
* @throws NotUsableException if the release method has been called on Fetch.
*
* */
public long addCompletedDownload(@NonNull final String filePath) {
public long addCompletedDownload(@NonNull String filePath) {

Utils.throwIfNotUsable(this);

Expand Down Expand Up @@ -837,15 +833,14 @@ public void runOnBackgroundThread(@NonNull final FetchTask fetchTask) {
Utils.throwIfNotUsable(this);
Utils.throwIfFetchTaskNull(fetchTask);

executor.execute(new Runnable() {
new Thread(new Runnable() {
@Override
public void run() {

Fetch fetch = Fetch.getInstance(context);
fetchTask.onProcess(fetch);
fetch.release();
}
});
}).start();
}

/**
Expand Down

0 comments on commit 3dc8431

Please sign in to comment.