Skip to content

Commit

Permalink
fix: android crash when init was not called on main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanneff committed Aug 1, 2017
1 parent a6391d0 commit 1fca206
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,76 +91,76 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo

if (action.equals("setDebug")) {
if (args.length() == 1) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
}
return true;
} else if (action.equals("initSession")) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("setMixpanelToken")) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else {
if (this.instance != null) {
if (action.equals("setIdentity")) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("userCompletedAction")) {
if (args.length() < 1 && args.length() > 2) {
callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
return false;
}
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("sendCommerceEvent")) {
if (args.length() < 1 && args.length() > 2) {
callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
return false;
}
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("getFirstReferringParams")) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("getLatestReferringParams")) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("logout")) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("loadRewards")) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("redeemRewards")) {
if (args.length() < 1 && args.length() > 2) {
callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
return false;
}
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("getCreditHistory")) {
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("createBranchUniversalObject")) {
if (args.length() != 1) {
callbackContext.error(String.format("Parameter mismatched. 1 is required but %d is given", args.length()));
return false;
}
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals(("generateShortUrl"))) {
if (args.length() != 3) {
callbackContext.error(String.format("Parameter mismatched. 3 is required but %d is given", args.length()));
return false;
}
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("registerView")) {
if (args.length() != 1) {
callbackContext.error(String.format("Parameter mismatched. 1 is required but %d is given", args.length()));
return false;
}
cordova.getThreadPool().execute(r);
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("showShareSheet")) {
if (args.length() < 3) {
Expand Down

0 comments on commit 1fca206

Please sign in to comment.