repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequest.java | HttpRequest.dispatchSync | void dispatchSync(DispatchQueue networkQueue) {
long requestStartTime = System.currentTimeMillis();
try {
sendRequestSync();
} catch (NetworkUnavailableException e) {
responseCode = -1; // indicates failure
errorMessage = e.getMessage();
ApptentiveLog.w(NETWORK, e.getMessage());
ApptentiveLog.w(NETWORK, "Cancelled? %b", isCancelled());
} catch (Exception e) {
responseCode = -1; // indicates failure
errorMessage = e.getMessage();
ApptentiveLog.e(NETWORK, "Cancelled? %b", isCancelled());
if (!isCancelled()) {
ApptentiveLog.e(NETWORK, "Unable to perform request: %s", this);
}
// TODO: send error metrics with the details of the request
}
ApptentiveLog.d(NETWORK, "Request finished in %d ms", System.currentTimeMillis() - requestStartTime);
// attempt a retry if request failed
if (isFailed() && retryRequest(networkQueue, responseCode)) { // we schedule request retry on the same queue as it was originally dispatched
return;
}
// use custom callback queue (if any)
if (callbackQueue != null) {
callbackQueue.dispatchAsync(new DispatchTask() {
@Override
protected void execute() {
finishRequest();
}
});
} else {
finishRequest(); // we don't care where the callback is dispatched until it's on a background queue
}
} | java | void dispatchSync(DispatchQueue networkQueue) {
long requestStartTime = System.currentTimeMillis();
try {
sendRequestSync();
} catch (NetworkUnavailableException e) {
responseCode = -1; // indicates failure
errorMessage = e.getMessage();
ApptentiveLog.w(NETWORK, e.getMessage());
ApptentiveLog.w(NETWORK, "Cancelled? %b", isCancelled());
} catch (Exception e) {
responseCode = -1; // indicates failure
errorMessage = e.getMessage();
ApptentiveLog.e(NETWORK, "Cancelled? %b", isCancelled());
if (!isCancelled()) {
ApptentiveLog.e(NETWORK, "Unable to perform request: %s", this);
}
// TODO: send error metrics with the details of the request
}
ApptentiveLog.d(NETWORK, "Request finished in %d ms", System.currentTimeMillis() - requestStartTime);
// attempt a retry if request failed
if (isFailed() && retryRequest(networkQueue, responseCode)) { // we schedule request retry on the same queue as it was originally dispatched
return;
}
// use custom callback queue (if any)
if (callbackQueue != null) {
callbackQueue.dispatchAsync(new DispatchTask() {
@Override
protected void execute() {
finishRequest();
}
});
} else {
finishRequest(); // we don't care where the callback is dispatched until it's on a background queue
}
} | [
"void",
"dispatchSync",
"(",
"DispatchQueue",
"networkQueue",
")",
"{",
"long",
"requestStartTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"sendRequestSync",
"(",
")",
";",
"}",
"catch",
"(",
"NetworkUnavailableException",
"e",
")",
... | Send request synchronously on a background network queue | [
"Send",
"request",
"synchronously",
"on",
"a",
"background",
"network",
"queue"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequest.java#L231-L270 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequest.java | HttpRequest.setRequestProperty | public void setRequestProperty(String key, Object value) {
if (value != null) {
if (requestProperties == null) {
requestProperties = new HashMap<>();
}
requestProperties.put(key, value);
}
} | java | public void setRequestProperty(String key, Object value) {
if (value != null) {
if (requestProperties == null) {
requestProperties = new HashMap<>();
}
requestProperties.put(key, value);
}
} | [
"public",
"void",
"setRequestProperty",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"if",
"(",
"requestProperties",
"==",
"null",
")",
"{",
"requestProperties",
"=",
"new",
"HashMap",
"<>",
"(",
")"... | Sets HTTP request property | [
"Sets",
"HTTP",
"request",
"property"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequest.java#L479-L486 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/model/MessageCenterInteraction.java | MessageCenterInteraction.getWhoCardRequestEnabled | public boolean getWhoCardRequestEnabled() {
InteractionConfiguration configuration = getConfiguration();
if (configuration == null) {
return false;
}
JSONObject profile = configuration.optJSONObject(KEY_PROFILE);
return profile.optBoolean(KEY_PROFILE_REQUEST, true);
} | java | public boolean getWhoCardRequestEnabled() {
InteractionConfiguration configuration = getConfiguration();
if (configuration == null) {
return false;
}
JSONObject profile = configuration.optJSONObject(KEY_PROFILE);
return profile.optBoolean(KEY_PROFILE_REQUEST, true);
} | [
"public",
"boolean",
"getWhoCardRequestEnabled",
"(",
")",
"{",
"InteractionConfiguration",
"configuration",
"=",
"getConfiguration",
"(",
")",
";",
"if",
"(",
"configuration",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"JSONObject",
"profile",
"=",
"c... | When enabled, display Who Card to request profile info | [
"When",
"enabled",
"display",
"Who",
"Card",
"to",
"request",
"profile",
"info"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/model/MessageCenterInteraction.java#L130-L137 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/model/MessageCenterInteraction.java | MessageCenterInteraction.getRegularStatus | public MessageCenterStatus getRegularStatus() {
InteractionConfiguration configuration = getConfiguration();
if (configuration == null) {
return null;
}
JSONObject status = configuration.optJSONObject(KEY_STATUS);
if (status == null) {
return null;
}
String statusBody = status.optString(KEY_STATUS_BODY);
if (statusBody == null || statusBody.isEmpty()) {
return null;
}
return new MessageCenterStatus(statusBody, null);
} | java | public MessageCenterStatus getRegularStatus() {
InteractionConfiguration configuration = getConfiguration();
if (configuration == null) {
return null;
}
JSONObject status = configuration.optJSONObject(KEY_STATUS);
if (status == null) {
return null;
}
String statusBody = status.optString(KEY_STATUS_BODY);
if (statusBody == null || statusBody.isEmpty()) {
return null;
}
return new MessageCenterStatus(statusBody, null);
} | [
"public",
"MessageCenterStatus",
"getRegularStatus",
"(",
")",
"{",
"InteractionConfiguration",
"configuration",
"=",
"getConfiguration",
"(",
")",
";",
"if",
"(",
"configuration",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"JSONObject",
"status",
"=",
... | Regular status shows customer's hours, expected time until response | [
"Regular",
"status",
"shows",
"customer",
"s",
"hours",
"expected",
"time",
"until",
"response"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/model/MessageCenterInteraction.java#L217-L231 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageUtil.java | ImageUtil.createScaledDownImageCacheFile | public static boolean createScaledDownImageCacheFile(String sourcePath, String cachedFileName) {
File localFile = new File(cachedFileName);
// Retrieve image orientation
int imageOrientation = 0;
try {
ExifInterface exif = new ExifInterface(sourcePath);
imageOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
} catch (IOException e) {
}
// Copy the file contents over.
CountingOutputStream cos = null;
try {
cos = new CountingOutputStream(new BufferedOutputStream(new FileOutputStream(localFile)));
System.gc();
Bitmap smaller = ImageUtil.createScaledBitmapFromLocalImageSource(sourcePath, MAX_SENT_IMAGE_EDGE, MAX_SENT_IMAGE_EDGE, null, imageOrientation);
// TODO: Is JPEG what we want here?
smaller.compress(Bitmap.CompressFormat.JPEG, 95, cos);
cos.flush();
ApptentiveLog.v(UTIL, "Bitmap saved, size = " + (cos.getBytesWritten() / 1024) + "k");
smaller.recycle();
System.gc();
} catch (FileNotFoundException e) {
ApptentiveLog.e(UTIL, e, "File not found while storing image.");
logException(e);
return false;
} catch (Exception e) {
ApptentiveLog.a(UTIL, e, "Error storing image.");
logException(e);
return false;
} finally {
Util.ensureClosed(cos);
}
return true;
} | java | public static boolean createScaledDownImageCacheFile(String sourcePath, String cachedFileName) {
File localFile = new File(cachedFileName);
// Retrieve image orientation
int imageOrientation = 0;
try {
ExifInterface exif = new ExifInterface(sourcePath);
imageOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
} catch (IOException e) {
}
// Copy the file contents over.
CountingOutputStream cos = null;
try {
cos = new CountingOutputStream(new BufferedOutputStream(new FileOutputStream(localFile)));
System.gc();
Bitmap smaller = ImageUtil.createScaledBitmapFromLocalImageSource(sourcePath, MAX_SENT_IMAGE_EDGE, MAX_SENT_IMAGE_EDGE, null, imageOrientation);
// TODO: Is JPEG what we want here?
smaller.compress(Bitmap.CompressFormat.JPEG, 95, cos);
cos.flush();
ApptentiveLog.v(UTIL, "Bitmap saved, size = " + (cos.getBytesWritten() / 1024) + "k");
smaller.recycle();
System.gc();
} catch (FileNotFoundException e) {
ApptentiveLog.e(UTIL, e, "File not found while storing image.");
logException(e);
return false;
} catch (Exception e) {
ApptentiveLog.a(UTIL, e, "Error storing image.");
logException(e);
return false;
} finally {
Util.ensureClosed(cos);
}
return true;
} | [
"public",
"static",
"boolean",
"createScaledDownImageCacheFile",
"(",
"String",
"sourcePath",
",",
"String",
"cachedFileName",
")",
"{",
"File",
"localFile",
"=",
"new",
"File",
"(",
"cachedFileName",
")",
";",
"// Retrieve image orientation",
"int",
"imageOrientation",... | This method creates a cached version of the original image, and compresses it in the process so it doesn't fill up the disk. Therefore, do not use
it to store an exact copy of the file in question.
@param sourcePath can be full file path or content uri string
@param cachedFileName file name of the cache to be created (with full path)
@return true if cache file is created successfully | [
"This",
"method",
"creates",
"a",
"cached",
"version",
"of",
"the",
"original",
"image",
"and",
"compresses",
"it",
"in",
"the",
"process",
"so",
"it",
"doesn",
"t",
"fill",
"up",
"the",
"disk",
".",
"Therefore",
"do",
"not",
"use",
"it",
"to",
"store",
... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageUtil.java#L270-L307 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/AdvertiserManager.java | AdvertiserManager.updateAdvertisingIdClientInfo | public static synchronized boolean updateAdvertisingIdClientInfo(Context context) {
ApptentiveLog.v(ADVERTISER_ID, "Updating advertiser ID client info...");
AdvertisingIdClientInfo clientInfo = resolveAdvertisingIdClientInfo(context);
if (clientInfo != null && clientInfo.equals(cachedClientInfo)) {
return false; // no changes
}
ApptentiveLog.v(ADVERTISER_ID, "Advertiser ID client info changed: %s", clientInfo);
cachedClientInfo = clientInfo;
notifyClientInfoChanged(cachedClientInfo);
return true;
} | java | public static synchronized boolean updateAdvertisingIdClientInfo(Context context) {
ApptentiveLog.v(ADVERTISER_ID, "Updating advertiser ID client info...");
AdvertisingIdClientInfo clientInfo = resolveAdvertisingIdClientInfo(context);
if (clientInfo != null && clientInfo.equals(cachedClientInfo)) {
return false; // no changes
}
ApptentiveLog.v(ADVERTISER_ID, "Advertiser ID client info changed: %s", clientInfo);
cachedClientInfo = clientInfo;
notifyClientInfoChanged(cachedClientInfo);
return true;
} | [
"public",
"static",
"synchronized",
"boolean",
"updateAdvertisingIdClientInfo",
"(",
"Context",
"context",
")",
"{",
"ApptentiveLog",
".",
"v",
"(",
"ADVERTISER_ID",
",",
"\"Updating advertiser ID client info...\"",
")",
";",
"AdvertisingIdClientInfo",
"clientInfo",
"=",
... | Returns true if changed | [
"Returns",
"true",
"if",
"changed"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/AdvertiserManager.java#L36-L47 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/storage/PayloadSender.java | PayloadSender.sendPayload | synchronized boolean sendPayload(final PayloadData payload) {
if (payload == null) {
throw new IllegalArgumentException("Payload is null");
}
// we don't allow concurrent payload sending
if (isSendingPayload()) {
return false;
}
// we mark the sender as "busy" so no other payloads would be sent until we're done
sendingFlag = true;
try {
sendPayloadRequest(payload);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while sending payload: %s", payload);
logException(e);
// for NullPointerException, the message object would be null, we should handle it separately
// TODO: add a helper class for handling that
String message = e.getMessage();
if (message == null) {
message = StringUtils.format("%s is thrown", e.getClass().getSimpleName());
}
// if an exception was thrown - mark payload as failed
handleFinishSendingPayload(payload, false, message, -1, null); // TODO: a better approach
}
return true;
} | java | synchronized boolean sendPayload(final PayloadData payload) {
if (payload == null) {
throw new IllegalArgumentException("Payload is null");
}
// we don't allow concurrent payload sending
if (isSendingPayload()) {
return false;
}
// we mark the sender as "busy" so no other payloads would be sent until we're done
sendingFlag = true;
try {
sendPayloadRequest(payload);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while sending payload: %s", payload);
logException(e);
// for NullPointerException, the message object would be null, we should handle it separately
// TODO: add a helper class for handling that
String message = e.getMessage();
if (message == null) {
message = StringUtils.format("%s is thrown", e.getClass().getSimpleName());
}
// if an exception was thrown - mark payload as failed
handleFinishSendingPayload(payload, false, message, -1, null); // TODO: a better approach
}
return true;
} | [
"synchronized",
"boolean",
"sendPayload",
"(",
"final",
"PayloadData",
"payload",
")",
"{",
"if",
"(",
"payload",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Payload is null\"",
")",
";",
"}",
"// we don't allow concurrent payload sendi... | Sends payload asynchronously. Returns boolean flag immediately indicating if payload send was
scheduled
@throws IllegalArgumentException is payload is null | [
"Sends",
"payload",
"asynchronously",
".",
"Returns",
"boolean",
"flag",
"immediately",
"indicating",
"if",
"payload",
"send",
"was",
"scheduled"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/PayloadSender.java#L67-L98 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/storage/PayloadSender.java | PayloadSender.handleFinishSendingPayload | private synchronized void handleFinishSendingPayload(PayloadData payload, boolean cancelled, String errorMessage, int responseCode, JSONObject responseData) {
sendingFlag = false; // mark sender as 'not busy'
try {
if (listener != null) {
listener.onFinishSending(this, payload, cancelled, errorMessage, responseCode, responseData);
}
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while notifying payload listener");
logException(e);
}
} | java | private synchronized void handleFinishSendingPayload(PayloadData payload, boolean cancelled, String errorMessage, int responseCode, JSONObject responseData) {
sendingFlag = false; // mark sender as 'not busy'
try {
if (listener != null) {
listener.onFinishSending(this, payload, cancelled, errorMessage, responseCode, responseData);
}
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while notifying payload listener");
logException(e);
}
} | [
"private",
"synchronized",
"void",
"handleFinishSendingPayload",
"(",
"PayloadData",
"payload",
",",
"boolean",
"cancelled",
",",
"String",
"errorMessage",
",",
"int",
"responseCode",
",",
"JSONObject",
"responseData",
")",
"{",
"sendingFlag",
"=",
"false",
";",
"//... | Executed when we're done with the current payload
@param payload - current payload
@param cancelled - flag indicating if payload Http-request was cancelled
@param errorMessage - if not <code>null</code> - payload request failed
@param responseCode - http-request response code
@param responseData - http-reqeust response json (or null if failed) | [
"Executed",
"when",
"we",
"re",
"done",
"with",
"the",
"current",
"payload"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/PayloadSender.java#L156-L167 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/model/CommerceExtendedData.java | CommerceExtendedData.addItem | public CommerceExtendedData addItem(Item item) throws JSONException {
if (this.items == null) {
this.items = new ArrayList<>();
}
items.add(item);
return this;
} | java | public CommerceExtendedData addItem(Item item) throws JSONException {
if (this.items == null) {
this.items = new ArrayList<>();
}
items.add(item);
return this;
} | [
"public",
"CommerceExtendedData",
"addItem",
"(",
"Item",
"item",
")",
"throws",
"JSONException",
"{",
"if",
"(",
"this",
".",
"items",
"==",
"null",
")",
"{",
"this",
".",
"items",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"items",
".",
"add"... | Add information about a purchased item to this record. Calls to this method can be chained.
@param item A {@link CommerceExtendedData.Item}
@return This object.
@throws JSONException if item can't be added. | [
"Add",
"information",
"about",
"a",
"purchased",
"item",
"to",
"this",
"record",
".",
"Calls",
"to",
"this",
"method",
"can",
"be",
"chained",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/model/CommerceExtendedData.java#L106-L112 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java | MessageCenterFragment.displayNewIncomingMessageItem | public void displayNewIncomingMessageItem(ApptentiveMessage message) {
messagingActionHandler.sendEmptyMessage(MSG_REMOVE_STATUS);
// Determine where to insert the new incoming message. It will be in front of any eidting
// area, i.e. composing, Who Card ...
int insertIndex = listItems.size(); // If inserted onto the end, then the list will have grown by one.
outside_loop:
// Starting at end of list, go back up the list to find the proper place to insert the incoming message.
for (int i = listItems.size() - 1; i > 0; i--) {
MessageCenterListItem item = listItems.get(i);
switch (item.getListItemType()) {
case MESSAGE_COMPOSER:
case MESSAGE_CONTEXT:
case WHO_CARD:
case STATUS:
insertIndex--;
break;
default:
// Any other type means we are past the temporary items.
break outside_loop;
}
}
listItems.add(insertIndex, message);
messageCenterRecyclerViewAdapter.notifyItemInserted(insertIndex);
int firstIndex = messageCenterRecyclerView.getFirstVisiblePosition();
int lastIndex = messageCenterRecyclerView.getLastVisiblePosition();
boolean composingAreaTakesUpVisibleArea = firstIndex <= insertIndex && insertIndex < lastIndex;
if (composingAreaTakesUpVisibleArea) {
View v = messageCenterRecyclerView.getChildAt(0);
int top = (v == null) ? 0 : v.getTop();
updateMessageSentStates();
// Restore the position of listview to composing view
messagingActionHandler.sendMessage(messagingActionHandler.obtainMessage(MSG_SCROLL_FROM_TOP, insertIndex, top));
} else {
updateMessageSentStates();
}
} | java | public void displayNewIncomingMessageItem(ApptentiveMessage message) {
messagingActionHandler.sendEmptyMessage(MSG_REMOVE_STATUS);
// Determine where to insert the new incoming message. It will be in front of any eidting
// area, i.e. composing, Who Card ...
int insertIndex = listItems.size(); // If inserted onto the end, then the list will have grown by one.
outside_loop:
// Starting at end of list, go back up the list to find the proper place to insert the incoming message.
for (int i = listItems.size() - 1; i > 0; i--) {
MessageCenterListItem item = listItems.get(i);
switch (item.getListItemType()) {
case MESSAGE_COMPOSER:
case MESSAGE_CONTEXT:
case WHO_CARD:
case STATUS:
insertIndex--;
break;
default:
// Any other type means we are past the temporary items.
break outside_loop;
}
}
listItems.add(insertIndex, message);
messageCenterRecyclerViewAdapter.notifyItemInserted(insertIndex);
int firstIndex = messageCenterRecyclerView.getFirstVisiblePosition();
int lastIndex = messageCenterRecyclerView.getLastVisiblePosition();
boolean composingAreaTakesUpVisibleArea = firstIndex <= insertIndex && insertIndex < lastIndex;
if (composingAreaTakesUpVisibleArea) {
View v = messageCenterRecyclerView.getChildAt(0);
int top = (v == null) ? 0 : v.getTop();
updateMessageSentStates();
// Restore the position of listview to composing view
messagingActionHandler.sendMessage(messagingActionHandler.obtainMessage(MSG_SCROLL_FROM_TOP, insertIndex, top));
} else {
updateMessageSentStates();
}
} | [
"public",
"void",
"displayNewIncomingMessageItem",
"(",
"ApptentiveMessage",
"message",
")",
"{",
"messagingActionHandler",
".",
"sendEmptyMessage",
"(",
"MSG_REMOVE_STATUS",
")",
";",
"// Determine where to insert the new incoming message. It will be in front of any eidting",
"// ar... | Call only from handler. | [
"Call",
"only",
"from",
"handler",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java#L694-L731 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/view/holder/MessageComposerHolder.java | MessageComposerHolder.clearImageAttachmentBand | public void clearImageAttachmentBand() {
attachments.setVisibility(View.GONE);
images.clear();
attachments.setData(null);
} | java | public void clearImageAttachmentBand() {
attachments.setVisibility(View.GONE);
images.clear();
attachments.setData(null);
} | [
"public",
"void",
"clearImageAttachmentBand",
"(",
")",
"{",
"attachments",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"images",
".",
"clear",
"(",
")",
";",
"attachments",
".",
"setData",
"(",
"null",
")",
";",
"}"
] | Remove all images from attachment band. | [
"Remove",
"all",
"images",
"from",
"attachment",
"band",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/view/holder/MessageComposerHolder.java#L184-L188 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/view/holder/MessageComposerHolder.java | MessageComposerHolder.addImagesToImageAttachmentBand | public void addImagesToImageAttachmentBand(final List<ImageItem> imagesToAttach) {
if (imagesToAttach == null || imagesToAttach.size() == 0) {
return;
}
attachments.setupLayoutListener();
attachments.setVisibility(View.VISIBLE);
images.addAll(imagesToAttach);
setAttachButtonState();
addAdditionalAttachItem();
attachments.notifyDataSetChanged();
} | java | public void addImagesToImageAttachmentBand(final List<ImageItem> imagesToAttach) {
if (imagesToAttach == null || imagesToAttach.size() == 0) {
return;
}
attachments.setupLayoutListener();
attachments.setVisibility(View.VISIBLE);
images.addAll(imagesToAttach);
setAttachButtonState();
addAdditionalAttachItem();
attachments.notifyDataSetChanged();
} | [
"public",
"void",
"addImagesToImageAttachmentBand",
"(",
"final",
"List",
"<",
"ImageItem",
">",
"imagesToAttach",
")",
"{",
"if",
"(",
"imagesToAttach",
"==",
"null",
"||",
"imagesToAttach",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
... | Add new images to attachment band.
@param imagesToAttach an array of new images to add | [
"Add",
"new",
"images",
"to",
"attachment",
"band",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/view/holder/MessageComposerHolder.java#L195-L205 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/view/holder/MessageComposerHolder.java | MessageComposerHolder.removeImageFromImageAttachmentBand | public void removeImageFromImageAttachmentBand(final int position) {
images.remove(position);
attachments.setupLayoutListener();
setAttachButtonState();
if (images.size() == 0) {
// Hide attachment band after last attachment is removed
attachments.setVisibility(View.GONE);
return;
}
addAdditionalAttachItem();
} | java | public void removeImageFromImageAttachmentBand(final int position) {
images.remove(position);
attachments.setupLayoutListener();
setAttachButtonState();
if (images.size() == 0) {
// Hide attachment band after last attachment is removed
attachments.setVisibility(View.GONE);
return;
}
addAdditionalAttachItem();
} | [
"public",
"void",
"removeImageFromImageAttachmentBand",
"(",
"final",
"int",
"position",
")",
"{",
"images",
".",
"remove",
"(",
"position",
")",
";",
"attachments",
".",
"setupLayoutListener",
"(",
")",
";",
"setAttachButtonState",
"(",
")",
";",
"if",
"(",
"... | Remove an image from attachment band.
@param position the postion index of the image to be removed | [
"Remove",
"an",
"image",
"from",
"attachment",
"band",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/messagecenter/view/holder/MessageComposerHolder.java#L212-L222 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestRetryPolicyDefault.java | HttpRequestRetryPolicyDefault.getRetryTimeoutMillis | @Override
public long getRetryTimeoutMillis(int retryAttempt) {
long temp = Math.min(MAX_RETRY_CAP, (long) (retryTimeoutMillis * Math.pow(2.0, retryAttempt - 1)));
return (long) ((temp / 2) * (1.0 + RANDOM.nextDouble()));
} | java | @Override
public long getRetryTimeoutMillis(int retryAttempt) {
long temp = Math.min(MAX_RETRY_CAP, (long) (retryTimeoutMillis * Math.pow(2.0, retryAttempt - 1)));
return (long) ((temp / 2) * (1.0 + RANDOM.nextDouble()));
} | [
"@",
"Override",
"public",
"long",
"getRetryTimeoutMillis",
"(",
"int",
"retryAttempt",
")",
"{",
"long",
"temp",
"=",
"Math",
".",
"min",
"(",
"MAX_RETRY_CAP",
",",
"(",
"long",
")",
"(",
"retryTimeoutMillis",
"*",
"Math",
".",
"pow",
"(",
"2.0",
",",
"... | Returns the delay in millis for the next retry
@param retryAttempt - number of retries attempted already | [
"Returns",
"the",
"delay",
"in",
"millis",
"for",
"the",
"next",
"retry"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestRetryPolicyDefault.java#L57-L61 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/logic/ConditionalClause.java | ConditionalClause.evaluate | @Override
public boolean evaluate(FieldManager fieldManager, IndentPrinter printer) {
Comparable fieldValue = fieldManager.getValue(fieldName);
for (ConditionalTest test : conditionalTests) {
boolean result = test.operator.apply(fieldValue, test.parameter);
printer.print("- %s => %b", test.operator.description(fieldManager.getDescription(fieldName), fieldValue, test.parameter), result);
if (!result) {
return false;
}
}
return true;
} | java | @Override
public boolean evaluate(FieldManager fieldManager, IndentPrinter printer) {
Comparable fieldValue = fieldManager.getValue(fieldName);
for (ConditionalTest test : conditionalTests) {
boolean result = test.operator.apply(fieldValue, test.parameter);
printer.print("- %s => %b", test.operator.description(fieldManager.getDescription(fieldName), fieldValue, test.parameter), result);
if (!result) {
return false;
}
}
return true;
} | [
"@",
"Override",
"public",
"boolean",
"evaluate",
"(",
"FieldManager",
"fieldManager",
",",
"IndentPrinter",
"printer",
")",
"{",
"Comparable",
"fieldValue",
"=",
"fieldManager",
".",
"getValue",
"(",
"fieldName",
")",
";",
"for",
"(",
"ConditionalTest",
"test",
... | The test in this conditional clause are implicitly ANDed together, so return false if any of them is false, and continue the loop for each test that is true;
@return | [
"The",
"test",
"in",
"this",
"conditional",
"clause",
"are",
"implicitly",
"ANDed",
"together",
"so",
"return",
"false",
"if",
"any",
"of",
"them",
"is",
"false",
"and",
"continue",
"the",
"loop",
"for",
"each",
"test",
"that",
"is",
"true",
";"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/logic/ConditionalClause.java#L66-L77 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/storage/CustomData.java | CustomData.put | @Override
public Serializable put(String key, Serializable value) {
Serializable ret = super.put(key, value);
notifyDataChanged();
return ret;
} | java | @Override
public Serializable put(String key, Serializable value) {
Serializable ret = super.put(key, value);
notifyDataChanged();
return ret;
} | [
"@",
"Override",
"public",
"Serializable",
"put",
"(",
"String",
"key",
",",
"Serializable",
"value",
")",
"{",
"Serializable",
"ret",
"=",
"super",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"notifyDataChanged",
"(",
")",
";",
"return",
"ret",
";",... | region Saving when modified | [
"region",
"Saving",
"when",
"modified"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/storage/CustomData.java#L43-L48 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/migration/v4_0_0/VersionHistoryStore.java | VersionHistoryStore.getTimeAtInstall | public static synchronized Apptentive.DateTime getTimeAtInstall(Selector selector) {
ensureLoaded();
for (VersionHistoryEntry entry : versionHistoryEntries) {
switch (selector) {
case total:
// Since the list is ordered, this will be the first and oldest entry.
return new Apptentive.DateTime(entry.getTimestamp());
case version_code:
if (entry.getVersionCode() == RuntimeUtils.getAppVersionCode(ApptentiveInternal.getInstance().getApplicationContext())) {
return new Apptentive.DateTime(entry.getTimestamp());
}
break;
case version_name:
Apptentive.Version entryVersionName = new Apptentive.Version();
Apptentive.Version currentVersionName = new Apptentive.Version();
entryVersionName.setVersion(entry.getVersionName());
currentVersionName.setVersion(RuntimeUtils.getAppVersionName(ApptentiveInternal.getInstance().getApplicationContext()));
if (entryVersionName.equals(currentVersionName)) {
return new Apptentive.DateTime(entry.getTimestamp());
}
break;
}
}
return new Apptentive.DateTime(Util.currentTimeSeconds());
} | java | public static synchronized Apptentive.DateTime getTimeAtInstall(Selector selector) {
ensureLoaded();
for (VersionHistoryEntry entry : versionHistoryEntries) {
switch (selector) {
case total:
// Since the list is ordered, this will be the first and oldest entry.
return new Apptentive.DateTime(entry.getTimestamp());
case version_code:
if (entry.getVersionCode() == RuntimeUtils.getAppVersionCode(ApptentiveInternal.getInstance().getApplicationContext())) {
return new Apptentive.DateTime(entry.getTimestamp());
}
break;
case version_name:
Apptentive.Version entryVersionName = new Apptentive.Version();
Apptentive.Version currentVersionName = new Apptentive.Version();
entryVersionName.setVersion(entry.getVersionName());
currentVersionName.setVersion(RuntimeUtils.getAppVersionName(ApptentiveInternal.getInstance().getApplicationContext()));
if (entryVersionName.equals(currentVersionName)) {
return new Apptentive.DateTime(entry.getTimestamp());
}
break;
}
}
return new Apptentive.DateTime(Util.currentTimeSeconds());
} | [
"public",
"static",
"synchronized",
"Apptentive",
".",
"DateTime",
"getTimeAtInstall",
"(",
"Selector",
"selector",
")",
"{",
"ensureLoaded",
"(",
")",
";",
"for",
"(",
"VersionHistoryEntry",
"entry",
":",
"versionHistoryEntries",
")",
"{",
"switch",
"(",
"selecto... | Returns the number of seconds since the first time we saw this release of the app. Since the version entries are
always stored in order, the first matching entry happened first.
@param selector - The type of version entry we are looking for: total, version, or build.
@return A DateTime representing the number of seconds since we first saw the desired app release entry. A DateTime with current time if never seen. | [
"Returns",
"the",
"number",
"of",
"seconds",
"since",
"the",
"first",
"time",
"we",
"saw",
"this",
"release",
"of",
"the",
"app",
".",
"Since",
"the",
"version",
"entries",
"are",
"always",
"stored",
"in",
"order",
"the",
"first",
"matching",
"entry",
"hap... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/migration/v4_0_0/VersionHistoryStore.java#L109-L133 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/migration/v4_0_0/VersionHistoryStore.java | VersionHistoryStore.isUpdate | public static synchronized boolean isUpdate(Selector selector) {
ensureLoaded();
Set<String> uniques = new HashSet<String>();
for (VersionHistoryEntry entry : versionHistoryEntries) {
switch (selector) {
case version_name:
uniques.add(entry.getVersionName());
break;
case version_code:
uniques.add(String.valueOf(entry.getVersionCode()));
break;
default:
break;
}
}
return uniques.size() > 1;
} | java | public static synchronized boolean isUpdate(Selector selector) {
ensureLoaded();
Set<String> uniques = new HashSet<String>();
for (VersionHistoryEntry entry : versionHistoryEntries) {
switch (selector) {
case version_name:
uniques.add(entry.getVersionName());
break;
case version_code:
uniques.add(String.valueOf(entry.getVersionCode()));
break;
default:
break;
}
}
return uniques.size() > 1;
} | [
"public",
"static",
"synchronized",
"boolean",
"isUpdate",
"(",
"Selector",
"selector",
")",
"{",
"ensureLoaded",
"(",
")",
";",
"Set",
"<",
"String",
">",
"uniques",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"VersionHistoryEntr... | Returns true if the current version or build is not the first version or build that we have seen. Basically, it just
looks for two or more versions or builds.
@param selector - The type of version entry we are looking for: version, or build.
@return True if there are records with more than one version or build, depending on the value of selector. | [
"Returns",
"true",
"if",
"the",
"current",
"version",
"or",
"build",
"is",
"not",
"the",
"first",
"version",
"or",
"build",
"that",
"we",
"have",
"seen",
".",
"Basically",
"it",
"just",
"looks",
"for",
"two",
"or",
"more",
"versions",
"or",
"builds",
"."... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/migration/v4_0_0/VersionHistoryStore.java#L142-L158 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/migration/v4_0_0/VersionHistoryStore.java | VersionHistoryStore.getBaseArray | public static JSONArray getBaseArray() {
ensureLoaded();
JSONArray baseArray = new JSONArray();
for (VersionHistoryEntry entry : versionHistoryEntries) {
baseArray.put(entry);
}
return baseArray;
} | java | public static JSONArray getBaseArray() {
ensureLoaded();
JSONArray baseArray = new JSONArray();
for (VersionHistoryEntry entry : versionHistoryEntries) {
baseArray.put(entry);
}
return baseArray;
} | [
"public",
"static",
"JSONArray",
"getBaseArray",
"(",
")",
"{",
"ensureLoaded",
"(",
")",
";",
"JSONArray",
"baseArray",
"=",
"new",
"JSONArray",
"(",
")",
";",
"for",
"(",
"VersionHistoryEntry",
"entry",
":",
"versionHistoryEntries",
")",
"{",
"baseArray",
".... | Don't use this directly. Used for debugging only.
@return the base JSONArray | [
"Don",
"t",
"use",
"this",
"directly",
".",
"Used",
"for",
"debugging",
"only",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/migration/v4_0_0/VersionHistoryStore.java#L173-L180 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.addCustomDeviceData | public static void addCustomDeviceData(final String key, final String value) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getDevice().getCustomData().put(key, trim(value));
return true;
}
}, "add custom device data");
} | java | public static void addCustomDeviceData(final String key, final String value) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getDevice().getCustomData().put(key, trim(value));
return true;
}
}, "add custom device data");
} | [
"public",
"static",
"void",
"addCustomDeviceData",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"value",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"execute",
"(",... | Add a custom data String to the Device. Custom data will be sent to the server, is displayed
in the Conversation view, and can be used in Interaction targeting. Calls to this method are
idempotent.
@param key The key to store the data under.
@param value A String value. | [
"Add",
"a",
"custom",
"data",
"String",
"to",
"the",
"Device",
".",
"Custom",
"data",
"will",
"be",
"sent",
"to",
"the",
"server",
"is",
"displayed",
"in",
"the",
"Conversation",
"view",
"and",
"can",
"be",
"used",
"in",
"Interaction",
"targeting",
".",
... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L234-L242 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.removeCustomDeviceData | public static void removeCustomDeviceData(final String key) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getDevice().getCustomData().remove(key);
return true;
}
}, "remove custom device data");
} | java | public static void removeCustomDeviceData(final String key) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getDevice().getCustomData().remove(key);
return true;
}
}, "remove custom device data");
} | [
"public",
"static",
"void",
"removeCustomDeviceData",
"(",
"final",
"String",
"key",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"execute",
"(",
"Conversation",
"conversation",
... | Remove a piece of custom data from the device. Calls to this method are idempotent.
@param key The key to remove. | [
"Remove",
"a",
"piece",
"of",
"custom",
"data",
"from",
"the",
"device",
".",
"Calls",
"to",
"this",
"method",
"are",
"idempotent",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L305-L313 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.addCustomPersonData | public static void addCustomPersonData(final String key, final String value) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getPerson().getCustomData().put(key, trim(value));
return true;
}
}, "add custom person data");
} | java | public static void addCustomPersonData(final String key, final String value) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getPerson().getCustomData().put(key, trim(value));
return true;
}
}, "add custom person data");
} | [
"public",
"static",
"void",
"addCustomPersonData",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"value",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"execute",
"(",... | Add a custom data String to the Person. Custom data will be sent to the server, is displayed
in the Conversation view, and can be used in Interaction targeting. Calls to this method are
idempotent.
@param key The key to store the data under.
@param value A String value. | [
"Add",
"a",
"custom",
"data",
"String",
"to",
"the",
"Person",
".",
"Custom",
"data",
"will",
"be",
"sent",
"to",
"the",
"server",
"is",
"displayed",
"in",
"the",
"Conversation",
"view",
"and",
"can",
"be",
"used",
"in",
"Interaction",
"targeting",
".",
... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L323-L331 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.removeCustomPersonData | public static void removeCustomPersonData(final String key) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getPerson().getCustomData().remove(key);
return true;
}
}, "remove custom person data");
} | java | public static void removeCustomPersonData(final String key) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getPerson().getCustomData().remove(key);
return true;
}
}, "remove custom person data");
} | [
"public",
"static",
"void",
"removeCustomPersonData",
"(",
"final",
"String",
"key",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"execute",
"(",
"Conversation",
"conversation",
... | Remove a piece of custom data from the Person. Calls to this method are idempotent.
@param key The key to remove. | [
"Remove",
"a",
"piece",
"of",
"custom",
"data",
"from",
"the",
"Person",
".",
"Calls",
"to",
"this",
"method",
"are",
"idempotent",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L394-L402 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.isApptentivePushNotification | public static boolean isApptentivePushNotification(Intent intent) {
try {
if (!ApptentiveInternal.checkRegistered()) {
return false;
}
return ApptentiveInternal.getApptentivePushNotificationData(intent) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification intent");
logException(e);
}
return false;
} | java | public static boolean isApptentivePushNotification(Intent intent) {
try {
if (!ApptentiveInternal.checkRegistered()) {
return false;
}
return ApptentiveInternal.getApptentivePushNotificationData(intent) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification intent");
logException(e);
}
return false;
} | [
"public",
"static",
"boolean",
"isApptentivePushNotification",
"(",
"Intent",
"intent",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"ApptentiveInternal",
".",
"checkRegistered",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"ApptentiveInternal",
".",
"g... | Determines whether this Intent is a push notification sent from Apptentive.
@param intent The received {@link Intent} you received in your BroadcastReceiver.
@return True if the Intent came from, and should be handled by Apptentive. | [
"Determines",
"whether",
"this",
"Intent",
"is",
"a",
"push",
"notification",
"sent",
"from",
"Apptentive",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L496-L507 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.isApptentivePushNotification | public static boolean isApptentivePushNotification(Bundle bundle) {
try {
if (!ApptentiveInternal.checkRegistered()) {
return false;
}
return ApptentiveInternal.getApptentivePushNotificationData(bundle) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification bundle");
logException(e);
}
return false;
} | java | public static boolean isApptentivePushNotification(Bundle bundle) {
try {
if (!ApptentiveInternal.checkRegistered()) {
return false;
}
return ApptentiveInternal.getApptentivePushNotificationData(bundle) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification bundle");
logException(e);
}
return false;
} | [
"public",
"static",
"boolean",
"isApptentivePushNotification",
"(",
"Bundle",
"bundle",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"ApptentiveInternal",
".",
"checkRegistered",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"ApptentiveInternal",
".",
"g... | Determines whether this Bundle came from an Apptentive push notification. This method is used with Urban Airship
integrations.
@param bundle The push payload bundle passed to GCM onMessageReceived() callback
@return True if the push came from, and should be handled by Apptentive. | [
"Determines",
"whether",
"this",
"Bundle",
"came",
"from",
"an",
"Apptentive",
"push",
"notification",
".",
"This",
"method",
"is",
"used",
"with",
"Urban",
"Airship",
"integrations",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L516-L527 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.isApptentivePushNotification | public static boolean isApptentivePushNotification(Map<String, String> data) {
try {
if (!ApptentiveInternal.checkRegistered()) {
return false;
}
return ApptentiveInternal.getApptentivePushNotificationData(data) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification data");
logException(e);
}
return false;
} | java | public static boolean isApptentivePushNotification(Map<String, String> data) {
try {
if (!ApptentiveInternal.checkRegistered()) {
return false;
}
return ApptentiveInternal.getApptentivePushNotificationData(data) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification data");
logException(e);
}
return false;
} | [
"public",
"static",
"boolean",
"isApptentivePushNotification",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"data",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"ApptentiveInternal",
".",
"checkRegistered",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"retu... | Determines whether push payload data came from an Apptentive push notification.
@param data The push payload data obtained through FCM's RemoteMessage.getData(), when using FCM
@return True if the push came from, and should be handled by Apptentive. | [
"Determines",
"whether",
"push",
"payload",
"data",
"came",
"from",
"an",
"Apptentive",
"push",
"notification",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L535-L546 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.setRatingProvider | public static void setRatingProvider(IRatingProvider ratingProvider) {
try {
if (ApptentiveInternal.isApptentiveRegistered()) {
ApptentiveInternal.getInstance().setRatingProvider(ratingProvider);
}
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while setting rating provider");
logException(e);
}
} | java | public static void setRatingProvider(IRatingProvider ratingProvider) {
try {
if (ApptentiveInternal.isApptentiveRegistered()) {
ApptentiveInternal.getInstance().setRatingProvider(ratingProvider);
}
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while setting rating provider");
logException(e);
}
} | [
"public",
"static",
"void",
"setRatingProvider",
"(",
"IRatingProvider",
"ratingProvider",
")",
"{",
"try",
"{",
"if",
"(",
"ApptentiveInternal",
".",
"isApptentiveRegistered",
"(",
")",
")",
"{",
"ApptentiveInternal",
".",
"getInstance",
"(",
")",
".",
"setRating... | Use this to choose where to send the user when they are prompted to rate the app. This should be the same place
that the app was downloaded from.
@param ratingProvider A {@link IRatingProvider} value. | [
"Use",
"this",
"to",
"choose",
"where",
"to",
"send",
"the",
"user",
"when",
"they",
"are",
"prompted",
"to",
"rate",
"the",
"app",
".",
"This",
"should",
"be",
"the",
"same",
"place",
"that",
"the",
"app",
"was",
"downloaded",
"from",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L857-L866 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.showMessageCenter | public static void showMessageCenter(final Context context, final BooleanCallback callback, final Map<String, Object> customData) {
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
return ApptentiveInternal.getInstance().showMessageCenterInternal(context, customData);
}
}, "show message center");
} | java | public static void showMessageCenter(final Context context, final BooleanCallback callback, final Map<String, Object> customData) {
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
return ApptentiveInternal.getInstance().showMessageCenterInternal(context, customData);
}
}, "show message center");
} | [
"public",
"static",
"void",
"showMessageCenter",
"(",
"final",
"Context",
"context",
",",
"final",
"BooleanCallback",
"callback",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"customData",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationD... | Opens the Apptentive Message Center UI Activity, and allows custom data to be sent with the
next message the user sends. If the user sends multiple messages, this data will only be sent
with the first message sent after this method is invoked. Additional invocations of this method
with custom data will repeat this process. If Message Center is closed without a message being
sent, the custom data is cleared. This task is performed asynchronously. Message Center
configuration may not have been downloaded yet when this is called.
@param context The context from which to launch the Message Center. This should be an
Activity, except in rare cases where you don't have access to one, in which
case Apptentive Message Center will launch in a new task.
@param callback Called after we check to see if Message Center can be displayed, but before
it is displayed. Called with true if an Interaction will be displayed, else
false.
@param customData A Map of String keys to Object values. Objects may be Strings, Numbers, or
Booleans. If any message is sent by the Person, this data is sent with it,
and then cleared. If no message is sent, this data is discarded. | [
"Opens",
"the",
"Apptentive",
"Message",
"Center",
"UI",
"Activity",
"and",
"allows",
"custom",
"data",
"to",
"be",
"sent",
"with",
"the",
"next",
"message",
"the",
"user",
"sends",
".",
"If",
"the",
"user",
"sends",
"multiple",
"messages",
"this",
"data",
... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L953-L960 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.canShowMessageCenter | public static void canShowMessageCenter(BooleanCallback callback) {
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
return ApptentiveInternal.canShowMessageCenterInternal(conversation);
}
}, "check message center availability");
} | java | public static void canShowMessageCenter(BooleanCallback callback) {
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
return ApptentiveInternal.canShowMessageCenterInternal(conversation);
}
}, "check message center availability");
} | [
"public",
"static",
"void",
"canShowMessageCenter",
"(",
"BooleanCallback",
"callback",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
"callback",
",",
"DispatchQueue",
".",
"mainQueue",
"(",
")",
")",
"{",
"@",
"Override",
"prote... | Our SDK must connect to our server at least once to download initial configuration for Message
Center. Call this method to see whether or not Message Center can be displayed. This task is
performed asynchronously.
@param callback Called after we check to see if Message Center can be displayed, but before it
is displayed. Called with true if an Interaction will be displayed, else false. | [
"Our",
"SDK",
"must",
"connect",
"to",
"our",
"server",
"at",
"least",
"once",
"to",
"download",
"initial",
"configuration",
"for",
"Message",
"Center",
".",
"Call",
"this",
"method",
"to",
"see",
"whether",
"or",
"not",
"Message",
"Center",
"can",
"be",
"... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L970-L977 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.addUnreadMessagesListener | public static void addUnreadMessagesListener(final UnreadMessagesListener listener) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getMessageManager().addHostUnreadMessagesListener(listener);
return true;
}
}, "add unread message listener");
} | java | public static void addUnreadMessagesListener(final UnreadMessagesListener listener) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
conversation.getMessageManager().addHostUnreadMessagesListener(listener);
return true;
}
}, "add unread message listener");
} | [
"public",
"static",
"void",
"addUnreadMessagesListener",
"(",
"final",
"UnreadMessagesListener",
"listener",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"execute",
"(",
"Conversati... | Add a listener to be notified when the number of unread messages in the Message Center changes.
@param listener An UnreadMessagesListener that you instantiate. Do not pass in an anonymous class.
Instead, create your listener as an instance variable and pass that in. This
allows us to keep a weak reference to avoid memory leaks. | [
"Add",
"a",
"listener",
"to",
"be",
"notified",
"when",
"the",
"number",
"of",
"unread",
"messages",
"in",
"the",
"Message",
"Center",
"changes",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L1007-L1015 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.getUnreadMessageCount | public static int getUnreadMessageCount() {
try {
if (ApptentiveInternal.isApptentiveRegistered()) {
ConversationProxy conversationProxy = ApptentiveInternal.getInstance().getConversationProxy();
return conversationProxy != null ? conversationProxy.getUnreadMessageCount() : 0;
}
} catch (Exception e) {
ApptentiveLog.e(MESSAGES, e, "Exception while getting unread message count");
logException(e);
}
return 0;
} | java | public static int getUnreadMessageCount() {
try {
if (ApptentiveInternal.isApptentiveRegistered()) {
ConversationProxy conversationProxy = ApptentiveInternal.getInstance().getConversationProxy();
return conversationProxy != null ? conversationProxy.getUnreadMessageCount() : 0;
}
} catch (Exception e) {
ApptentiveLog.e(MESSAGES, e, "Exception while getting unread message count");
logException(e);
}
return 0;
} | [
"public",
"static",
"int",
"getUnreadMessageCount",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"ApptentiveInternal",
".",
"isApptentiveRegistered",
"(",
")",
")",
"{",
"ConversationProxy",
"conversationProxy",
"=",
"ApptentiveInternal",
".",
"getInstance",
"(",
")",
".... | Returns the number of unread messages in the Message Center.
@return The number of unread messages. | [
"Returns",
"the",
"number",
"of",
"unread",
"messages",
"in",
"the",
"Message",
"Center",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L1022-L1033 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.sendAttachmentText | public static void sendAttachmentText(final String text) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
CompoundMessage message = new CompoundMessage();
message.setBody(text);
message.setRead(true);
message.setHidden(true);
message.setSenderId(conversation.getPerson().getId());
message.setAssociatedFiles(null);
conversation.getMessageManager().sendMessage(message);
return true;
}
}, "send attachment text");
} | java | public static void sendAttachmentText(final String text) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
protected boolean execute(Conversation conversation) {
CompoundMessage message = new CompoundMessage();
message.setBody(text);
message.setRead(true);
message.setHidden(true);
message.setSenderId(conversation.getPerson().getId());
message.setAssociatedFiles(null);
conversation.getMessageManager().sendMessage(message);
return true;
}
}, "send attachment text");
} | [
"public",
"static",
"void",
"sendAttachmentText",
"(",
"final",
"String",
"text",
")",
"{",
"dispatchConversationTask",
"(",
"new",
"ConversationDispatchTask",
"(",
")",
"{",
"@",
"Override",
"protected",
"boolean",
"execute",
"(",
"Conversation",
"conversation",
")... | Sends a text message to the server. This message will be visible in the conversation view on the server, but will
not be shown in the client's Message Center.
@param text The message you wish to send. | [
"Sends",
"a",
"text",
"message",
"to",
"the",
"server",
".",
"This",
"message",
"will",
"be",
"visible",
"in",
"the",
"conversation",
"view",
"on",
"the",
"server",
"but",
"will",
"not",
"be",
"shown",
"in",
"the",
"client",
"s",
"Message",
"Center",
"."... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L1041-L1055 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.engage | public static synchronized void engage(Context context, String event, BooleanCallback callback) {
engage(context, event, callback, null, (ExtendedData[]) null);
} | java | public static synchronized void engage(Context context, String event, BooleanCallback callback) {
engage(context, event, callback, null, (ExtendedData[]) null);
} | [
"public",
"static",
"synchronized",
"void",
"engage",
"(",
"Context",
"context",
",",
"String",
"event",
",",
"BooleanCallback",
"callback",
")",
"{",
"engage",
"(",
"context",
",",
"event",
",",
"callback",
",",
"null",
",",
"(",
"ExtendedData",
"[",
"]",
... | This method takes a unique event string, stores a record of that event having been visited,
determines if there is an interaction that is able to run for this event, and then runs it. If
more than one interaction can run, then the most appropriate interaction takes precedence. Only
one interaction at most will run per invocation of this method. This task is performed
asynchronously.
@param context The context from which to launch the Interaction. This should be an Activity,
except in rare cases where you don't have access to one, in which case
Apptentive Interactions will launch in a new task.
@param event A unique String representing the line this method is called on. For instance,
you may want to have the ability to target interactions to run after the user
uploads a file in your app. You may then call
<strong><code>engage(context, "finished_upload");</code></strong>
@param callback Called after we check to see if an Interaction should be displayed. Called with
true if an Interaction will be displayed, else false. | [
"This",
"method",
"takes",
"a",
"unique",
"event",
"string",
"stores",
"a",
"record",
"of",
"that",
"event",
"having",
"been",
"visited",
"determines",
"if",
"there",
"is",
"an",
"interaction",
"that",
"is",
"able",
"to",
"run",
"for",
"this",
"event",
"an... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L1223-L1225 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.engage | public static synchronized void engage(final Context context, final String event, final BooleanCallback callback, final Map<String, Object> customData, final ExtendedData... extendedData) {
if (context == null) {
throw new IllegalArgumentException("Context is null");
}
if (StringUtils.isNullOrEmpty(event)) {
throw new IllegalArgumentException("Event is null or empty");
}
// first, we check if there's an engagement callback to inject
final OnPreInteractionListener preInteractionListener = Apptentive.preInteractionListener; // capture variable to avoid concurrency issues
if (preInteractionListener != null) {
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
if (!canShowLocalAppInteraction(conversation, event)) {
return false;
}
boolean allowsInteraction = preInteractionListener.shouldEngageInteraction(event, customData);
ApptentiveLog.i("Engagement callback allows interaction for event '%s': %b", event, allowsInteraction);
if (!allowsInteraction) {
return false;
}
return engageLocalAppEvent(context, conversation, event, customData, extendedData); // actually engage event
}
}, StringUtils.format("engage '%s' event", event));
return;
}
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
return engageLocalAppEvent(context, conversation, event, customData, extendedData);
}
}, StringUtils.format("engage '%s' event", event));
} | java | public static synchronized void engage(final Context context, final String event, final BooleanCallback callback, final Map<String, Object> customData, final ExtendedData... extendedData) {
if (context == null) {
throw new IllegalArgumentException("Context is null");
}
if (StringUtils.isNullOrEmpty(event)) {
throw new IllegalArgumentException("Event is null or empty");
}
// first, we check if there's an engagement callback to inject
final OnPreInteractionListener preInteractionListener = Apptentive.preInteractionListener; // capture variable to avoid concurrency issues
if (preInteractionListener != null) {
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
if (!canShowLocalAppInteraction(conversation, event)) {
return false;
}
boolean allowsInteraction = preInteractionListener.shouldEngageInteraction(event, customData);
ApptentiveLog.i("Engagement callback allows interaction for event '%s': %b", event, allowsInteraction);
if (!allowsInteraction) {
return false;
}
return engageLocalAppEvent(context, conversation, event, customData, extendedData); // actually engage event
}
}, StringUtils.format("engage '%s' event", event));
return;
}
dispatchConversationTask(new ConversationDispatchTask(callback, DispatchQueue.mainQueue()) {
@Override
protected boolean execute(Conversation conversation) {
return engageLocalAppEvent(context, conversation, event, customData, extendedData);
}
}, StringUtils.format("engage '%s' event", event));
} | [
"public",
"static",
"synchronized",
"void",
"engage",
"(",
"final",
"Context",
"context",
",",
"final",
"String",
"event",
",",
"final",
"BooleanCallback",
"callback",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"customData",
",",
"final",
"Extende... | This method takes a unique event string, stores a record of that event having been visited,
determines if there is an interaction that is able to run for this event, and then runs it. If
more than one interaction can run, then the most appropriate interaction takes precedence. Only
one interaction at most will run per invocation of this method.
@param context The context from which to launch the Interaction. This should be an
Activity, except in rare cases where you don't have access to one, in which
case Apptentive Interactions will launch in a new task.
@param event A unique String representing the line this method is called on.
For instance, you may want to have the ability to target interactions to
run after the user uploads a file in your app. You may then call
<strong><code>engage(context, "finished_upload");</code></strong>
@param callback Called after we check to see if an Interaction should be displayed. Called with
true if an Interaction will be displayed, else false.
@param customData A Map of String keys to Object values. Objects may be Strings, Numbers, or
Booleans. This data is sent to the server for tracking information in the
context of the engaged Event.
@param extendedData An array of ExtendedData objects. ExtendedData objects used to send
structured data that has specific meaning to the server. By using an
{@link ExtendedData} object instead of arbitrary customData, special
meaning can be derived. Supported objects include {@link TimeExtendedData},
{@link LocationExtendedData}, and {@link CommerceExtendedData}. Include
each type only once. | [
"This",
"method",
"takes",
"a",
"unique",
"event",
"string",
"stores",
"a",
"record",
"of",
"that",
"event",
"having",
"been",
"visited",
"determines",
"if",
"there",
"is",
"an",
"interaction",
"that",
"is",
"able",
"to",
"run",
"for",
"this",
"event",
"an... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L1329-L1366 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java | Apptentive.login | public static void login(final String token, final LoginCallback callback) {
if (StringUtils.isNullOrEmpty(token)) {
throw new IllegalArgumentException("Token is null or empty");
}
dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
try {
loginGuarded(token, callback);
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while trying to login");
logException(e);
notifyFailure(callback, "Exception while trying to login");
}
}
});
} | java | public static void login(final String token, final LoginCallback callback) {
if (StringUtils.isNullOrEmpty(token)) {
throw new IllegalArgumentException("Token is null or empty");
}
dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
try {
loginGuarded(token, callback);
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while trying to login");
logException(e);
notifyFailure(callback, "Exception while trying to login");
}
}
});
} | [
"public",
"static",
"void",
"login",
"(",
"final",
"String",
"token",
",",
"final",
"LoginCallback",
"callback",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNullOrEmpty",
"(",
"token",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Token is... | Starts login process asynchronously. This call returns immediately. Using this method requires
you to implement JWT generation on your server. Please read about it in Apptentive's Android
Integration Reference Guide.
@param token A JWT signed by your server using the secret from your app's Apptentive settings.
@param callback A LoginCallback, which will be called asynchronously when the login succeeds
or fails. | [
"Starts",
"login",
"process",
"asynchronously",
".",
"This",
"call",
"returns",
"immediately",
".",
"Using",
"this",
"method",
"requires",
"you",
"to",
"implement",
"JWT",
"generation",
"on",
"your",
"server",
".",
"Please",
"read",
"about",
"it",
"in",
"Appte... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/Apptentive.java#L1434-L1452 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/StringUtils.java | StringUtils.join | public static <T> String join(List<T> list, String separator) {
StringBuilder builder = new StringBuilder();
int i = 0;
for (T t : list) {
builder.append(t);
if (++i < list.size()) builder.append(separator);
}
return builder.toString();
} | java | public static <T> String join(List<T> list, String separator) {
StringBuilder builder = new StringBuilder();
int i = 0;
for (T t : list) {
builder.append(t);
if (++i < list.size()) builder.append(separator);
}
return builder.toString();
} | [
"public",
"static",
"<",
"T",
">",
"String",
"join",
"(",
"List",
"<",
"T",
">",
"list",
",",
"String",
"separator",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"T",
"t",
... | Constructs and returns a string object that is the result of interposing a separator between the elements of the list | [
"Constructs",
"and",
"returns",
"a",
"string",
"object",
"that",
"is",
"the",
"result",
"of",
"interposing",
"a",
"separator",
"between",
"the",
"elements",
"of",
"the",
"list"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/StringUtils.java#L125-L133 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/StringUtils.java | StringUtils.trim | public static String trim(String str) {
return str != null && str.length() > 0 ? str.trim() : str;
} | java | public static String trim(String str) {
return str != null && str.length() > 0 ? str.trim() : str;
} | [
"public",
"static",
"String",
"trim",
"(",
"String",
"str",
")",
"{",
"return",
"str",
"!=",
"null",
"&&",
"str",
".",
"length",
"(",
")",
">",
"0",
"?",
"str",
".",
"trim",
"(",
")",
":",
"str",
";",
"}"
] | Safely trims input string | [
"Safely",
"trims",
"input",
"string"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/StringUtils.java#L145-L147 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/StringUtils.java | StringUtils.asJson | public static String asJson(String key, Object value) {
try {
JSONObject json = new JSONObject();
json.put(key, value);
return json.toString();
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while creating json-string { %s:%s }", key, value);
return null;
}
} | java | public static String asJson(String key, Object value) {
try {
JSONObject json = new JSONObject();
json.put(key, value);
return json.toString();
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while creating json-string { %s:%s }", key, value);
return null;
}
} | [
"public",
"static",
"String",
"asJson",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"try",
"{",
"JSONObject",
"json",
"=",
"new",
"JSONObject",
"(",
")",
";",
"json",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"json",
".",
... | Creates a simple json string from key and value | [
"Creates",
"a",
"simple",
"json",
"string",
"from",
"key",
"and",
"value"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/StringUtils.java#L159-L168 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/StringUtils.java | StringUtils.hexToBytes | public static byte[] hexToBytes(String hex) {
int length = hex.length();
byte[] ret = new byte[length / 2];
for (int i = 0; i < length; i += 2) {
ret[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4) + Character.digit(hex.charAt(i + 1), 16));
}
return ret;
} | java | public static byte[] hexToBytes(String hex) {
int length = hex.length();
byte[] ret = new byte[length / 2];
for (int i = 0; i < length; i += 2) {
ret[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4) + Character.digit(hex.charAt(i + 1), 16));
}
return ret;
} | [
"public",
"static",
"byte",
"[",
"]",
"hexToBytes",
"(",
"String",
"hex",
")",
"{",
"int",
"length",
"=",
"hex",
".",
"length",
"(",
")",
";",
"byte",
"[",
"]",
"ret",
"=",
"new",
"byte",
"[",
"length",
"/",
"2",
"]",
";",
"for",
"(",
"int",
"i... | Converts a hex String to a byte array. | [
"Converts",
"a",
"hex",
"String",
"to",
"a",
"byte",
"array",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/StringUtils.java#L173-L180 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestManager.java | HttpRequestManager.dispatchRequest | void dispatchRequest(final HttpRequest request) {
networkQueue.dispatchAsync(new DispatchTask() {
@Override
protected void execute() {
request.dispatchSync(networkQueue);
}
});
} | java | void dispatchRequest(final HttpRequest request) {
networkQueue.dispatchAsync(new DispatchTask() {
@Override
protected void execute() {
request.dispatchSync(networkQueue);
}
});
} | [
"void",
"dispatchRequest",
"(",
"final",
"HttpRequest",
"request",
")",
"{",
"networkQueue",
".",
"dispatchAsync",
"(",
"new",
"DispatchTask",
"(",
")",
"{",
"@",
"Override",
"protected",
"void",
"execute",
"(",
")",
"{",
"request",
".",
"dispatchSync",
"(",
... | Handles request synchronously | [
"Handles",
"request",
"synchronously"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestManager.java#L68-L75 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestManager.java | HttpRequestManager.cancelAll | public synchronized void cancelAll() {
if (activeRequests.size() > 0) {
List<HttpRequest> temp = new ArrayList<>(activeRequests);
for (HttpRequest request : temp) {
request.cancel();
}
}
notifyCancelledAllRequests();
} | java | public synchronized void cancelAll() {
if (activeRequests.size() > 0) {
List<HttpRequest> temp = new ArrayList<>(activeRequests);
for (HttpRequest request : temp) {
request.cancel();
}
}
notifyCancelledAllRequests();
} | [
"public",
"synchronized",
"void",
"cancelAll",
"(",
")",
"{",
"if",
"(",
"activeRequests",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"List",
"<",
"HttpRequest",
">",
"temp",
"=",
"new",
"ArrayList",
"<>",
"(",
"activeRequests",
")",
";",
"for",
"(",
... | Cancel all active requests | [
"Cancel",
"all",
"active",
"requests"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestManager.java#L80-L88 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestManager.java | HttpRequestManager.unregisterRequest | synchronized void unregisterRequest(HttpRequest request) {
assertTrue(this == request.requestManager);
boolean removed = activeRequests.remove(request);
assertTrue(removed, "Attempted to unregister missing request: %s", request);
if (removed) {
notifyRequestFinished(request);
}
} | java | synchronized void unregisterRequest(HttpRequest request) {
assertTrue(this == request.requestManager);
boolean removed = activeRequests.remove(request);
assertTrue(removed, "Attempted to unregister missing request: %s", request);
if (removed) {
notifyRequestFinished(request);
}
} | [
"synchronized",
"void",
"unregisterRequest",
"(",
"HttpRequest",
"request",
")",
"{",
"assertTrue",
"(",
"this",
"==",
"request",
".",
"requestManager",
")",
";",
"boolean",
"removed",
"=",
"activeRequests",
".",
"remove",
"(",
"request",
")",
";",
"assertTrue",... | Unregisters active request | [
"Unregisters",
"active",
"request"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/network/HttpRequestManager.java#L101-L109 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/comm/ApptentiveHttpClient.java | ApptentiveHttpClient.createConversationTokenRequest | public HttpJsonRequest createConversationTokenRequest(ConversationTokenRequest conversationTokenRequest, HttpRequest.Listener<HttpJsonRequest> listener) {
HttpJsonRequest request = createJsonRequest(ENDPOINT_CONVERSATION, conversationTokenRequest, HttpRequestMethod.POST);
request.addListener(listener);
return request;
} | java | public HttpJsonRequest createConversationTokenRequest(ConversationTokenRequest conversationTokenRequest, HttpRequest.Listener<HttpJsonRequest> listener) {
HttpJsonRequest request = createJsonRequest(ENDPOINT_CONVERSATION, conversationTokenRequest, HttpRequestMethod.POST);
request.addListener(listener);
return request;
} | [
"public",
"HttpJsonRequest",
"createConversationTokenRequest",
"(",
"ConversationTokenRequest",
"conversationTokenRequest",
",",
"HttpRequest",
".",
"Listener",
"<",
"HttpJsonRequest",
">",
"listener",
")",
"{",
"HttpJsonRequest",
"request",
"=",
"createJsonRequest",
"(",
"... | region API Requests | [
"region",
"API",
"Requests"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/comm/ApptentiveHttpClient.java#L76-L80 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/SurveyFragment.java | SurveyFragment.validateAndUpdateState | public boolean validateAndUpdateState() {
boolean validationPassed = true;
List<Fragment> fragments = getRetainedChildFragmentManager().getFragments();
for (Fragment fragment : fragments) {
SurveyQuestionView surveyQuestionView = (SurveyQuestionView) fragment;
answers.put(surveyQuestionView.getQuestionId(), surveyQuestionView.getAnswer());
boolean isValid = surveyQuestionView.isValid();
surveyQuestionView.updateValidationState(isValid);
if (!isValid) {
validationPassed = false;
}
}
return validationPassed;
} | java | public boolean validateAndUpdateState() {
boolean validationPassed = true;
List<Fragment> fragments = getRetainedChildFragmentManager().getFragments();
for (Fragment fragment : fragments) {
SurveyQuestionView surveyQuestionView = (SurveyQuestionView) fragment;
answers.put(surveyQuestionView.getQuestionId(), surveyQuestionView.getAnswer());
boolean isValid = surveyQuestionView.isValid();
surveyQuestionView.updateValidationState(isValid);
if (!isValid) {
validationPassed = false;
}
}
return validationPassed;
} | [
"public",
"boolean",
"validateAndUpdateState",
"(",
")",
"{",
"boolean",
"validationPassed",
"=",
"true",
";",
"List",
"<",
"Fragment",
">",
"fragments",
"=",
"getRetainedChildFragmentManager",
"(",
")",
".",
"getFragments",
"(",
")",
";",
"for",
"(",
"Fragment"... | Run this when the user hits the send button, and only send if it returns true. This method will update the visual validation state of all questions, and update the answers instance variable with the latest answer state.
@return true if all questions that have constraints have met those constraints. | [
"Run",
"this",
"when",
"the",
"user",
"hits",
"the",
"send",
"button",
"and",
"only",
"send",
"if",
"it",
"returns",
"true",
".",
"This",
"method",
"will",
"update",
"the",
"visual",
"validation",
"state",
"of",
"all",
"questions",
"and",
"update",
"the",
... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/SurveyFragment.java#L280-L294 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveViewActivity.java | ApptentiveViewActivity.exitActivity | private void exitActivity(ApptentiveViewExitType exitType) {
try {
exitActivityGuarded(exitType);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while trying to exit activity (type=%s)", exitType);
logException(e);
}
} | java | private void exitActivity(ApptentiveViewExitType exitType) {
try {
exitActivityGuarded(exitType);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while trying to exit activity (type=%s)", exitType);
logException(e);
}
} | [
"private",
"void",
"exitActivity",
"(",
"ApptentiveViewExitType",
"exitType",
")",
"{",
"try",
"{",
"exitActivityGuarded",
"(",
"exitType",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"ApptentiveLog",
".",
"e",
"(",
"e",
",",
"\"Exception while tr... | Helper to clean up the Activity, whether it is exited through the toolbar back button, or the hardware back button. | [
"Helper",
"to",
"clean",
"up",
"the",
"Activity",
"whether",
"it",
"is",
"exited",
"through",
"the",
"toolbar",
"back",
"button",
"or",
"the",
"hardware",
"back",
"button",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/ApptentiveViewActivity.java#L255-L262 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitor.java | LogMonitor.startSession | public static void startSession(final Context context, final String appKey, final String appSignature) {
dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
try {
startSessionGuarded(context, appKey, appSignature);
} catch (Exception e) {
ApptentiveLog.e(TROUBLESHOOT, e, "Unable to start Apptentive Log Monitor");
logException(e);
}
}
});
} | java | public static void startSession(final Context context, final String appKey, final String appSignature) {
dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
try {
startSessionGuarded(context, appKey, appSignature);
} catch (Exception e) {
ApptentiveLog.e(TROUBLESHOOT, e, "Unable to start Apptentive Log Monitor");
logException(e);
}
}
});
} | [
"public",
"static",
"void",
"startSession",
"(",
"final",
"Context",
"context",
",",
"final",
"String",
"appKey",
",",
"final",
"String",
"appSignature",
")",
"{",
"dispatchOnConversationQueue",
"(",
"new",
"DispatchTask",
"(",
")",
"{",
"@",
"Override",
"protec... | Attempts to start a new troubleshooting session. First the SDK will check if there is
an existing session stored in the persistent storage and then check if the clipboard
contains a valid access token.
This call is async and returns immediately. | [
"Attempts",
"to",
"start",
"a",
"new",
"troubleshooting",
"session",
".",
"First",
"the",
"SDK",
"will",
"check",
"if",
"there",
"is",
"an",
"existing",
"session",
"stored",
"in",
"the",
"persistent",
"storage",
"and",
"then",
"check",
"if",
"the",
"clipboar... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitor.java#L61-L73 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitor.java | LogMonitor.readAccessTokenFromClipboard | private static @Nullable String readAccessTokenFromClipboard(Context context) {
String text = Util.getClipboardText(context);
if (StringUtils.isNullOrEmpty(text)) {
return null;
}
//Since the token string should never contain spaces, attempt to repair line breaks introduced in the copying process.
text = text.replaceAll("\\s+", "");
if (!text.startsWith(DEBUG_TEXT_HEADER)) {
return null;
}
// Remove the header
return text.substring(DEBUG_TEXT_HEADER.length());
} | java | private static @Nullable String readAccessTokenFromClipboard(Context context) {
String text = Util.getClipboardText(context);
if (StringUtils.isNullOrEmpty(text)) {
return null;
}
//Since the token string should never contain spaces, attempt to repair line breaks introduced in the copying process.
text = text.replaceAll("\\s+", "");
if (!text.startsWith(DEBUG_TEXT_HEADER)) {
return null;
}
// Remove the header
return text.substring(DEBUG_TEXT_HEADER.length());
} | [
"private",
"static",
"@",
"Nullable",
"String",
"readAccessTokenFromClipboard",
"(",
"Context",
"context",
")",
"{",
"String",
"text",
"=",
"Util",
".",
"getClipboardText",
"(",
"context",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNullOrEmpty",
"(",
"text",
... | Attempts to read access token from the clipboard | [
"Attempts",
"to",
"read",
"access",
"token",
"from",
"the",
"clipboard"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitor.java#L173-L189 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitor.java | LogMonitor.createTokenVerificationRequest | private static HttpRequest createTokenVerificationRequest(String apptentiveAppKey, String apptentiveAppSignature, String token, HttpRequest.Listener<HttpJsonRequest> listener) {
// TODO: move this logic to ApptentiveHttpClient
String URL = Constants.CONFIG_DEFAULT_SERVER_URL + "/debug_token/verify";
HttpRequest request = new HttpJsonRequest(URL, createVerityRequestObject(token));
request.setTag(TAG_VERIFICATION_REQUEST);
request.setMethod(HttpRequestMethod.POST);
request.setRequestManager(HttpRequestManager.sharedManager());
request.setRequestProperty("X-API-Version", Constants.API_VERSION);
request.setRequestProperty("APPTENTIVE-KEY", apptentiveAppKey);
request.setRequestProperty("APPTENTIVE-SIGNATURE", apptentiveAppSignature);
request.setRequestProperty("Content-Type", "application/json");
request.setRequestProperty("Accept", "application/json");
request.setRequestProperty("User-Agent", String.format(USER_AGENT_STRING, Constants.getApptentiveSdkVersion()));
request.setRetryPolicy(createVerityRequestRetryPolicy());
request.addListener(listener);
return request;
} | java | private static HttpRequest createTokenVerificationRequest(String apptentiveAppKey, String apptentiveAppSignature, String token, HttpRequest.Listener<HttpJsonRequest> listener) {
// TODO: move this logic to ApptentiveHttpClient
String URL = Constants.CONFIG_DEFAULT_SERVER_URL + "/debug_token/verify";
HttpRequest request = new HttpJsonRequest(URL, createVerityRequestObject(token));
request.setTag(TAG_VERIFICATION_REQUEST);
request.setMethod(HttpRequestMethod.POST);
request.setRequestManager(HttpRequestManager.sharedManager());
request.setRequestProperty("X-API-Version", Constants.API_VERSION);
request.setRequestProperty("APPTENTIVE-KEY", apptentiveAppKey);
request.setRequestProperty("APPTENTIVE-SIGNATURE", apptentiveAppSignature);
request.setRequestProperty("Content-Type", "application/json");
request.setRequestProperty("Accept", "application/json");
request.setRequestProperty("User-Agent", String.format(USER_AGENT_STRING, Constants.getApptentiveSdkVersion()));
request.setRetryPolicy(createVerityRequestRetryPolicy());
request.addListener(listener);
return request;
} | [
"private",
"static",
"HttpRequest",
"createTokenVerificationRequest",
"(",
"String",
"apptentiveAppKey",
",",
"String",
"apptentiveAppSignature",
",",
"String",
"token",
",",
"HttpRequest",
".",
"Listener",
"<",
"HttpJsonRequest",
">",
"listener",
")",
"{",
"// TODO: mo... | region Token Verification | [
"region",
"Token",
"Verification"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/debug/LogMonitor.java#L195-L211 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java | ImageGridViewAdapter.clickOn | public boolean clickOn(int index) {
ImageItem item = getItem(index);
if (item == null || TextUtils.isEmpty(item.mimeType)) {
return false;
}
// For non-image items, the first tap will start it downloading
if (!Util.isMimeTypeImage(item.mimeType)) {
// It is being downloaded, do nothing (prevent double tap, etc)
if (downloadItems.contains(item.originalPath)) {
return true;
} else {
// If no write permission, do not try to download. Instead let caller handles it by launching browser
if (!bHasWritePermission) {
return false;
}
File localFile = new File(item.localCachePath);
if (localFile.exists() && ApptentiveAttachmentLoader.getInstance().isFileCompletelyDownloaded(item.localCachePath)) {
// If have right permission, and already downloaded, let caller open 3rd app to view it
return false;
} else {
// First tap detected and never download before, start download
downloadItems.add(item.originalPath);
notifyDataSetChanged();
return true;
}
}
}
return false;
} | java | public boolean clickOn(int index) {
ImageItem item = getItem(index);
if (item == null || TextUtils.isEmpty(item.mimeType)) {
return false;
}
// For non-image items, the first tap will start it downloading
if (!Util.isMimeTypeImage(item.mimeType)) {
// It is being downloaded, do nothing (prevent double tap, etc)
if (downloadItems.contains(item.originalPath)) {
return true;
} else {
// If no write permission, do not try to download. Instead let caller handles it by launching browser
if (!bHasWritePermission) {
return false;
}
File localFile = new File(item.localCachePath);
if (localFile.exists() && ApptentiveAttachmentLoader.getInstance().isFileCompletelyDownloaded(item.localCachePath)) {
// If have right permission, and already downloaded, let caller open 3rd app to view it
return false;
} else {
// First tap detected and never download before, start download
downloadItems.add(item.originalPath);
notifyDataSetChanged();
return true;
}
}
}
return false;
} | [
"public",
"boolean",
"clickOn",
"(",
"int",
"index",
")",
"{",
"ImageItem",
"item",
"=",
"getItem",
"(",
"index",
")",
";",
"if",
"(",
"item",
"==",
"null",
"||",
"TextUtils",
".",
"isEmpty",
"(",
"item",
".",
"mimeType",
")",
")",
"{",
"return",
"fa... | Click an image
@param index
@return True if handled here; False, let the caller handle it, i.e. launch 3rd party app to open attachment | [
"Click",
"an",
"image"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java#L123-L151 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java | ImageGridViewAdapter.select | public void select(ImageItem image) {
if (selectedImages.contains(image)) {
selectedImages.remove(image);
} else {
selectedImages.add(image);
}
notifyDataSetChanged();
} | java | public void select(ImageItem image) {
if (selectedImages.contains(image)) {
selectedImages.remove(image);
} else {
selectedImages.add(image);
}
notifyDataSetChanged();
} | [
"public",
"void",
"select",
"(",
"ImageItem",
"image",
")",
"{",
"if",
"(",
"selectedImages",
".",
"contains",
"(",
"image",
")",
")",
"{",
"selectedImages",
".",
"remove",
"(",
"image",
")",
";",
"}",
"else",
"{",
"selectedImages",
".",
"add",
"(",
"i... | Select an image
@param image | [
"Select",
"an",
"image"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java#L158-L165 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java | ImageGridViewAdapter.setDefaultSelected | public void setDefaultSelected(ArrayList<String> resultList) {
for (String uri : resultList) {
ImageItem image = getImageByUri(uri);
if (image != null) {
selectedImages.add(image);
}
}
if (selectedImages.size() > 0) {
notifyDataSetChanged();
}
} | java | public void setDefaultSelected(ArrayList<String> resultList) {
for (String uri : resultList) {
ImageItem image = getImageByUri(uri);
if (image != null) {
selectedImages.add(image);
}
}
if (selectedImages.size() > 0) {
notifyDataSetChanged();
}
} | [
"public",
"void",
"setDefaultSelected",
"(",
"ArrayList",
"<",
"String",
">",
"resultList",
")",
"{",
"for",
"(",
"String",
"uri",
":",
"resultList",
")",
"{",
"ImageItem",
"image",
"=",
"getImageByUri",
"(",
"uri",
")",
";",
"if",
"(",
"image",
"!=",
"n... | Re-Select image from selected list result
@param resultList | [
"Re",
"-",
"Select",
"image",
"from",
"selected",
"list",
"result"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java#L172-L182 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java | ImageGridViewAdapter.setData | public void setData(List<ImageItem> images) {
selectedImages.clear();
if (images != null && images.size() > 0) {
this.images = images;
} else {
this.images.clear();
}
notifyDataSetChanged();
} | java | public void setData(List<ImageItem> images) {
selectedImages.clear();
if (images != null && images.size() > 0) {
this.images = images;
} else {
this.images.clear();
}
notifyDataSetChanged();
} | [
"public",
"void",
"setData",
"(",
"List",
"<",
"ImageItem",
">",
"images",
")",
"{",
"selectedImages",
".",
"clear",
"(",
")",
";",
"if",
"(",
"images",
"!=",
"null",
"&&",
"images",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"this",
".",
"images",... | Re-select image from selected image set
@param images | [
"Re",
"-",
"select",
"image",
"from",
"selected",
"image",
"set"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java#L200-L209 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java | ImageGridViewAdapter.setItemSize | public void setItemSize(int columnWidth, int columnHeight) {
if (itemWidth == columnWidth) {
return;
}
itemWidth = columnWidth;
itemHeight = columnHeight;
itemLayoutParams = new GridView.LayoutParams(itemWidth, itemHeight);
notifyDataSetChanged();
} | java | public void setItemSize(int columnWidth, int columnHeight) {
if (itemWidth == columnWidth) {
return;
}
itemWidth = columnWidth;
itemHeight = columnHeight;
itemLayoutParams = new GridView.LayoutParams(itemWidth, itemHeight);
notifyDataSetChanged();
} | [
"public",
"void",
"setItemSize",
"(",
"int",
"columnWidth",
",",
"int",
"columnHeight",
")",
"{",
"if",
"(",
"itemWidth",
"==",
"columnWidth",
")",
"{",
"return",
";",
"}",
"itemWidth",
"=",
"columnWidth",
";",
"itemHeight",
"=",
"columnHeight",
";",
"itemLa... | Reset colum size
@param columnWidth | [
"Reset",
"colum",
"size"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/image/ImageGridViewAdapter.java#L216-L228 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/module/metric/MetricModule.java | MetricModule.sendError | public static void sendError(final Throwable throwable, final String description, final String extraData) {
if (!isConversationQueue()) {
dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
sendError(throwable, description, extraData);
}
});
return;
}
EventPayload.EventLabel type = EventPayload.EventLabel.error;
try {
JSONObject data = new JSONObject();
data.put("thread", Thread.currentThread().getName());
if (throwable != null) {
JSONObject exception = new JSONObject();
exception.put("message", throwable.getMessage());
exception.put("stackTrace", Util.stackTraceAsString(throwable));
data.put(KEY_EXCEPTION, exception);
}
if (description != null) {
data.put("description", description);
}
if (extraData != null) {
data.put("extraData", extraData);
}
Configuration config = Configuration.load();
if (config.isMetricsEnabled()) {
ApptentiveLog.v(UTIL, "Sending Error Metric: %s, data: %s", type.getLabelName(), data.toString());
EventPayload event = new EventPayload(type.getLabelName(), data);
sendEvent(event);
}
} catch (Exception e) {
// Since this is the last place in Apptentive code we can catch exceptions, we must catch all other Exceptions to
// prevent the app from crashing.
ApptentiveLog.w(UTIL, e, "Error creating Error Metric. Nothing we can do but log this.");
}
} | java | public static void sendError(final Throwable throwable, final String description, final String extraData) {
if (!isConversationQueue()) {
dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
sendError(throwable, description, extraData);
}
});
return;
}
EventPayload.EventLabel type = EventPayload.EventLabel.error;
try {
JSONObject data = new JSONObject();
data.put("thread", Thread.currentThread().getName());
if (throwable != null) {
JSONObject exception = new JSONObject();
exception.put("message", throwable.getMessage());
exception.put("stackTrace", Util.stackTraceAsString(throwable));
data.put(KEY_EXCEPTION, exception);
}
if (description != null) {
data.put("description", description);
}
if (extraData != null) {
data.put("extraData", extraData);
}
Configuration config = Configuration.load();
if (config.isMetricsEnabled()) {
ApptentiveLog.v(UTIL, "Sending Error Metric: %s, data: %s", type.getLabelName(), data.toString());
EventPayload event = new EventPayload(type.getLabelName(), data);
sendEvent(event);
}
} catch (Exception e) {
// Since this is the last place in Apptentive code we can catch exceptions, we must catch all other Exceptions to
// prevent the app from crashing.
ApptentiveLog.w(UTIL, e, "Error creating Error Metric. Nothing we can do but log this.");
}
} | [
"public",
"static",
"void",
"sendError",
"(",
"final",
"Throwable",
"throwable",
",",
"final",
"String",
"description",
",",
"final",
"String",
"extraData",
")",
"{",
"if",
"(",
"!",
"isConversationQueue",
"(",
")",
")",
"{",
"dispatchOnConversationQueue",
"(",
... | Used for internal error reporting when we intercept a Throwable that may have otherwise caused a crash.
@param throwable An optional throwable that was caught, and which we want to log.
@param description An optional description of what happened.
@param extraData Any extra data that may have contributed to the Throwable being thrown. | [
"Used",
"for",
"internal",
"error",
"reporting",
"when",
"we",
"intercept",
"a",
"Throwable",
"that",
"may",
"have",
"otherwise",
"caused",
"a",
"crash",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/module/metric/MetricModule.java#L68-L106 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.parseWebColorAsAndroidColor | public static Integer parseWebColorAsAndroidColor(String input) {
// Swap if input is #RRGGBBAA, but not if it is #RRGGBB
Boolean swapAlpha = (input.length() == 9);
try {
Integer ret = Color.parseColor(input);
if (swapAlpha) {
ret = (ret >>> 8) | ((ret & 0x000000FF) << 24);
}
return ret;
} catch (IllegalArgumentException e) {
logException(e);
}
return null;
} | java | public static Integer parseWebColorAsAndroidColor(String input) {
// Swap if input is #RRGGBBAA, but not if it is #RRGGBB
Boolean swapAlpha = (input.length() == 9);
try {
Integer ret = Color.parseColor(input);
if (swapAlpha) {
ret = (ret >>> 8) | ((ret & 0x000000FF) << 24);
}
return ret;
} catch (IllegalArgumentException e) {
logException(e);
}
return null;
} | [
"public",
"static",
"Integer",
"parseWebColorAsAndroidColor",
"(",
"String",
"input",
")",
"{",
"// Swap if input is #RRGGBBAA, but not if it is #RRGGBB",
"Boolean",
"swapAlpha",
"=",
"(",
"input",
".",
"length",
"(",
")",
"==",
"9",
")",
";",
"try",
"{",
"Integer",... | The web standard for colors is RGBA, but Android uses ARGB. This method provides a way to convert RGBA to ARGB. | [
"The",
"web",
"standard",
"for",
"colors",
"is",
"RGBA",
"but",
"Android",
"uses",
"ARGB",
".",
"This",
"method",
"provides",
"a",
"way",
"to",
"convert",
"RGBA",
"to",
"ARGB",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L340-L353 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.getCompatDrawable | public static Drawable getCompatDrawable(Context c, int drawableRes) {
Drawable d = null;
try {
d = ContextCompat.getDrawable(c, drawableRes);
} catch (Exception ex) {
logException(ex);
}
return d;
} | java | public static Drawable getCompatDrawable(Context c, int drawableRes) {
Drawable d = null;
try {
d = ContextCompat.getDrawable(c, drawableRes);
} catch (Exception ex) {
logException(ex);
}
return d;
} | [
"public",
"static",
"Drawable",
"getCompatDrawable",
"(",
"Context",
"c",
",",
"int",
"drawableRes",
")",
"{",
"Drawable",
"d",
"=",
"null",
";",
"try",
"{",
"d",
"=",
"ContextCompat",
".",
"getDrawable",
"(",
"c",
",",
"drawableRes",
")",
";",
"}",
"cat... | helper method to get the drawable by its resource id, specific to the correct android version
@param c
@param drawableRes
@return | [
"helper",
"method",
"to",
"get",
"the",
"drawable",
"by",
"its",
"resource",
"id",
"specific",
"to",
"the",
"correct",
"android",
"version"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L386-L394 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.getSelectableImageButtonBackground | public static StateListDrawable getSelectableImageButtonBackground(int selected_color) {
ColorDrawable selectedColor = new ColorDrawable(selected_color);
StateListDrawable states = new StateListDrawable();
states.addState(new int[]{android.R.attr.state_pressed}, selectedColor);
states.addState(new int[]{android.R.attr.state_activated}, selectedColor);
return states;
} | java | public static StateListDrawable getSelectableImageButtonBackground(int selected_color) {
ColorDrawable selectedColor = new ColorDrawable(selected_color);
StateListDrawable states = new StateListDrawable();
states.addState(new int[]{android.R.attr.state_pressed}, selectedColor);
states.addState(new int[]{android.R.attr.state_activated}, selectedColor);
return states;
} | [
"public",
"static",
"StateListDrawable",
"getSelectableImageButtonBackground",
"(",
"int",
"selected_color",
")",
"{",
"ColorDrawable",
"selectedColor",
"=",
"new",
"ColorDrawable",
"(",
"selected_color",
")",
";",
"StateListDrawable",
"states",
"=",
"new",
"StateListDraw... | helper method to generate the ImageButton background with specified highlight color.
@param selected_color the color shown as highlight
@return | [
"helper",
"method",
"to",
"generate",
"the",
"ImageButton",
"background",
"with",
"specified",
"highlight",
"color",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L443-L449 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.openFileAttachment | public static boolean openFileAttachment(final Context context, final String sourcePath, final String selectedFilePath, final String mimeTypeString) {
if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable())
&& hasPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
File selectedFile = new File(selectedFilePath);
String selectedFileName = null;
if (selectedFile.exists()) {
selectedFileName = selectedFile.getName();
final Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
/* Attachments were downloaded into app private data dir. In order for external app to open
* the attachments, the file need to be copied to a download folder that is accessible to public
* The folder will be sdcard/Downloads/apptentive-received/<file name>
*/
File downloadFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File apptentiveSubFolder = new File(downloadFolder, "apptentive-received");
if (!apptentiveSubFolder.exists()) {
apptentiveSubFolder.mkdir();
}
File tmpfile = new File(apptentiveSubFolder, selectedFileName);
String tmpFilePath = tmpfile.getPath();
// If destination file already exists, overwrite it; otherwise, delete all existing files in the same folder first.
if (!tmpfile.exists()) {
String[] children = apptentiveSubFolder.list();
if (children != null) {
for (int i = 0; i < children.length; i++) {
new File(apptentiveSubFolder, children[i]).delete();
}
}
}
if (copyFile(selectedFilePath, tmpFilePath) == 0) {
return false;
}
intent.setDataAndType(Uri.fromFile(tmpfile), mimeTypeString);
try {
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
ApptentiveLog.e(e, "Activity not found to open attachment: ");
logException(e);
}
}
} else {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(sourcePath));
if (Util.canLaunchIntent(context, browserIntent)) {
context.startActivity(browserIntent);
}
}
return false;
} | java | public static boolean openFileAttachment(final Context context, final String sourcePath, final String selectedFilePath, final String mimeTypeString) {
if ((Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|| !Environment.isExternalStorageRemovable())
&& hasPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
File selectedFile = new File(selectedFilePath);
String selectedFileName = null;
if (selectedFile.exists()) {
selectedFileName = selectedFile.getName();
final Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
/* Attachments were downloaded into app private data dir. In order for external app to open
* the attachments, the file need to be copied to a download folder that is accessible to public
* The folder will be sdcard/Downloads/apptentive-received/<file name>
*/
File downloadFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File apptentiveSubFolder = new File(downloadFolder, "apptentive-received");
if (!apptentiveSubFolder.exists()) {
apptentiveSubFolder.mkdir();
}
File tmpfile = new File(apptentiveSubFolder, selectedFileName);
String tmpFilePath = tmpfile.getPath();
// If destination file already exists, overwrite it; otherwise, delete all existing files in the same folder first.
if (!tmpfile.exists()) {
String[] children = apptentiveSubFolder.list();
if (children != null) {
for (int i = 0; i < children.length; i++) {
new File(apptentiveSubFolder, children[i]).delete();
}
}
}
if (copyFile(selectedFilePath, tmpFilePath) == 0) {
return false;
}
intent.setDataAndType(Uri.fromFile(tmpfile), mimeTypeString);
try {
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
ApptentiveLog.e(e, "Activity not found to open attachment: ");
logException(e);
}
}
} else {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(sourcePath));
if (Util.canLaunchIntent(context, browserIntent)) {
context.startActivity(browserIntent);
}
}
return false;
} | [
"public",
"static",
"boolean",
"openFileAttachment",
"(",
"final",
"Context",
"context",
",",
"final",
"String",
"sourcePath",
",",
"final",
"String",
"selectedFilePath",
",",
"final",
"String",
"mimeTypeString",
")",
"{",
"if",
"(",
"(",
"Environment",
".",
"ME... | This function launchs the default app to view the selected file, based on mime type
@param sourcePath
@param selectedFilePath the full path to the local storage
@param mimeTypeString the mime type of the file to be opened
@return true if file can be viewed | [
"This",
"function",
"launchs",
"the",
"default",
"app",
"to",
"view",
"the",
"selected",
"file",
"based",
"on",
"mime",
"type"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L644-L696 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.copyFile | public static int copyFile(String from, String to) {
InputStream inStream = null;
FileOutputStream fs = null;
try {
int bytesum = 0;
int byteread;
File oldfile = new File(from);
if (oldfile.exists()) {
inStream = new FileInputStream(from);
fs = new FileOutputStream(to);
byte[] buffer = new byte[1444];
while ((byteread = inStream.read(buffer)) != -1) {
bytesum += byteread;
fs.write(buffer, 0, byteread);
}
}
return bytesum;
} catch (Exception e) {
return 0;
} finally {
Util.ensureClosed(inStream);
Util.ensureClosed(fs);
}
} | java | public static int copyFile(String from, String to) {
InputStream inStream = null;
FileOutputStream fs = null;
try {
int bytesum = 0;
int byteread;
File oldfile = new File(from);
if (oldfile.exists()) {
inStream = new FileInputStream(from);
fs = new FileOutputStream(to);
byte[] buffer = new byte[1444];
while ((byteread = inStream.read(buffer)) != -1) {
bytesum += byteread;
fs.write(buffer, 0, byteread);
}
}
return bytesum;
} catch (Exception e) {
return 0;
} finally {
Util.ensureClosed(inStream);
Util.ensureClosed(fs);
}
} | [
"public",
"static",
"int",
"copyFile",
"(",
"String",
"from",
",",
"String",
"to",
")",
"{",
"InputStream",
"inStream",
"=",
"null",
";",
"FileOutputStream",
"fs",
"=",
"null",
";",
"try",
"{",
"int",
"bytesum",
"=",
"0",
";",
"int",
"byteread",
";",
"... | This function copies file from one location to another
@param from the full path to the source file
@param to the full path to the destination file
@return total bytes copied. 0 indicates | [
"This",
"function",
"copies",
"file",
"from",
"one",
"location",
"to",
"another"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L705-L728 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.createLocalStoredFile | public static StoredFile createLocalStoredFile(String sourceUrl, String localFilePath, String mimeType) {
InputStream is = null;
try {
Context context = ApptentiveInternal.getInstance().getApplicationContext();
if (URLUtil.isContentUrl(sourceUrl) && context != null) {
Uri uri = Uri.parse(sourceUrl);
is = context.getContentResolver().openInputStream(uri);
} else {
File file = new File(sourceUrl);
is = new FileInputStream(file);
}
return createLocalStoredFile(is, sourceUrl, localFilePath, mimeType);
} catch (FileNotFoundException e) {
return null;
} finally {
ensureClosed(is);
}
} | java | public static StoredFile createLocalStoredFile(String sourceUrl, String localFilePath, String mimeType) {
InputStream is = null;
try {
Context context = ApptentiveInternal.getInstance().getApplicationContext();
if (URLUtil.isContentUrl(sourceUrl) && context != null) {
Uri uri = Uri.parse(sourceUrl);
is = context.getContentResolver().openInputStream(uri);
} else {
File file = new File(sourceUrl);
is = new FileInputStream(file);
}
return createLocalStoredFile(is, sourceUrl, localFilePath, mimeType);
} catch (FileNotFoundException e) {
return null;
} finally {
ensureClosed(is);
}
} | [
"public",
"static",
"StoredFile",
"createLocalStoredFile",
"(",
"String",
"sourceUrl",
",",
"String",
"localFilePath",
",",
"String",
"mimeType",
")",
"{",
"InputStream",
"is",
"=",
"null",
";",
"try",
"{",
"Context",
"context",
"=",
"ApptentiveInternal",
".",
"... | This method creates a cached file exactly copying from the input stream.
@param sourceUrl the source file path or uri string
@param localFilePath the cache file path string
@param mimeType the mimeType of the source inputstream
@return null if failed, otherwise a StoredFile object | [
"This",
"method",
"creates",
"a",
"cached",
"file",
"exactly",
"copying",
"from",
"the",
"input",
"stream",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L914-L932 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.createLocalStoredFile | public static StoredFile createLocalStoredFile(InputStream is, String sourceUrl, String localFilePath, String mimeType) {
if (is == null) {
return null;
}
// Copy the file contents over.
CountingOutputStream cos = null;
BufferedOutputStream bos = null;
FileOutputStream fos = null;
try {
File localFile = new File(localFilePath);
/* Local cache file name may not be unique, and can be reused, in which case, the previously created
* cache file need to be deleted before it is being copied over.
*/
if (localFile.exists()) {
localFile.delete();
}
fos = new FileOutputStream(localFile);
bos = new BufferedOutputStream(fos);
cos = new CountingOutputStream(bos);
byte[] buf = new byte[2048];
int count;
while ((count = is.read(buf, 0, 2048)) != -1) {
cos.write(buf, 0, count);
}
ApptentiveLog.v(UTIL, "File saved, size = " + (cos.getBytesWritten() / 1024) + "k");
} catch (IOException e) {
ApptentiveLog.e(UTIL, "Error creating local copy of file attachment.");
logException(e);
return null;
} finally {
Util.ensureClosed(cos);
Util.ensureClosed(bos);
Util.ensureClosed(fos);
}
// Create a StoredFile database entry for this locally saved file.
StoredFile storedFile = new StoredFile();
storedFile.setSourceUriOrPath(sourceUrl);
storedFile.setLocalFilePath(localFilePath);
storedFile.setMimeType(mimeType);
return storedFile;
} | java | public static StoredFile createLocalStoredFile(InputStream is, String sourceUrl, String localFilePath, String mimeType) {
if (is == null) {
return null;
}
// Copy the file contents over.
CountingOutputStream cos = null;
BufferedOutputStream bos = null;
FileOutputStream fos = null;
try {
File localFile = new File(localFilePath);
/* Local cache file name may not be unique, and can be reused, in which case, the previously created
* cache file need to be deleted before it is being copied over.
*/
if (localFile.exists()) {
localFile.delete();
}
fos = new FileOutputStream(localFile);
bos = new BufferedOutputStream(fos);
cos = new CountingOutputStream(bos);
byte[] buf = new byte[2048];
int count;
while ((count = is.read(buf, 0, 2048)) != -1) {
cos.write(buf, 0, count);
}
ApptentiveLog.v(UTIL, "File saved, size = " + (cos.getBytesWritten() / 1024) + "k");
} catch (IOException e) {
ApptentiveLog.e(UTIL, "Error creating local copy of file attachment.");
logException(e);
return null;
} finally {
Util.ensureClosed(cos);
Util.ensureClosed(bos);
Util.ensureClosed(fos);
}
// Create a StoredFile database entry for this locally saved file.
StoredFile storedFile = new StoredFile();
storedFile.setSourceUriOrPath(sourceUrl);
storedFile.setLocalFilePath(localFilePath);
storedFile.setMimeType(mimeType);
return storedFile;
} | [
"public",
"static",
"StoredFile",
"createLocalStoredFile",
"(",
"InputStream",
"is",
",",
"String",
"sourceUrl",
",",
"String",
"localFilePath",
",",
"String",
"mimeType",
")",
"{",
"if",
"(",
"is",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// Cop... | This method creates a cached file copy from the source input stream.
@param is the source input stream
@param sourceUrl the source file path or uri string
@param localFilePath the cache file path string
@param mimeType the mimeType of the source inputstream
@return null if failed, otherwise a StoredFile object | [
"This",
"method",
"creates",
"a",
"cached",
"file",
"copy",
"from",
"the",
"source",
"input",
"stream",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L943-L985 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.buildApptentiveInteractionTheme | public static Resources.Theme buildApptentiveInteractionTheme(Context context) {
Resources.Theme theme = context.getResources().newTheme();
// 1. Start by basing this on the Apptentive theme.
theme.applyStyle(R.style.ApptentiveTheme_Base_Versioned, true);
// 2. Get the theme from the host app. Overwrite what we have so far with the app's theme from
// the AndroidManifest.xml. This ensures that the app's styling shows up in our UI.
int appTheme;
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
ApplicationInfo ai = packageInfo.applicationInfo;
appTheme = ai.theme;
if (appTheme != 0) {
theme.applyStyle(appTheme, true);
}
} catch (PackageManager.NameNotFoundException e) {
// Can't happen
return null;
}
// Step 3: Restore Apptentive UI window properties that may have been overridden in Step 2. This
// ensures Apptentive interaction has a modal feel and look.
theme.applyStyle(R.style.ApptentiveBaseFrameTheme, true);
// Step 4: Apply optional theme override specified in host app's style
int themeOverrideResId = context.getResources().getIdentifier("ApptentiveThemeOverride", "style", context.getPackageName());
if (themeOverrideResId != 0) {
theme.applyStyle(themeOverrideResId, true);
}
return theme;
} | java | public static Resources.Theme buildApptentiveInteractionTheme(Context context) {
Resources.Theme theme = context.getResources().newTheme();
// 1. Start by basing this on the Apptentive theme.
theme.applyStyle(R.style.ApptentiveTheme_Base_Versioned, true);
// 2. Get the theme from the host app. Overwrite what we have so far with the app's theme from
// the AndroidManifest.xml. This ensures that the app's styling shows up in our UI.
int appTheme;
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
ApplicationInfo ai = packageInfo.applicationInfo;
appTheme = ai.theme;
if (appTheme != 0) {
theme.applyStyle(appTheme, true);
}
} catch (PackageManager.NameNotFoundException e) {
// Can't happen
return null;
}
// Step 3: Restore Apptentive UI window properties that may have been overridden in Step 2. This
// ensures Apptentive interaction has a modal feel and look.
theme.applyStyle(R.style.ApptentiveBaseFrameTheme, true);
// Step 4: Apply optional theme override specified in host app's style
int themeOverrideResId = context.getResources().getIdentifier("ApptentiveThemeOverride", "style", context.getPackageName());
if (themeOverrideResId != 0) {
theme.applyStyle(themeOverrideResId, true);
}
return theme;
} | [
"public",
"static",
"Resources",
".",
"Theme",
"buildApptentiveInteractionTheme",
"(",
"Context",
"context",
")",
"{",
"Resources",
".",
"Theme",
"theme",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"newTheme",
"(",
")",
";",
"// 1. Start by basing this on... | Builds out the main theme that we would like to use for all Apptentive UI, basing it on the
existing app theme, and adding Apptentive's theme where it doesn't override the existing app's
attributes. Finally, it forces changes to the theme using ApptentiveThemeOverride.
@param context The context for the app or Activity whose theme we want to inherit from.
@return A {@link Resources.Theme} | [
"Builds",
"out",
"the",
"main",
"theme",
"that",
"we",
"would",
"like",
"to",
"use",
"for",
"all",
"Apptentive",
"UI",
"basing",
"it",
"on",
"the",
"existing",
"app",
"theme",
"and",
"adding",
"Apptentive",
"s",
"theme",
"where",
"it",
"doesn",
"t",
"ove... | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L1079-L1111 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.getInternalDir | public static File getInternalDir(Context context, String path, boolean createIfNecessary) {
File filesDir = context.getFilesDir();
File internalDir = new File(filesDir, path);
if (!internalDir.exists() && createIfNecessary) {
boolean succeed = internalDir.mkdirs();
if (!succeed) {
ApptentiveLog.w(UTIL, "Unable to create internal directory: %s", internalDir);
}
}
return internalDir;
} | java | public static File getInternalDir(Context context, String path, boolean createIfNecessary) {
File filesDir = context.getFilesDir();
File internalDir = new File(filesDir, path);
if (!internalDir.exists() && createIfNecessary) {
boolean succeed = internalDir.mkdirs();
if (!succeed) {
ApptentiveLog.w(UTIL, "Unable to create internal directory: %s", internalDir);
}
}
return internalDir;
} | [
"public",
"static",
"File",
"getInternalDir",
"(",
"Context",
"context",
",",
"String",
"path",
",",
"boolean",
"createIfNecessary",
")",
"{",
"File",
"filesDir",
"=",
"context",
".",
"getFilesDir",
"(",
")",
";",
"File",
"internalDir",
"=",
"new",
"File",
"... | Returns and internal storage directory | [
"Returns",
"and",
"internal",
"storage",
"directory"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L1130-L1140 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.getManifestMetadataString | public static String getManifestMetadataString(Context context, String key) {
if (context == null) {
throw new IllegalArgumentException("Context is null");
}
if (key == null) {
throw new IllegalArgumentException("Key is null");
}
try {
String appPackageName = context.getPackageName();
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(appPackageName, PackageManager.GET_META_DATA | PackageManager.GET_RECEIVERS);
Bundle metaData = packageInfo.applicationInfo.metaData;
if (metaData != null) {
return Util.trim(metaData.getString(key));
}
} catch (Exception e) {
ApptentiveLog.e(e, "Unexpected error while reading application or package info.");
logException(e);
}
return null;
} | java | public static String getManifestMetadataString(Context context, String key) {
if (context == null) {
throw new IllegalArgumentException("Context is null");
}
if (key == null) {
throw new IllegalArgumentException("Key is null");
}
try {
String appPackageName = context.getPackageName();
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(appPackageName, PackageManager.GET_META_DATA | PackageManager.GET_RECEIVERS);
Bundle metaData = packageInfo.applicationInfo.metaData;
if (metaData != null) {
return Util.trim(metaData.getString(key));
}
} catch (Exception e) {
ApptentiveLog.e(e, "Unexpected error while reading application or package info.");
logException(e);
}
return null;
} | [
"public",
"static",
"String",
"getManifestMetadataString",
"(",
"Context",
"context",
",",
"String",
"key",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Context is null\"",
")",
";",
"}",
"if",
"("... | Helper method for resolving manifest metadata string value
@return null if key is missing or exception is thrown | [
"Helper",
"method",
"for",
"resolving",
"manifest",
"metadata",
"string",
"value"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L1147-L1170 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.guarded | public static @Nullable View.OnClickListener guarded(@Nullable final View.OnClickListener listener) {
if (listener != null) {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
listener.onClick(v);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while handling click listener");
logException(e);
}
}
};
}
return null;
} | java | public static @Nullable View.OnClickListener guarded(@Nullable final View.OnClickListener listener) {
if (listener != null) {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
listener.onClick(v);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while handling click listener");
logException(e);
}
}
};
}
return null;
} | [
"public",
"static",
"@",
"Nullable",
"View",
".",
"OnClickListener",
"guarded",
"(",
"@",
"Nullable",
"final",
"View",
".",
"OnClickListener",
"listener",
")",
"{",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"return",
"new",
"View",
".",
"OnClickListener... | Creates a fail-safe try..catch wrapped listener | [
"Creates",
"a",
"fail",
"-",
"safe",
"try",
"..",
"catch",
"wrapped",
"listener"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L1207-L1223 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/debug/Assert.java | Assert.assertMainThread | public static void assertMainThread() {
if (imp != null && !DispatchQueue.isMainQueue()) {
imp.assertFailed(StringUtils.format("Expected 'main' thread but was '%s'", Thread.currentThread().getName()));
}
} | java | public static void assertMainThread() {
if (imp != null && !DispatchQueue.isMainQueue()) {
imp.assertFailed(StringUtils.format("Expected 'main' thread but was '%s'", Thread.currentThread().getName()));
}
} | [
"public",
"static",
"void",
"assertMainThread",
"(",
")",
"{",
"if",
"(",
"imp",
"!=",
"null",
"&&",
"!",
"DispatchQueue",
".",
"isMainQueue",
"(",
")",
")",
"{",
"imp",
".",
"assertFailed",
"(",
"StringUtils",
".",
"format",
"(",
"\"Expected 'main' thread b... | Asserts that code executes on the main thread. | [
"Asserts",
"that",
"code",
"executes",
"on",
"the",
"main",
"thread",
"."
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/debug/Assert.java#L179-L183 | train |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/debug/Assert.java | Assert.assertFail | public static void assertFail(String format, Object... args) {
assertFail(StringUtils.format(format, args));
} | java | public static void assertFail(String format, Object... args) {
assertFail(StringUtils.format(format, args));
} | [
"public",
"static",
"void",
"assertFail",
"(",
"String",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"assertFail",
"(",
"StringUtils",
".",
"format",
"(",
"format",
",",
"args",
")",
")",
";",
"}"
] | General failure with a message | [
"General",
"failure",
"with",
"a",
"message"
] | 887c08d7bd5ae6488a90366dfb58f58938861a93 | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/debug/Assert.java#L201-L203 | train |
cerner/beadledom | pagination/src/main/java/com/cerner/beadledom/pagination/parameters/AbstractParameter.java | AbstractParameter.getValue | public T getValue() {
try {
value = parse(originalParameter);
} catch (InvalidParameterException e) {
throw new WebApplicationException(onError(e));
}
return value;
} | java | public T getValue() {
try {
value = parse(originalParameter);
} catch (InvalidParameterException e) {
throw new WebApplicationException(onError(e));
}
return value;
} | [
"public",
"T",
"getValue",
"(",
")",
"{",
"try",
"{",
"value",
"=",
"parse",
"(",
"originalParameter",
")",
";",
"}",
"catch",
"(",
"InvalidParameterException",
"e",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"onError",
"(",
"e",
")",
")",
... | Returns the parsed value. | [
"Returns",
"the",
"parsed",
"value",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/pagination/src/main/java/com/cerner/beadledom/pagination/parameters/AbstractParameter.java#L38-L45 | train |
cerner/beadledom | client/beadledom-client/src/main/java/com/cerner/beadledom/client/BeadledomClientConfiguration.java | BeadledomClientConfiguration.builder | public static Builder builder() {
return new AutoValue_BeadledomClientConfiguration.Builder()
.connectionPoolSize(DEFAULT_CONNECTION_POOL_SIZE)
.maxPooledPerRouteSize(DEFAULT_MAX_POOLED_PER_ROUTE)
.socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
.connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
.ttlMillis(DEFAULT_TTL_MILLIS);
} | java | public static Builder builder() {
return new AutoValue_BeadledomClientConfiguration.Builder()
.connectionPoolSize(DEFAULT_CONNECTION_POOL_SIZE)
.maxPooledPerRouteSize(DEFAULT_MAX_POOLED_PER_ROUTE)
.socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
.connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
.ttlMillis(DEFAULT_TTL_MILLIS);
} | [
"public",
"static",
"Builder",
"builder",
"(",
")",
"{",
"return",
"new",
"AutoValue_BeadledomClientConfiguration",
".",
"Builder",
"(",
")",
".",
"connectionPoolSize",
"(",
"DEFAULT_CONNECTION_POOL_SIZE",
")",
".",
"maxPooledPerRouteSize",
"(",
"DEFAULT_MAX_POOLED_PER_RO... | Default client config builder. | [
"Default",
"client",
"config",
"builder",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/client/beadledom-client/src/main/java/com/cerner/beadledom/client/BeadledomClientConfiguration.java#L31-L38 | train |
cerner/beadledom | jooq/src/main/java/com/cerner/beadledom/jooq/JooqTxnInterceptor.java | JooqTxnInterceptor.invokeInTransactionAndUnitOfWork | private Object invokeInTransactionAndUnitOfWork(MethodInvocation methodInvocation)
throws Throwable {
boolean unitOfWorkAlreadyStarted = unitOfWork.isActive();
if (!unitOfWorkAlreadyStarted) {
unitOfWork.begin();
}
Throwable originalThrowable = null;
try {
return dslContextProvider.get().transactionResult(() -> {
try {
return methodInvocation.proceed();
} catch (Throwable e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new RuntimeException(e);
}
});
} catch (Throwable t) {
originalThrowable = t;
throw t;
} finally {
if (!unitOfWorkAlreadyStarted) {
endUnitOfWork(originalThrowable);
}
}
} | java | private Object invokeInTransactionAndUnitOfWork(MethodInvocation methodInvocation)
throws Throwable {
boolean unitOfWorkAlreadyStarted = unitOfWork.isActive();
if (!unitOfWorkAlreadyStarted) {
unitOfWork.begin();
}
Throwable originalThrowable = null;
try {
return dslContextProvider.get().transactionResult(() -> {
try {
return methodInvocation.proceed();
} catch (Throwable e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new RuntimeException(e);
}
});
} catch (Throwable t) {
originalThrowable = t;
throw t;
} finally {
if (!unitOfWorkAlreadyStarted) {
endUnitOfWork(originalThrowable);
}
}
} | [
"private",
"Object",
"invokeInTransactionAndUnitOfWork",
"(",
"MethodInvocation",
"methodInvocation",
")",
"throws",
"Throwable",
"{",
"boolean",
"unitOfWorkAlreadyStarted",
"=",
"unitOfWork",
".",
"isActive",
"(",
")",
";",
"if",
"(",
"!",
"unitOfWorkAlreadyStarted",
"... | Invokes the method wrapped within a unit of work and a transaction.
@param methodInvocation the method to be invoked within a transaction
@return the result of the call to the invoked method
@throws Throwable if an exception occurs during the method invocation, transaction, or unit of
work | [
"Invokes",
"the",
"method",
"wrapped",
"within",
"a",
"unit",
"of",
"work",
"and",
"a",
"transaction",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jooq/src/main/java/com/cerner/beadledom/jooq/JooqTxnInterceptor.java#L38-L66 | train |
cerner/beadledom | jooq/src/main/java/com/cerner/beadledom/jooq/JooqTxnInterceptor.java | JooqTxnInterceptor.endUnitOfWork | private void endUnitOfWork(Throwable originalThrowable) throws Throwable {
try {
unitOfWork.end();
} catch (Throwable t) {
if (originalThrowable != null) {
throw originalThrowable;
} else {
throw t;
}
}
} | java | private void endUnitOfWork(Throwable originalThrowable) throws Throwable {
try {
unitOfWork.end();
} catch (Throwable t) {
if (originalThrowable != null) {
throw originalThrowable;
} else {
throw t;
}
}
} | [
"private",
"void",
"endUnitOfWork",
"(",
"Throwable",
"originalThrowable",
")",
"throws",
"Throwable",
"{",
"try",
"{",
"unitOfWork",
".",
"end",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
"originalThrowable",
"!=",
"null",
")... | Ends the unit of work.
<p>If originalThrowable is present, and an exception is thrown, then the originalThrowable
will be preferred and thrown instead; if originalThrowable is not present, and an exception is
thrown, then the unitOfWork exception will be thrown.
@param originalThrowable the original exception that was thrown and should be propagated
@throws Throwable if an exception occurred while ending the unit of work | [
"Ends",
"the",
"unit",
"of",
"work",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jooq/src/main/java/com/cerner/beadledom/jooq/JooqTxnInterceptor.java#L78-L88 | train |
cerner/beadledom | pagination/src/main/java/com/cerner/beadledom/pagination/parameters/OffsetPaginationParameters.java | OffsetPaginationParameters.getLimit | public Integer getLimit() {
String limitFromRequest =
uriInfo.getQueryParameters().getFirst(LimitParameter.getDefaultLimitFieldName());
return limitFromRequest != null ? new LimitParameter(limitFromRequest).getValue()
: LimitParameter.getDefaultLimit();
} | java | public Integer getLimit() {
String limitFromRequest =
uriInfo.getQueryParameters().getFirst(LimitParameter.getDefaultLimitFieldName());
return limitFromRequest != null ? new LimitParameter(limitFromRequest).getValue()
: LimitParameter.getDefaultLimit();
} | [
"public",
"Integer",
"getLimit",
"(",
")",
"{",
"String",
"limitFromRequest",
"=",
"uriInfo",
".",
"getQueryParameters",
"(",
")",
".",
"getFirst",
"(",
"LimitParameter",
".",
"getDefaultLimitFieldName",
"(",
")",
")",
";",
"return",
"limitFromRequest",
"!=",
"n... | Retrieves the value of the limit field from the request. Will use the configured field name
to find the parameter.
@return The value of the limit. | [
"Retrieves",
"the",
"value",
"of",
"the",
"limit",
"field",
"from",
"the",
"request",
".",
"Will",
"use",
"the",
"configured",
"field",
"name",
"to",
"find",
"the",
"parameter",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/pagination/src/main/java/com/cerner/beadledom/pagination/parameters/OffsetPaginationParameters.java#L28-L34 | train |
cerner/beadledom | pagination/src/main/java/com/cerner/beadledom/pagination/parameters/OffsetPaginationParameters.java | OffsetPaginationParameters.getOffset | public Long getOffset() {
String offsetFromRequest =
uriInfo.getQueryParameters().getFirst(OffsetParameter.getDefaultOffsetFieldName());
return offsetFromRequest != null ? new OffsetParameter(offsetFromRequest).getValue()
: OffsetParameter.getDefaultOffset();
} | java | public Long getOffset() {
String offsetFromRequest =
uriInfo.getQueryParameters().getFirst(OffsetParameter.getDefaultOffsetFieldName());
return offsetFromRequest != null ? new OffsetParameter(offsetFromRequest).getValue()
: OffsetParameter.getDefaultOffset();
} | [
"public",
"Long",
"getOffset",
"(",
")",
"{",
"String",
"offsetFromRequest",
"=",
"uriInfo",
".",
"getQueryParameters",
"(",
")",
".",
"getFirst",
"(",
"OffsetParameter",
".",
"getDefaultOffsetFieldName",
"(",
")",
")",
";",
"return",
"offsetFromRequest",
"!=",
... | Retrieves the value of the offset field from the request. Will use the configured field name
to find the parameter
@return The value of the offset. | [
"Retrieves",
"the",
"value",
"of",
"the",
"offset",
"field",
"from",
"the",
"request",
".",
"Will",
"use",
"the",
"configured",
"field",
"name",
"to",
"find",
"the",
"parameter"
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/pagination/src/main/java/com/cerner/beadledom/pagination/parameters/OffsetPaginationParameters.java#L42-L48 | train |
cerner/beadledom | pagination/src/main/java/com/cerner/beadledom/pagination/parameters/LimitParameter.java | LimitParameter.checkLimitRange | private void checkLimitRange(int limit) {
int minLimit = offsetPaginationConfiguration.allowZeroLimit() ? 0 : 1;
if (limit < minLimit || limit > offsetPaginationConfiguration.maxLimit()) {
throw InvalidParameterException.create(
"Invalid value for '" + this.getParameterFieldName() + "': " + limit
+ " - value between " + minLimit + " and " + offsetPaginationConfiguration.maxLimit()
+ " is required.");
}
} | java | private void checkLimitRange(int limit) {
int minLimit = offsetPaginationConfiguration.allowZeroLimit() ? 0 : 1;
if (limit < minLimit || limit > offsetPaginationConfiguration.maxLimit()) {
throw InvalidParameterException.create(
"Invalid value for '" + this.getParameterFieldName() + "': " + limit
+ " - value between " + minLimit + " and " + offsetPaginationConfiguration.maxLimit()
+ " is required.");
}
} | [
"private",
"void",
"checkLimitRange",
"(",
"int",
"limit",
")",
"{",
"int",
"minLimit",
"=",
"offsetPaginationConfiguration",
".",
"allowZeroLimit",
"(",
")",
"?",
"0",
":",
"1",
";",
"if",
"(",
"limit",
"<",
"minLimit",
"||",
"limit",
">",
"offsetPagination... | Ensures that the limit is in the allowed range.
@param limit the parsed limit value to check the range of
@throws InvalidParameterException if the limit value is less outside of the allowed range | [
"Ensures",
"that",
"the",
"limit",
"is",
"in",
"the",
"allowed",
"range",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/pagination/src/main/java/com/cerner/beadledom/pagination/parameters/LimitParameter.java#L72-L81 | train |
cerner/beadledom | stagemonitor/src/main/java/com/cerner/beadledom/stagemonitor/request/CondensedCallStackElement.java | CondensedCallStackElement.getSignature | @Override
public String getSignature() {
String signature = super.getSignature();
if (signature.indexOf('(') == -1) {
return signature;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Condensing signature [{}]", signature);
}
int returnTypeSpace = signature.indexOf(" ");
StringBuilder sb = new StringBuilder(100);
sb.append(signature.substring(0, returnTypeSpace + 1));
// Have to replace ".." to "." for classes generated by guice. e.g.
// Object com.cerner.beadledom.health.resource.AvailabilityResource..FastClassByGuice..77b09000.newInstance(int, Object[])
String[] parts =
signature.replaceAll("\\.\\.", ".").substring(returnTypeSpace + 1).split("\\.");
for (int i = 0; i < parts.length - 2; i++) {
// Shorten each package name to only include the first character
sb.append(parts[i].charAt(0)).append(".");
}
sb.append(parts[parts.length - 2]).append(".").append(parts[parts.length - 1]);
return sb.toString();
} | java | @Override
public String getSignature() {
String signature = super.getSignature();
if (signature.indexOf('(') == -1) {
return signature;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Condensing signature [{}]", signature);
}
int returnTypeSpace = signature.indexOf(" ");
StringBuilder sb = new StringBuilder(100);
sb.append(signature.substring(0, returnTypeSpace + 1));
// Have to replace ".." to "." for classes generated by guice. e.g.
// Object com.cerner.beadledom.health.resource.AvailabilityResource..FastClassByGuice..77b09000.newInstance(int, Object[])
String[] parts =
signature.replaceAll("\\.\\.", ".").substring(returnTypeSpace + 1).split("\\.");
for (int i = 0; i < parts.length - 2; i++) {
// Shorten each package name to only include the first character
sb.append(parts[i].charAt(0)).append(".");
}
sb.append(parts[parts.length - 2]).append(".").append(parts[parts.length - 1]);
return sb.toString();
} | [
"@",
"Override",
"public",
"String",
"getSignature",
"(",
")",
"{",
"String",
"signature",
"=",
"super",
".",
"getSignature",
"(",
")",
";",
"if",
"(",
"signature",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"{",
"return",
"signature",
... | Returns the signature with the packages names shortened to only include the first character.
@return the condensed signature. e.g. {@code void org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletRequest, HttpServletResponse)}
would return {@code void o.j.r.p.s.s.HttpServletDispatcher.service(HttpServletRequest,
HttpServletResponse)} | [
"Returns",
"the",
"signature",
"with",
"the",
"packages",
"names",
"shortened",
"to",
"only",
"include",
"the",
"first",
"character",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/stagemonitor/src/main/java/com/cerner/beadledom/stagemonitor/request/CondensedCallStackElement.java#L54-L82 | train |
cerner/beadledom | jaxrs-genericresponse/src/main/java/com/cerner/beadledom/jaxrs/GenericResponseBuilder.java | GenericResponseBuilder.errorEntity | public GenericResponseBuilder<T> errorEntity(Object errorEntity, Annotation[] annotations) {
if (body != null) {
throw new IllegalStateException(
"entity already set. Only one of entity and errorEntity may be set");
}
rawBuilder.entity(errorEntity, annotations);
hasErrorEntity = true;
return this;
} | java | public GenericResponseBuilder<T> errorEntity(Object errorEntity, Annotation[] annotations) {
if (body != null) {
throw new IllegalStateException(
"entity already set. Only one of entity and errorEntity may be set");
}
rawBuilder.entity(errorEntity, annotations);
hasErrorEntity = true;
return this;
} | [
"public",
"GenericResponseBuilder",
"<",
"T",
">",
"errorEntity",
"(",
"Object",
"errorEntity",
",",
"Annotation",
"[",
"]",
"annotations",
")",
"{",
"if",
"(",
"body",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"entity already set. ... | Sets the response error entity body on the builder.
<p>A specific media type can be set using the {@code type(...)} methods.
@param errorEntity the response error entity body
@param annotations annotations, in addition to the annotations on the resource method returning
the response, to be passed to the {@link MessageBodyWriter}
@return this builder
@see #type(MediaType)
@see #type(String) | [
"Sets",
"the",
"response",
"error",
"entity",
"body",
"on",
"the",
"builder",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jaxrs-genericresponse/src/main/java/com/cerner/beadledom/jaxrs/GenericResponseBuilder.java#L165-L173 | train |
cerner/beadledom | jaxrs-genericresponse/src/main/java/com/cerner/beadledom/jaxrs/GenericResponseBuilder.java | GenericResponseBuilder.header | public GenericResponseBuilder<T> header(String name, Object value) {
rawBuilder.header(name, value);
return this;
} | java | public GenericResponseBuilder<T> header(String name, Object value) {
rawBuilder.header(name, value);
return this;
} | [
"public",
"GenericResponseBuilder",
"<",
"T",
">",
"header",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"rawBuilder",
".",
"header",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Adds a header to the response.
@param name the header name
@param value the header value, {@code null} will clear any existing headers for the same name
@return this builder
@see Response.ResponseBuilder#header(String, Object) | [
"Adds",
"a",
"header",
"to",
"the",
"response",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jaxrs-genericresponse/src/main/java/com/cerner/beadledom/jaxrs/GenericResponseBuilder.java#L230-L233 | train |
cerner/beadledom | jaxrs-genericresponse/src/main/java/com/cerner/beadledom/jaxrs/GenericResponseBuilder.java | GenericResponseBuilder.replaceAll | public GenericResponseBuilder<T> replaceAll(MultivaluedMap<String, Object> headers) {
rawBuilder.replaceAll(headers);
return this;
} | java | public GenericResponseBuilder<T> replaceAll(MultivaluedMap<String, Object> headers) {
rawBuilder.replaceAll(headers);
return this;
} | [
"public",
"GenericResponseBuilder",
"<",
"T",
">",
"replaceAll",
"(",
"MultivaluedMap",
"<",
"String",
",",
"Object",
">",
"headers",
")",
"{",
"rawBuilder",
".",
"replaceAll",
"(",
"headers",
")",
";",
"return",
"this",
";",
"}"
] | Replaces all of the headers with the these headers.
@param headers the new headers to be used, {@code null} to remove all existing headers
@return this builder | [
"Replaces",
"all",
"of",
"the",
"headers",
"with",
"the",
"these",
"headers",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jaxrs-genericresponse/src/main/java/com/cerner/beadledom/jaxrs/GenericResponseBuilder.java#L241-L244 | train |
cerner/beadledom | jaxrs-genericresponse/src/main/java/com/cerner/beadledom/jaxrs/GenericResponseBuilder.java | GenericResponseBuilder.link | public GenericResponseBuilder<T> link(URI uri, String rel) {
rawBuilder.link(uri, rel);
return this;
} | java | public GenericResponseBuilder<T> link(URI uri, String rel) {
rawBuilder.link(uri, rel);
return this;
} | [
"public",
"GenericResponseBuilder",
"<",
"T",
">",
"link",
"(",
"URI",
"uri",
",",
"String",
"rel",
")",
"{",
"rawBuilder",
".",
"link",
"(",
"uri",
",",
"rel",
")",
";",
"return",
"this",
";",
"}"
] | Adds a link header.
@param uri the URI of the link header
@param rel the value of the {@code rel} parameter
@return this builder | [
"Adds",
"a",
"link",
"header",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jaxrs-genericresponse/src/main/java/com/cerner/beadledom/jaxrs/GenericResponseBuilder.java#L430-L433 | train |
cerner/beadledom | health/service/src/main/java/com/cerner/beadledom/health/HealthStatus.java | HealthStatus.create | public static HealthStatus create(int status, String message, Throwable exception) {
return new AutoValue_HealthStatus(message, status, Optional.ofNullable(exception));
} | java | public static HealthStatus create(int status, String message, Throwable exception) {
return new AutoValue_HealthStatus(message, status, Optional.ofNullable(exception));
} | [
"public",
"static",
"HealthStatus",
"create",
"(",
"int",
"status",
",",
"String",
"message",
",",
"Throwable",
"exception",
")",
"{",
"return",
"new",
"AutoValue_HealthStatus",
"(",
"message",
",",
"status",
",",
"Optional",
".",
"ofNullable",
"(",
"exception",... | Create an instance with the given message, status code, and exception. | [
"Create",
"an",
"instance",
"with",
"the",
"given",
"message",
"status",
"code",
"and",
"exception",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/health/service/src/main/java/com/cerner/beadledom/health/HealthStatus.java#L21-L23 | train |
cerner/beadledom | common/src/main/java/com/cerner/beadledom/metadata/BuildInfo.java | BuildInfo.create | public static BuildInfo create(Properties properties) {
checkNotNull(properties, "properties: null");
return builder()
.setArtifactId(
checkNotNull(properties.getProperty("project.artifactId"), "project.artifactId: null"))
.setGroupId(
checkNotNull(properties.getProperty("project.groupId"), "project.groupId: null"))
.setRawProperties(properties)
.setScmRevision(
checkNotNull(properties.getProperty("git.commit.id"), "git.commit.id: null"))
.setVersion(
checkNotNull(properties.getProperty("project.version"), "project.version: null"))
.setBuildDateTime(Optional.ofNullable(properties.getProperty("project.build.date")))
.build();
} | java | public static BuildInfo create(Properties properties) {
checkNotNull(properties, "properties: null");
return builder()
.setArtifactId(
checkNotNull(properties.getProperty("project.artifactId"), "project.artifactId: null"))
.setGroupId(
checkNotNull(properties.getProperty("project.groupId"), "project.groupId: null"))
.setRawProperties(properties)
.setScmRevision(
checkNotNull(properties.getProperty("git.commit.id"), "git.commit.id: null"))
.setVersion(
checkNotNull(properties.getProperty("project.version"), "project.version: null"))
.setBuildDateTime(Optional.ofNullable(properties.getProperty("project.build.date")))
.build();
} | [
"public",
"static",
"BuildInfo",
"create",
"(",
"Properties",
"properties",
")",
"{",
"checkNotNull",
"(",
"properties",
",",
"\"properties: null\"",
")",
";",
"return",
"builder",
"(",
")",
".",
"setArtifactId",
"(",
"checkNotNull",
"(",
"properties",
".",
"get... | Create an instance using the given properties.
<p>Currently, at least the following properties are required:
<ul>
<li>git.commit.id</li>
<li>project.artifactId</li>
<li>project.groupId</li>
<li>project.version</li>
</ul>
<p>Optional properties:
<ul>
<li>project.build.date</li>
</ul> | [
"Create",
"an",
"instance",
"using",
"the",
"given",
"properties",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/common/src/main/java/com/cerner/beadledom/metadata/BuildInfo.java#L102-L116 | train |
cerner/beadledom | health/service/src/main/java/com/cerner/beadledom/health/internal/HealthChecker.java | HealthChecker.doPrimaryHealthCheck | public HealthDto doPrimaryHealthCheck() {
List<HealthDependency> primaryHealthDependencies = healthDependencies.values().stream()
.filter(HealthDependency::isPrimary)
.collect(Collectors.toList());
return checkHealth(primaryHealthDependencies);
} | java | public HealthDto doPrimaryHealthCheck() {
List<HealthDependency> primaryHealthDependencies = healthDependencies.values().stream()
.filter(HealthDependency::isPrimary)
.collect(Collectors.toList());
return checkHealth(primaryHealthDependencies);
} | [
"public",
"HealthDto",
"doPrimaryHealthCheck",
"(",
")",
"{",
"List",
"<",
"HealthDependency",
">",
"primaryHealthDependencies",
"=",
"healthDependencies",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"HealthDependency",
"::",
"isPrimary",... | Performs the Primary Health Check.
<p>The resulting DTO will contain information about the health of all the main dependencies
(currently, all dependencies) as well as an overall status of either 200 (if all dependencies
are healthy) or 503 (if one or more dependencies are unhealthy) and corresponding message.
Other metadata fields on the HealthDto will also be populated. | [
"Performs",
"the",
"Primary",
"Health",
"Check",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/health/service/src/main/java/com/cerner/beadledom/health/internal/HealthChecker.java#L59-L64 | train |
cerner/beadledom | health/service/src/main/java/com/cerner/beadledom/health/internal/HealthChecker.java | HealthChecker.doDependencyListing | public List<HealthDependencyDto> doDependencyListing() {
List<HealthDependencyDto> listing = Lists.newArrayList();
for (HealthDependency dependency : healthDependencies.values()) {
listing.add(dependencyDtoBuilder(dependency).build());
}
return listing;
} | java | public List<HealthDependencyDto> doDependencyListing() {
List<HealthDependencyDto> listing = Lists.newArrayList();
for (HealthDependency dependency : healthDependencies.values()) {
listing.add(dependencyDtoBuilder(dependency).build());
}
return listing;
} | [
"public",
"List",
"<",
"HealthDependencyDto",
">",
"doDependencyListing",
"(",
")",
"{",
"List",
"<",
"HealthDependencyDto",
">",
"listing",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"HealthDependency",
"dependency",
":",
"healthDependencies",
... | Returns a list of all health dependencies, but does not check their health. | [
"Returns",
"a",
"list",
"of",
"all",
"health",
"dependencies",
"but",
"does",
"not",
"check",
"their",
"health",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/health/service/src/main/java/com/cerner/beadledom/health/internal/HealthChecker.java#L78-L84 | train |
cerner/beadledom | health/service/src/main/java/com/cerner/beadledom/health/internal/HealthChecker.java | HealthChecker.doDependencyAvailabilityCheck | public HealthDependencyDto doDependencyAvailabilityCheck(String name) {
HealthDependency dependency = healthDependencies.get(checkNotNull(name));
if (dependency == null) {
throw new WebApplicationException(Response.status(404).build());
}
return checkDependencyHealth(dependency);
} | java | public HealthDependencyDto doDependencyAvailabilityCheck(String name) {
HealthDependency dependency = healthDependencies.get(checkNotNull(name));
if (dependency == null) {
throw new WebApplicationException(Response.status(404).build());
}
return checkDependencyHealth(dependency);
} | [
"public",
"HealthDependencyDto",
"doDependencyAvailabilityCheck",
"(",
"String",
"name",
")",
"{",
"HealthDependency",
"dependency",
"=",
"healthDependencies",
".",
"get",
"(",
"checkNotNull",
"(",
"name",
")",
")",
";",
"if",
"(",
"dependency",
"==",
"null",
")",... | Returns information about a dependency, including the result of checking its health. | [
"Returns",
"information",
"about",
"a",
"dependency",
"including",
"the",
"result",
"of",
"checking",
"its",
"health",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/health/service/src/main/java/com/cerner/beadledom/health/internal/HealthChecker.java#L89-L95 | train |
cerner/beadledom | jaxrs/src/main/java/com/cerner/beadledom/jaxrs/JaxRsParamConditions.java | JaxRsParamConditions.checkParam | public static void checkParam(boolean expression, Object errorMessage) {
if (!expression) {
Response response = Response.status(Response.Status.BAD_REQUEST)
.type(MediaType.TEXT_PLAIN)
.build();
throw new WebApplicationException(String.valueOf(errorMessage), response);
}
} | java | public static void checkParam(boolean expression, Object errorMessage) {
if (!expression) {
Response response = Response.status(Response.Status.BAD_REQUEST)
.type(MediaType.TEXT_PLAIN)
.build();
throw new WebApplicationException(String.valueOf(errorMessage), response);
}
} | [
"public",
"static",
"void",
"checkParam",
"(",
"boolean",
"expression",
",",
"Object",
"errorMessage",
")",
"{",
"if",
"(",
"!",
"expression",
")",
"{",
"Response",
"response",
"=",
"Response",
".",
"status",
"(",
"Response",
".",
"Status",
".",
"BAD_REQUEST... | Ensures the truth of an expression involving a jax-rs parameter.
@param expression a boolean expression
@param errorMessage the exception message to use if the check fails; will
be converted to a string using {@link String#valueOf(Object)}
@throws WebApplicationException with response status 400 if {@code expression} is false | [
"Ensures",
"the",
"truth",
"of",
"an",
"expression",
"involving",
"a",
"jax",
"-",
"rs",
"parameter",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jaxrs/src/main/java/com/cerner/beadledom/jaxrs/JaxRsParamConditions.java#L44-L51 | train |
cerner/beadledom | client/beadledom-client-guice/src/main/java/com/cerner/beadledom/client/BeadledomClientBuilderProvider.java | BeadledomClientBuilderProvider.isExcludedBinding | private boolean isExcludedBinding(Key<?> key) {
Class<?> rawType = key.getTypeLiteral().getRawType();
for (Class<?> excludedClass : excludedBindings) {
if (excludedClass.isAssignableFrom(rawType)) {
return true;
}
}
return false;
} | java | private boolean isExcludedBinding(Key<?> key) {
Class<?> rawType = key.getTypeLiteral().getRawType();
for (Class<?> excludedClass : excludedBindings) {
if (excludedClass.isAssignableFrom(rawType)) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"isExcludedBinding",
"(",
"Key",
"<",
"?",
">",
"key",
")",
"{",
"Class",
"<",
"?",
">",
"rawType",
"=",
"key",
".",
"getTypeLiteral",
"(",
")",
".",
"getRawType",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"excludedClas... | This is to prevent circular dependency during binding resolution in the provider.
As we loop through every binding in the injector, we need to exclude
certain bindings as they havent been created yet. | [
"This",
"is",
"to",
"prevent",
"circular",
"dependency",
"during",
"binding",
"resolution",
"in",
"the",
"provider",
".",
"As",
"we",
"loop",
"through",
"every",
"binding",
"in",
"the",
"injector",
"we",
"need",
"to",
"exclude",
"certain",
"bindings",
"as",
... | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/client/beadledom-client-guice/src/main/java/com/cerner/beadledom/client/BeadledomClientBuilderProvider.java#L121-L130 | train |
cerner/beadledom | jackson/src/main/java/com/cerner/beadledom/jackson/filter/FieldFilter.java | FieldFilter.addField | protected void addField(String field) {
if (field.contains("/")) {
// Splits the field into, at most, 2 strings - "prefix" / "suffix" - since we guarantee the
// field contains a / this will ALWAYS have a length of 2.
String[] fields = field.split("/", 2);
String prefix = fields[0];
// This may be an empty string if the field passed in was "foo/"
String suffix = fields[1];
if ("".equals(suffix)) {
filters.put(prefix, UNFILTERED_FIELD);
return;
}
FieldFilter nestedFilter = filters.get(prefix);
if (filters.containsKey(prefix) && nestedFilter == UNFILTERED_FIELD) {
return;
} else if (nestedFilter == null) {
nestedFilter = new FieldFilter(true);
filters.put(prefix, nestedFilter);
}
nestedFilter.addField(suffix);
} else {
filters.put(field, UNFILTERED_FIELD);
}
} | java | protected void addField(String field) {
if (field.contains("/")) {
// Splits the field into, at most, 2 strings - "prefix" / "suffix" - since we guarantee the
// field contains a / this will ALWAYS have a length of 2.
String[] fields = field.split("/", 2);
String prefix = fields[0];
// This may be an empty string if the field passed in was "foo/"
String suffix = fields[1];
if ("".equals(suffix)) {
filters.put(prefix, UNFILTERED_FIELD);
return;
}
FieldFilter nestedFilter = filters.get(prefix);
if (filters.containsKey(prefix) && nestedFilter == UNFILTERED_FIELD) {
return;
} else if (nestedFilter == null) {
nestedFilter = new FieldFilter(true);
filters.put(prefix, nestedFilter);
}
nestedFilter.addField(suffix);
} else {
filters.put(field, UNFILTERED_FIELD);
}
} | [
"protected",
"void",
"addField",
"(",
"String",
"field",
")",
"{",
"if",
"(",
"field",
".",
"contains",
"(",
"\"/\"",
")",
")",
"{",
"// Splits the field into, at most, 2 strings - \"prefix\" / \"suffix\" - since we guarantee the",
"// field contains a / this will ALWAYS have a... | Adds a field to be filtered for this FieldFilter. | [
"Adds",
"a",
"field",
"to",
"be",
"filtered",
"for",
"this",
"FieldFilter",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jackson/src/main/java/com/cerner/beadledom/jackson/filter/FieldFilter.java#L98-L122 | train |
cerner/beadledom | jackson/src/main/java/com/cerner/beadledom/jackson/filter/FieldFilter.java | FieldFilter.writeJson | public void writeJson(JsonParser parser, JsonGenerator jgen) throws IOException {
checkNotNull(parser, "JsonParser cannot be null for writeJson.");
checkNotNull(jgen, "JsonGenerator cannot be null for writeJson.");
JsonToken curToken = parser.nextToken();
while (curToken != null) {
curToken = processToken(curToken, parser, jgen);
}
jgen.flush();
} | java | public void writeJson(JsonParser parser, JsonGenerator jgen) throws IOException {
checkNotNull(parser, "JsonParser cannot be null for writeJson.");
checkNotNull(jgen, "JsonGenerator cannot be null for writeJson.");
JsonToken curToken = parser.nextToken();
while (curToken != null) {
curToken = processToken(curToken, parser, jgen);
}
jgen.flush();
} | [
"public",
"void",
"writeJson",
"(",
"JsonParser",
"parser",
",",
"JsonGenerator",
"jgen",
")",
"throws",
"IOException",
"{",
"checkNotNull",
"(",
"parser",
",",
"\"JsonParser cannot be null for writeJson.\"",
")",
";",
"checkNotNull",
"(",
"jgen",
",",
"\"JsonGenerato... | Writes the json from the parser onto the generator, using the filters to only write the objects
specified.
@param parser JsonParser that is created from a Jackson utility (i.e. ObjectMapper)
@param jgen JsonGenerator that is used for writing json onto an underlying stream
@throws JsonGenerationException exception if Jackson throws an error while iterating through
the JsonParser
@throws IOException if en error occurs while Jackson is parsing or writing json | [
"Writes",
"the",
"json",
"from",
"the",
"parser",
"onto",
"the",
"generator",
"using",
"the",
"filters",
"to",
"only",
"write",
"the",
"objects",
"specified",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jackson/src/main/java/com/cerner/beadledom/jackson/filter/FieldFilter.java#L145-L153 | train |
cerner/beadledom | jackson/src/main/java/com/cerner/beadledom/jackson/filter/FieldFilter.java | FieldFilter.processValue | private void processValue(JsonToken valueToken, JsonParser parser, JsonGenerator jgen)
throws IOException {
if (valueToken.isBoolean()) {
jgen.writeBoolean(parser.getBooleanValue());
} else if (valueToken.isNumeric()) {
if (parser.getNumberType() == JsonParser.NumberType.INT) {
jgen.writeNumber(parser.getIntValue());
} else if (parser.getNumberType() == JsonParser.NumberType.DOUBLE) {
jgen.writeNumber(parser.getDoubleValue());
} else if (parser.getNumberType() == JsonParser.NumberType.FLOAT) {
jgen.writeNumber(parser.getFloatValue());
} else if (parser.getNumberType() == JsonParser.NumberType.LONG) {
jgen.writeNumber(parser.getLongValue());
} else if (parser.getNumberType() == JsonParser.NumberType.BIG_DECIMAL) {
jgen.writeNumber(parser.getDecimalValue());
} else if (parser.getNumberType() == JsonParser.NumberType.BIG_INTEGER) {
jgen.writeNumber(parser.getBigIntegerValue());
} else {
LOGGER.error("Found unsupported numeric value with name {}.", parser.getCurrentName());
throw new RuntimeException(
"Found unsupported numeric value with name " + parser.getCurrentName());
}
} else if (valueToken.id() == JsonTokenId.ID_STRING) {
jgen.writeString(parser.getText());
} else {
// Something bad just happened. Probably an unsupported type.
LOGGER.error(
"Found unsupported value type {} for name {}.", valueToken.id(), parser.getCurrentName());
throw new RuntimeException(
"Found unsupported value type " + valueToken.id() + " for name " + parser
.getCurrentName());
}
} | java | private void processValue(JsonToken valueToken, JsonParser parser, JsonGenerator jgen)
throws IOException {
if (valueToken.isBoolean()) {
jgen.writeBoolean(parser.getBooleanValue());
} else if (valueToken.isNumeric()) {
if (parser.getNumberType() == JsonParser.NumberType.INT) {
jgen.writeNumber(parser.getIntValue());
} else if (parser.getNumberType() == JsonParser.NumberType.DOUBLE) {
jgen.writeNumber(parser.getDoubleValue());
} else if (parser.getNumberType() == JsonParser.NumberType.FLOAT) {
jgen.writeNumber(parser.getFloatValue());
} else if (parser.getNumberType() == JsonParser.NumberType.LONG) {
jgen.writeNumber(parser.getLongValue());
} else if (parser.getNumberType() == JsonParser.NumberType.BIG_DECIMAL) {
jgen.writeNumber(parser.getDecimalValue());
} else if (parser.getNumberType() == JsonParser.NumberType.BIG_INTEGER) {
jgen.writeNumber(parser.getBigIntegerValue());
} else {
LOGGER.error("Found unsupported numeric value with name {}.", parser.getCurrentName());
throw new RuntimeException(
"Found unsupported numeric value with name " + parser.getCurrentName());
}
} else if (valueToken.id() == JsonTokenId.ID_STRING) {
jgen.writeString(parser.getText());
} else {
// Something bad just happened. Probably an unsupported type.
LOGGER.error(
"Found unsupported value type {} for name {}.", valueToken.id(), parser.getCurrentName());
throw new RuntimeException(
"Found unsupported value type " + valueToken.id() + " for name " + parser
.getCurrentName());
}
} | [
"private",
"void",
"processValue",
"(",
"JsonToken",
"valueToken",
",",
"JsonParser",
"parser",
",",
"JsonGenerator",
"jgen",
")",
"throws",
"IOException",
"{",
"if",
"(",
"valueToken",
".",
"isBoolean",
"(",
")",
")",
"{",
"jgen",
".",
"writeBoolean",
"(",
... | Uses a JsonToken + JsonParser to determine how to write a value to the JsonGenerator.
<p>This separation exists so we can separate the iteration logic from the parsing logic.
@param valueToken current token we are interested in from the parser
@param parser current parser
@param jgen JsonGenerator that is used for writing json onto an underlying stream
@throws JsonGenerationException if access to the JsonParser throws a JsonGenerationException
@throws IOException if the Jackson utilties (JsonParser or JsonGenerator) throw an IOException | [
"Uses",
"a",
"JsonToken",
"+",
"JsonParser",
"to",
"determine",
"how",
"to",
"write",
"a",
"value",
"to",
"the",
"JsonGenerator",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/jackson/src/main/java/com/cerner/beadledom/jackson/filter/FieldFilter.java#L207-L239 | train |
cerner/beadledom | pagination/src/main/java/com/cerner/beadledom/pagination/OffsetPaginationLinks.java | OffsetPaginationLinks.lastLink | String lastLink() {
if (totalResults == null || currentLimit == 0L) {
return null;
}
Long lastOffset;
if (totalResults % currentLimit == 0L) {
lastOffset = totalResults - currentLimit;
} else {
// Truncation due to integral division gives floor-like behavior for free.
lastOffset = totalResults / currentLimit * currentLimit;
}
return urlWithUpdatedPagination(lastOffset, currentLimit);
} | java | String lastLink() {
if (totalResults == null || currentLimit == 0L) {
return null;
}
Long lastOffset;
if (totalResults % currentLimit == 0L) {
lastOffset = totalResults - currentLimit;
} else {
// Truncation due to integral division gives floor-like behavior for free.
lastOffset = totalResults / currentLimit * currentLimit;
}
return urlWithUpdatedPagination(lastOffset, currentLimit);
} | [
"String",
"lastLink",
"(",
")",
"{",
"if",
"(",
"totalResults",
"==",
"null",
"||",
"currentLimit",
"==",
"0L",
")",
"{",
"return",
"null",
";",
"}",
"Long",
"lastOffset",
";",
"if",
"(",
"totalResults",
"%",
"currentLimit",
"==",
"0L",
")",
"{",
"last... | Returns the last page link; null if no last page link is available. | [
"Returns",
"the",
"last",
"page",
"link",
";",
"null",
"if",
"no",
"last",
"page",
"link",
"is",
"available",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/pagination/src/main/java/com/cerner/beadledom/pagination/OffsetPaginationLinks.java#L80-L94 | train |
cerner/beadledom | pagination/src/main/java/com/cerner/beadledom/pagination/OffsetPaginationLinks.java | OffsetPaginationLinks.prevLink | String prevLink() {
if (currentOffset == 0 || currentLimit == 0) {
return null;
}
return urlWithUpdatedPagination(Math.max(0, currentOffset - currentLimit), currentLimit);
} | java | String prevLink() {
if (currentOffset == 0 || currentLimit == 0) {
return null;
}
return urlWithUpdatedPagination(Math.max(0, currentOffset - currentLimit), currentLimit);
} | [
"String",
"prevLink",
"(",
")",
"{",
"if",
"(",
"currentOffset",
"==",
"0",
"||",
"currentLimit",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"return",
"urlWithUpdatedPagination",
"(",
"Math",
".",
"max",
"(",
"0",
",",
"currentOffset",
"-",
"curren... | Returns the next prev link; null if no prev page link is available. | [
"Returns",
"the",
"next",
"prev",
"link",
";",
"null",
"if",
"no",
"prev",
"page",
"link",
"is",
"available",
"."
] | 75435bced5187d5455b46518fadf85c93cf32014 | https://github.com/cerner/beadledom/blob/75435bced5187d5455b46518fadf85c93cf32014/pagination/src/main/java/com/cerner/beadledom/pagination/OffsetPaginationLinks.java#L110-L116 | train |
libgdx/box2dlights | src/box2dLight/RayHandler.java | RayHandler.resizeFBO | public void resizeFBO(int fboWidth, int fboHeight) {
if (lightMap != null) {
lightMap.dispose();
}
lightMap = new LightMap(this, fboWidth, fboHeight);
} | java | public void resizeFBO(int fboWidth, int fboHeight) {
if (lightMap != null) {
lightMap.dispose();
}
lightMap = new LightMap(this, fboWidth, fboHeight);
} | [
"public",
"void",
"resizeFBO",
"(",
"int",
"fboWidth",
",",
"int",
"fboHeight",
")",
"{",
"if",
"(",
"lightMap",
"!=",
"null",
")",
"{",
"lightMap",
".",
"dispose",
"(",
")",
";",
"}",
"lightMap",
"=",
"new",
"LightMap",
"(",
"this",
",",
"fboWidth",
... | Resize the FBO used for intermediate rendering. | [
"Resize",
"the",
"FBO",
"used",
"for",
"intermediate",
"rendering",
"."
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/RayHandler.java#L138-L143 | train |
libgdx/box2dlights | src/box2dLight/RayHandler.java | RayHandler.setCombinedMatrix | public void setCombinedMatrix(OrthographicCamera camera) {
this.setCombinedMatrix(
camera.combined,
camera.position.x,
camera.position.y,
camera.viewportWidth * camera.zoom,
camera.viewportHeight * camera.zoom);
} | java | public void setCombinedMatrix(OrthographicCamera camera) {
this.setCombinedMatrix(
camera.combined,
camera.position.x,
camera.position.y,
camera.viewportWidth * camera.zoom,
camera.viewportHeight * camera.zoom);
} | [
"public",
"void",
"setCombinedMatrix",
"(",
"OrthographicCamera",
"camera",
")",
"{",
"this",
".",
"setCombinedMatrix",
"(",
"camera",
".",
"combined",
",",
"camera",
".",
"position",
".",
"x",
",",
"camera",
".",
"position",
".",
"y",
",",
"camera",
".",
... | Sets combined matrix basing on camera position, rotation and zoom
<p> Same as calling:
{@code setCombinedMatrix(
camera.combined,
camera.position.x,
camera.position.y,
camera.viewportWidth * camera.zoom,
camera.viewportHeight * camera.zoom );}
@see #setCombinedMatrix(Matrix4, float, float, float, float) | [
"Sets",
"combined",
"matrix",
"basing",
"on",
"camera",
"position",
"rotation",
"and",
"zoom"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/RayHandler.java#L158-L165 | train |
libgdx/box2dlights | src/box2dLight/RayHandler.java | RayHandler.prepareRender | public void prepareRender() {
lightRenderedLastFrame = 0;
Gdx.gl.glDepthMask(false);
Gdx.gl.glEnable(GL20.GL_BLEND);
simpleBlendFunc.apply();
boolean useLightMap = (shadows || blur);
if (useLightMap) {
lightMap.frameBuffer.begin();
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
ShaderProgram shader = customLightShader != null ? customLightShader : lightShader;
shader.begin();
{
shader.setUniformMatrix("u_projTrans", combined);
if (customLightShader != null) updateLightShader();
for (Light light : lightList) {
if (customLightShader != null) updateLightShaderPerLight(light);
light.render();
}
}
shader.end();
if (useLightMap) {
if (customViewport) {
lightMap.frameBuffer.end(
viewportX,
viewportY,
viewportWidth,
viewportHeight);
} else {
lightMap.frameBuffer.end();
}
boolean needed = lightRenderedLastFrame > 0;
// this way lot less binding
if (needed && blur)
lightMap.gaussianBlur();
}
} | java | public void prepareRender() {
lightRenderedLastFrame = 0;
Gdx.gl.glDepthMask(false);
Gdx.gl.glEnable(GL20.GL_BLEND);
simpleBlendFunc.apply();
boolean useLightMap = (shadows || blur);
if (useLightMap) {
lightMap.frameBuffer.begin();
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
ShaderProgram shader = customLightShader != null ? customLightShader : lightShader;
shader.begin();
{
shader.setUniformMatrix("u_projTrans", combined);
if (customLightShader != null) updateLightShader();
for (Light light : lightList) {
if (customLightShader != null) updateLightShaderPerLight(light);
light.render();
}
}
shader.end();
if (useLightMap) {
if (customViewport) {
lightMap.frameBuffer.end(
viewportX,
viewportY,
viewportWidth,
viewportHeight);
} else {
lightMap.frameBuffer.end();
}
boolean needed = lightRenderedLastFrame > 0;
// this way lot less binding
if (needed && blur)
lightMap.gaussianBlur();
}
} | [
"public",
"void",
"prepareRender",
"(",
")",
"{",
"lightRenderedLastFrame",
"=",
"0",
";",
"Gdx",
".",
"gl",
".",
"glDepthMask",
"(",
"false",
")",
";",
"Gdx",
".",
"gl",
".",
"glEnable",
"(",
"GL20",
".",
"GL_BLEND",
")",
";",
"simpleBlendFunc",
".",
... | Prepare all lights for rendering.
<p>You should need to use this method only if you want to render lights
on a frame buffer object. Use {@link #render()} otherwise.
<p><b>NOTE!</b> Don't call this inside of any begin/end statements.
@see #renderOnly()
@see #render() | [
"Prepare",
"all",
"lights",
"for",
"rendering",
"."
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/RayHandler.java#L297-L339 | train |
libgdx/box2dlights | src/box2dLight/RayHandler.java | RayHandler.pointAtLight | public boolean pointAtLight(float x, float y) {
for (Light light : lightList) {
if (light.contains(x, y)) return true;
}
return false;
} | java | public boolean pointAtLight(float x, float y) {
for (Light light : lightList) {
if (light.contains(x, y)) return true;
}
return false;
} | [
"public",
"boolean",
"pointAtLight",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"for",
"(",
"Light",
"light",
":",
"lightList",
")",
"{",
"if",
"(",
"light",
".",
"contains",
"(",
"x",
",",
"y",
")",
")",
"return",
"true",
";",
"}",
"return",
... | Checks whether the given point is inside of any light volume
@return true if point is inside of any light volume | [
"Checks",
"whether",
"the",
"given",
"point",
"is",
"inside",
"of",
"any",
"light",
"volume"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/RayHandler.java#L400-L405 | train |
libgdx/box2dlights | src/box2dLight/RayHandler.java | RayHandler.dispose | public void dispose() {
removeAll();
if (lightMap != null) lightMap.dispose();
if (lightShader != null) lightShader.dispose();
} | java | public void dispose() {
removeAll();
if (lightMap != null) lightMap.dispose();
if (lightShader != null) lightShader.dispose();
} | [
"public",
"void",
"dispose",
"(",
")",
"{",
"removeAll",
"(",
")",
";",
"if",
"(",
"lightMap",
"!=",
"null",
")",
"lightMap",
".",
"dispose",
"(",
")",
";",
"if",
"(",
"lightShader",
"!=",
"null",
")",
"lightShader",
".",
"dispose",
"(",
")",
";",
... | Disposes all this rayHandler lights and resources | [
"Disposes",
"all",
"this",
"rayHandler",
"lights",
"and",
"resources"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/RayHandler.java#L422-L426 | train |
libgdx/box2dlights | src/box2dLight/RayHandler.java | RayHandler.removeAll | public void removeAll() {
for (Light light : lightList) {
light.dispose();
}
lightList.clear();
for (Light light : disabledLights) {
light.dispose();
}
disabledLights.clear();
} | java | public void removeAll() {
for (Light light : lightList) {
light.dispose();
}
lightList.clear();
for (Light light : disabledLights) {
light.dispose();
}
disabledLights.clear();
} | [
"public",
"void",
"removeAll",
"(",
")",
"{",
"for",
"(",
"Light",
"light",
":",
"lightList",
")",
"{",
"light",
".",
"dispose",
"(",
")",
";",
"}",
"lightList",
".",
"clear",
"(",
")",
";",
"for",
"(",
"Light",
"light",
":",
"disabledLights",
")",
... | Removes and disposes both all active and disabled lights | [
"Removes",
"and",
"disposes",
"both",
"all",
"active",
"and",
"disabled",
"lights"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/RayHandler.java#L431-L441 | train |
libgdx/box2dlights | src/box2dLight/RayHandler.java | RayHandler.setAmbientLight | public void setAmbientLight(float r, float g, float b, float a) {
this.ambientLight.set(r, g, b, a);
} | java | public void setAmbientLight(float r, float g, float b, float a) {
this.ambientLight.set(r, g, b, a);
} | [
"public",
"void",
"setAmbientLight",
"(",
"float",
"r",
",",
"float",
"g",
",",
"float",
"b",
",",
"float",
"a",
")",
"{",
"this",
".",
"ambientLight",
".",
"set",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
")",
";",
"}"
] | Sets ambient light color.
Specifies how shadows colored and their brightness.
<p>Default = Color(0, 0, 0, 0)
@param r
shadows color red component
@param g
shadows color green component
@param b
shadows color blue component
@param a
shadows brightness component
@see #setAmbientLight(float)
@see #setAmbientLight(Color) | [
"Sets",
"ambient",
"light",
"color",
".",
"Specifies",
"how",
"shadows",
"colored",
"and",
"their",
"brightness",
"."
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/RayHandler.java#L530-L532 | train |
libgdx/box2dlights | src/box2dLight/PointLight.java | PointLight.setDistance | @Override
public void setDistance(float dist) {
dist *= RayHandler.gammaCorrectionParameter;
this.distance = dist < 0.01f ? 0.01f : dist;
dirty = true;
} | java | @Override
public void setDistance(float dist) {
dist *= RayHandler.gammaCorrectionParameter;
this.distance = dist < 0.01f ? 0.01f : dist;
dirty = true;
} | [
"@",
"Override",
"public",
"void",
"setDistance",
"(",
"float",
"dist",
")",
"{",
"dist",
"*=",
"RayHandler",
".",
"gammaCorrectionParameter",
";",
"this",
".",
"distance",
"=",
"dist",
"<",
"0.01f",
"?",
"0.01f",
":",
"dist",
";",
"dirty",
"=",
"true",
... | Sets light distance
<p>MIN value capped to 0.1f meter
<p>Actual recalculations will be done only on {@link #update()} call | [
"Sets",
"light",
"distance"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/PointLight.java#L69-L74 | train |
libgdx/box2dlights | src/box2dLight/Light.java | Light.add | public void add(RayHandler rayHandler) {
this.rayHandler = rayHandler;
if (active) {
rayHandler.lightList.add(this);
} else {
rayHandler.disabledLights.add(this);
}
} | java | public void add(RayHandler rayHandler) {
this.rayHandler = rayHandler;
if (active) {
rayHandler.lightList.add(this);
} else {
rayHandler.disabledLights.add(this);
}
} | [
"public",
"void",
"add",
"(",
"RayHandler",
"rayHandler",
")",
"{",
"this",
".",
"rayHandler",
"=",
"rayHandler",
";",
"if",
"(",
"active",
")",
"{",
"rayHandler",
".",
"lightList",
".",
"add",
"(",
"this",
")",
";",
"}",
"else",
"{",
"rayHandler",
"."... | Adds light to specified RayHandler | [
"Adds",
"light",
"to",
"specified",
"RayHandler"
] | 08cf93a41464f71d32475aaa2fe280dc6af78ff3 | https://github.com/libgdx/box2dlights/blob/08cf93a41464f71d32475aaa2fe280dc6af78ff3/src/box2dLight/Light.java#L200-L207 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.