Skip to content

Commit

Permalink
hhh
Browse files Browse the repository at this point in the history
hhh
  • Loading branch information
abenkdh committed Feb 29, 2020
1 parent a3a314a commit 20ff50a
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 52 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/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 36 additions & 47 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 29 additions & 3 deletions bsjson/src/main/java/com/benkkstudio/bsjson/BSJsonV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import android.app.Activity;
import android.util.Log;
import android.widget.Toast;

import com.androidnetworking.AndroidNetworking;
Expand All @@ -22,22 +23,39 @@ public class BSJsonV2 {
private BSJsonV2Listener bsJsonV2Listener;
private String purchaseCode;
private int method;
private boolean enable_logging;
private boolean is_verified;
private BSJsonV2(Activity activity,
String server,
JsonObject jsObj,
BSJsonV2Listener bsJsonV2Listener,
String purchaseCode,
int method) {
int method,
boolean enable_logging) {
this.activity = activity;
this.server = server;
this.jsObj = jsObj;
this.bsJsonV2Listener = bsJsonV2Listener;
this.purchaseCode = purchaseCode;
this.method = method;
verifyNow();
this.enable_logging = enable_logging;
if(is_verified){
loadNow();
if (enable_logging){
Log.d("BSJsonV2 : ", "Is Verified");
}
} else {
verifyNow();
if (enable_logging){
Log.d("BSJsonV2 : ", "Not Verified");
}
}
}

private void verifyNow() {
if (enable_logging){
Log.d("BSJsonV2 : ", "Verify purchase to server");
}
AndroidNetworking.get("https://api.envato.com/v3/market/author/sale")
.addHeaders("Authorization", "Bearer 031Cm94VBFWVIwOGuyvfTcvvmvF3EM9b")
.addHeaders("User-Agent", "Purchase code verification on benkkstudio.xyz")
Expand All @@ -48,10 +66,12 @@ private void verifyNow() {
@Override
public void onResponse(String response) {
loadNow();
is_verified = true;
}

@Override
public void onError(ANError error) {
is_verified = false;
Toast.makeText(activity, "Your purchase code not valid", Toast.LENGTH_SHORT).show();
}
});
Expand Down Expand Up @@ -117,6 +137,7 @@ public static class Builder {
private BSJsonV2Listener bsJsonV2Listener;
private String purchaseCode;
private int method;
private boolean enable_logging;
public Builder(Activity activity) {
this.activity = activity;
}
Expand All @@ -133,6 +154,11 @@ public BSJsonV2.Builder setMethod(int method) {
return this;
}

public BSJsonV2.Builder enableLogging(boolean enable_logging) {
this.enable_logging = enable_logging;
return this;
}

public BSJsonV2.Builder setObject(JsonObject jsObj) {
this.jsObj = jsObj;
return this;
Expand All @@ -151,7 +177,7 @@ public BSJsonV2.Builder setListener(BSJsonV2Listener bsJsonV2Listener) {
}

public BSJsonV2 load() {
return new BSJsonV2(activity, server, jsObj, bsJsonV2Listener, purchaseCode, method);
return new BSJsonV2(activity, server, jsObj, bsJsonV2Listener, purchaseCode, method, enable_logging);
}
}
}

0 comments on commit 20ff50a

Please sign in to comment.