From e31227f62e3262031a2c16276c02e0af78c6a572 Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Tue, 11 Sep 2018 18:36:08 +0300 Subject: [PATCH] override constructors --- .../mthmmy/utils/parsing/NetworkTask.java | 13 ++++++++++++ .../mthmmy/utils/parsing/NewParseTask.java | 21 ++++++++++--------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/NetworkTask.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/NetworkTask.java index d2bd3d57..cfceb904 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/NetworkTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/NetworkTask.java @@ -15,6 +15,19 @@ public abstract class NetworkTask extends ExternalAsyncTask private OnParseTaskFinishedListener onParseTaskFinishedListener; + public NetworkTask(OnParseTaskStartedListener onParseTaskStartedListener, OnParseTaskCancelledListener onParseTaskCancelledListener, + OnParseTaskFinishedListener onParseTaskFinishedListener) { + super(onParseTaskStartedListener, onParseTaskCancelledListener, null); + this.onParseTaskFinishedListener = onParseTaskFinishedListener; + } + + public NetworkTask(OnParseTaskStartedListener onParseTaskStartedListener, OnParseTaskFinishedListener onParseTaskFinishedListener) { + super(onParseTaskStartedListener, null); + this.onParseTaskFinishedListener = onParseTaskFinishedListener; + } + + public NetworkTask() {} + @Override protected final Parcel doInBackground(String... input) { Request request = createRequest(input); diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/NewParseTask.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/NewParseTask.java index 0d19c098..0a0591de 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/NewParseTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/NewParseTask.java @@ -2,12 +2,19 @@ package gr.thmmy.mthmmy.utils.parsing; import org.jsoup.nodes.Document; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; - public abstract class NewParseTask extends NetworkTask { + public NewParseTask(OnParseTaskStartedListener onParseTaskStartedListener, OnParseTaskCancelledListener onParseTaskCancelledListener, + OnParseTaskFinishedListener onParseTaskFinishedListener) { + super(onParseTaskStartedListener, onParseTaskCancelledListener, onParseTaskFinishedListener); + } + + public NewParseTask(OnParseTaskStartedListener onParseTaskStartedListener, OnParseTaskFinishedListener onParseTaskFinishedListener) { + super(onParseTaskStartedListener, onParseTaskFinishedListener); + } + + public NewParseTask() {} + @Override final T performTask(Document document) throws ParseException { try { @@ -17,11 +24,5 @@ public abstract class NewParseTask extends NetworkTask { } } - abstract Request createRequest(String... input); - - abstract Response getResponse(Request request, OkHttpClient client); - abstract T parse (Document document); - - abstract int getResultCode(Response response, T data); }