Skip to content

Commit

Permalink
asd
Browse files Browse the repository at this point in the history
asd
  • Loading branch information
abenkdh committed Dec 16, 2019
1 parent 34fdd4f commit 82d1eff
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 9 deletions.
Binary file modified .gradle/5.4.1/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/5.4.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/5.4.1/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file modified .gradle/5.4.1/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified .gradle/5.4.1/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.benkkstudio.bsjson.API;
import com.benkkstudio.bsjson.BSJsonV2;
import com.benkkstudio.bsjson.Interface.BSJsonV2Listener;
import com.google.gson.Gson;
import com.google.gson.JsonObject;

import org.json.JSONObject;

public class MainActivity extends AppCompatActivity {

@Override
Expand All @@ -23,6 +26,12 @@ protected void onCreate(Bundle savedInstanceState) {
.setParams(BSJsonV2.makeRequest(jsObj))
.setPurchaseCode("52394c52-11f0-4c5a-91d7-7c2c7c054fdb")
.setServer("https://benkkstudio.xyz/bsvideostatus/api.php")
.setListener(new BSJsonV2Listener() {
@Override
public void onLoaded(JSONObject jsonObject) {
Toast.makeText(MainActivity.this, "asdasd", Toast.LENGTH_SHORT).show();
}
})
.load();
}
}
18 changes: 9 additions & 9 deletions bsjson/src/main/java/com/benkkstudio/bsjson/BSJsonV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ public class BSJsonV2 {
private String server;
private BSJsonV2Listener bsJsonV2Listener;
private String purchaseCode;
private RequestBody requestBody;
private JsonObject jsonObject;

private BSJsonV2(Activity activity,
String server, RequestBody requestBody,
String server, JsonObject jsonObject,
BSJsonV2Listener bsJsonV2Listener,
String purchaseCode) {
this.activity = activity;
this.server = server;
this.bsJsonV2Listener = bsJsonV2Listener;
this.purchaseCode = purchaseCode;
this.requestBody = requestBody;
this.jsonObject = jsonObject;
verifyNow();
}

Expand Down Expand Up @@ -93,7 +93,7 @@ protected void onPreExecute() {
@Override
protected JSONObject doInBackground(JSONObject... strings) {
try {
String responseBody = API.okhttpPost(server, requestBody);
String responseBody = API.okhttpPost(server, makeRequest(jsonObject));
return new JSONObject(responseBody);
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -112,7 +112,7 @@ protected void onPostExecute(JSONObject jsonObject) {
}
}

public static RequestBody makeRequest(JsonObject jsObj) {
public RequestBody makeRequest(JsonObject jsObj) {
return new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("data", API.toBase64(jsObj.toString()))
Expand All @@ -123,7 +123,7 @@ public static class Builder {
private Activity activity;
private String server;
private BSJsonV2Listener bsJsonV2Listener;
private RequestBody requestBody;
private JsonObject jsonObject;
private String purchaseCode;

public Builder(Activity activity) {
Expand All @@ -136,8 +136,8 @@ public BSJsonV2.Builder setServer(String server) {
}


public BSJsonV2.Builder setParams(RequestBody requestBody) {
this.requestBody = requestBody;
public BSJsonV2.Builder setParams(JsonObject jsonObject) {
this.jsonObject = jsonObject;
return this;
}

Expand All @@ -152,7 +152,7 @@ public BSJsonV2.Builder setListener(BSJsonV2Listener bsJsonV2Listener) {
}

public BSJsonV2 load() {
return new BSJsonV2(activity, server, requestBody, bsJsonV2Listener, purchaseCode);
return new BSJsonV2(activity, server, jsonObject, bsJsonV2Listener, purchaseCode);
}
}
}

0 comments on commit 82d1eff

Please sign in to comment.