mirror of https://github.com/ThmmyNoLife/mTHMMY
Thodoris1999
6 years ago
5 changed files with 157 additions and 25 deletions
@ -0,0 +1,50 @@ |
|||||
|
package gr.thmmy.mthmmy.activities.main.shoutbox; |
||||
|
|
||||
|
import org.jsoup.nodes.Document; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
|
||||
|
import gr.thmmy.mthmmy.utils.NetworkResultCodes; |
||||
|
import gr.thmmy.mthmmy.utils.NetworkTask; |
||||
|
import okhttp3.MultipartBody; |
||||
|
import okhttp3.OkHttpClient; |
||||
|
import okhttp3.Request; |
||||
|
import okhttp3.Response; |
||||
|
|
||||
|
public class SendShoutTask extends NetworkTask<Void> { |
||||
|
|
||||
|
public SendShoutTask(OnTaskStartedListener onTaskStartedListener, OnNetworkTaskFinishedListener<Void> onNetworkTaskFinishedListener) { |
||||
|
super(onTaskStartedListener, onNetworkTaskFinishedListener); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected Response sendRequest(OkHttpClient client, String... input) throws IOException { |
||||
|
MultipartBody.Builder postBodyBuilder = new MultipartBody.Builder() |
||||
|
.setType(MultipartBody.FORM) |
||||
|
.addFormDataPart("sc", input[2]) |
||||
|
.addFormDataPart("tp-shout", input[1]) |
||||
|
.addFormDataPart("tp-shout-name", input[3]) |
||||
|
.addFormDataPart("shout_send", input[4]) |
||||
|
.addFormDataPart("tp-shout-url", input[5]); |
||||
|
|
||||
|
Request voteRequest = new Request.Builder() |
||||
|
.url(input[0]) |
||||
|
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36") |
||||
|
.post(postBodyBuilder.build()) |
||||
|
.build(); |
||||
|
client.newCall(voteRequest).execute(); |
||||
|
return client.newCall(voteRequest).execute(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
protected Void performTask(Document document, Response response) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected int getResultCode(Response response, Void data) { |
||||
|
return NetworkResultCodes.SUCCESSFUL; |
||||
|
} |
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
package gr.thmmy.mthmmy.model; |
||||
|
|
||||
|
import androidx.annotation.NonNull; |
||||
|
import timber.log.Timber; |
||||
|
|
||||
|
public class Shoutbox { |
||||
|
private Shout[] shouts; |
||||
|
private String sc, sendShoutUrl, shoutName, shoutSend, shoutUrl; |
||||
|
|
||||
|
public Shoutbox(Shout[] shouts, String sc, String sendShoutUrl, String shoutName, String shoutSend, String shoutUrl) { |
||||
|
this.shouts = shouts; |
||||
|
this.sc = sc; |
||||
|
this.sendShoutUrl = sendShoutUrl; |
||||
|
this.shoutName = shoutName; |
||||
|
this.shoutSend = shoutSend; |
||||
|
this.shoutUrl = shoutUrl; |
||||
|
} |
||||
|
|
||||
|
public Shout[] getShouts() { |
||||
|
return shouts; |
||||
|
} |
||||
|
|
||||
|
public String getSc() { |
||||
|
return sc; |
||||
|
} |
||||
|
|
||||
|
public String getSendShoutUrl() { |
||||
|
return sendShoutUrl; |
||||
|
} |
||||
|
|
||||
|
public String getShoutName() { |
||||
|
return shoutName; |
||||
|
} |
||||
|
|
||||
|
public String getShoutSend() { |
||||
|
return shoutSend; |
||||
|
} |
||||
|
|
||||
|
public String getShoutUrl() { |
||||
|
return shoutUrl; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue