Skip to content

Commit

Permalink
Fixed some bugs and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
shuboooom committed Sep 25, 2019
1 parent bf7330a commit 98c0fc2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/pingmelive/application.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void onCreate() {
.setErrorEventEnabled(true)
.setErrorEventTitle("ERROR_TITLE")
.setAPI_KEY("YOUR_API_KEY")
.setAPP_ID("YOUR_APP_ID")
.setPROJECT_ID("YOUR_APP_ID")
.install();
}
}
32 changes: 16 additions & 16 deletions pingmelive/src/main/java/com/pingmelive/pingMeLive.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected pingMeLive(Builder builder) {
this.builder = builder;
}

public static void install(@Nullable final Context context,boolean errorEvents, final String errorEventTitle, String APIKEY,String appId) {
public static void install(@Nullable final Context context,boolean errorEvents, final String errorEventTitle, String API_KEY,String PROJECT_ID) {

if(errorEvents) {
try {
Expand All @@ -73,23 +73,23 @@ public static void install(@Nullable final Context context,boolean errorEvents,
return;
}

if (APIKEY == null || APIKEY.trim().length() <= 0) {
if (API_KEY == null || API_KEY.trim().length() <= 0) {
Log.e(TAG, "API KEY needed check your application class");
Log.e(TAG, "pingMeLive not installed.");
return;
}

if (appId == null || appId.trim().length() <= 0) {
Log.e(TAG, "appId needed check your application class");
if (PROJECT_ID == null || PROJECT_ID.trim().length() <= 0) {
Log.e(TAG, "PROJECT_ID needed check your application class");
Log.e(TAG, "pingMeLive not installed.");
return;
}

dbHelper = DBHelper.getInstance(context);
pingMePref = com.pingmelive.pingMePref.getInstance(context);

pingMePref.setAPIKey(APIKEY);
pingMePref.setAppId(appId);
pingMePref.setAPIKey(API_KEY);
pingMePref.setAppId(PROJECT_ID);

//INSTALL!
final Thread.UncaughtExceptionHandler oldHandler = Thread.getDefaultUncaughtExceptionHandler();
Expand Down Expand Up @@ -144,13 +144,13 @@ public void uncaughtException(Thread thread, final Throwable throwable) {
}
else {

if (APIKEY == null || APIKEY.trim().length() <= 0) {
if (API_KEY == null || API_KEY.trim().length() <= 0) {
Log.e(TAG, "API KEY needed check your application class");
Log.e(TAG, "pingMeLive not installed.");
return;
}

if (appId == null || appId.trim().length() <= 0) {
if (PROJECT_ID == null || PROJECT_ID.trim().length() <= 0) {
Log.e(TAG, "appId needed check your application class");
Log.e(TAG, "pingMeLive not installed.");
return;
Expand All @@ -162,8 +162,8 @@ public void uncaughtException(Thread thread, final Throwable throwable) {
dbHelper = DBHelper.getInstance(context);
pingMePref = com.pingmelive.pingMePref.getInstance(context);

pingMePref.setAPIKey(APIKEY);
pingMePref.setAppId(appId);
pingMePref.setAPIKey(API_KEY);
pingMePref.setAppId(PROJECT_ID);

dbHelper.sendData();
}
Expand Down Expand Up @@ -255,7 +255,7 @@ public static class Builder {
boolean ErrorEventEnabled = true;
String ErrorEventTitle = null;
String API_KEY = null;
String APP_ID = null;
String PROJECT_ID = null;
Context context;

public Builder(Context context)
Expand Down Expand Up @@ -290,17 +290,17 @@ public Builder setAPI_KEY(String API_KEY) {
return this;
}

String getAPP_ID() {
return APP_ID;
public String getPROJECT_ID() {
return PROJECT_ID;
}

public Builder setAPP_ID(String APP_ID) {
this.APP_ID = APP_ID;
public Builder setPROJECT_ID(String PROJECT_ID) {
this.PROJECT_ID = PROJECT_ID;
return this;
}

public void install() {
pingMeLive.install(context,isErrorEventEnabled(),getErrorEventTitle(),getAPI_KEY(),getAPP_ID());
pingMeLive.install(context,isErrorEventEnabled(),getErrorEventTitle(),getAPI_KEY(),getPROJECT_ID());
}
}
}
3 changes: 3 additions & 0 deletions pingmelive/src/main/java/com/pingmelive/sendLogToServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void sync_local_to_server(final pingModel pingModel) {
@Override
public void onResponse(String response) {

Log.e("API Response",""+response);
Log.e("Data","Sent to server");
dbHelper.removeEvent(pingModel.getId());

Expand Down Expand Up @@ -119,6 +120,7 @@ public byte[] getBody() throws AuthFailureError {
}
String str = jsonObject.toString();

Log.e("API Body",jsonObject.toString());
return str.getBytes();
}

Expand All @@ -131,6 +133,7 @@ public Map<String, String> getHeaders() {
headers.put("apikey",pingMePref.getAPIKey());
headers.put("projectid",pingMePref.getAppId());

Log.e("API Header",headers.toString());
return headers;
}

Expand Down

0 comments on commit 98c0fc2

Please sign in to comment.