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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/base/configurablestage/DClusterSourceOffsetCommitter.java | DClusterSourceOffsetCommitter.put | @Override
public Object put(List<Map.Entry> batch) throws InterruptedException {
if (initializeClusterSource()) {
return clusterSource.put(batch);
}
return null;
} | java | @Override
public Object put(List<Map.Entry> batch) throws InterruptedException {
if (initializeClusterSource()) {
return clusterSource.put(batch);
}
return null;
} | [
"@",
"Override",
"public",
"Object",
"put",
"(",
"List",
"<",
"Map",
".",
"Entry",
">",
"batch",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"initializeClusterSource",
"(",
")",
")",
"{",
"return",
"clusterSource",
".",
"put",
"(",
"batch",
")",... | Writes batch of data to the source
@param batch
@throws InterruptedException | [
"Writes",
"batch",
"of",
"data",
"to",
"the",
"source"
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/base/configurablestage/DClusterSourceOffsetCommitter.java#L69-L75 | train |
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/el/ELEval.java | ELEval.eval | public <T> T eval(ELVars vars, String el, Class<T> returnType) throws ELEvalException {
Utils.checkNotNull(vars, "vars");
Utils.checkNotNull(el, "expression");
Utils.checkNotNull(returnType, "returnType");
VARIABLES_IN_SCOPE_TL.set(vars);
try {
return evaluate(vars, el, returnType);
} finally {
VARIABLES_IN_SCOPE_TL.set(null);
}
} | java | public <T> T eval(ELVars vars, String el, Class<T> returnType) throws ELEvalException {
Utils.checkNotNull(vars, "vars");
Utils.checkNotNull(el, "expression");
Utils.checkNotNull(returnType, "returnType");
VARIABLES_IN_SCOPE_TL.set(vars);
try {
return evaluate(vars, el, returnType);
} finally {
VARIABLES_IN_SCOPE_TL.set(null);
}
} | [
"public",
"<",
"T",
">",
"T",
"eval",
"(",
"ELVars",
"vars",
",",
"String",
"el",
",",
"Class",
"<",
"T",
">",
"returnType",
")",
"throws",
"ELEvalException",
"{",
"Utils",
".",
"checkNotNull",
"(",
"vars",
",",
"\"vars\"",
")",
";",
"Utils",
".",
"c... | Evaluates an EL.
@param vars the variables to be available for the evaluation.
@param el the EL string to evaluate.
@param returnType the class the EL evaluates to.
@return the evaluated EL as an instance of the specified return type.
@throws ELEvalException if the EL could not be evaluated. | [
"Evaluates",
"an",
"EL",
"."
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/el/ELEval.java#L67-L77 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java | CTInboxMessageContent.getLinkCopyText | public String getLinkCopyText(JSONObject jsonObject){
if(jsonObject == null) return "";
try {
JSONObject copyObject = jsonObject.has("copyText") ? jsonObject.getJSONObject("copyText") : null;
if(copyObject != null){
return copyObject.has("text") ? copyObject.getString("text") : "";
}else{
return "";
}
} catch (JSONException e) {
Logger.v("Unable to get Link Text with JSON - "+e.getLocalizedMessage());
return "";
}
} | java | public String getLinkCopyText(JSONObject jsonObject){
if(jsonObject == null) return "";
try {
JSONObject copyObject = jsonObject.has("copyText") ? jsonObject.getJSONObject("copyText") : null;
if(copyObject != null){
return copyObject.has("text") ? copyObject.getString("text") : "";
}else{
return "";
}
} catch (JSONException e) {
Logger.v("Unable to get Link Text with JSON - "+e.getLocalizedMessage());
return "";
}
} | [
"public",
"String",
"getLinkCopyText",
"(",
"JSONObject",
"jsonObject",
")",
"{",
"if",
"(",
"jsonObject",
"==",
"null",
")",
"return",
"\"\"",
";",
"try",
"{",
"JSONObject",
"copyObject",
"=",
"jsonObject",
".",
"has",
"(",
"\"copyText\"",
")",
"?",
"jsonOb... | Returns the text for the JSONObject of Link provided
The JSONObject of Link provided should be of the type "copy"
@param jsonObject of Link
@return String | [
"Returns",
"the",
"text",
"for",
"the",
"JSONObject",
"of",
"Link",
"provided",
"The",
"JSONObject",
"of",
"Link",
"provided",
"should",
"be",
"of",
"the",
"type",
"copy"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java#L279-L292 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java | CTInboxMessageContent.getLinkUrl | public String getLinkUrl(JSONObject jsonObject){
if(jsonObject == null) return null;
try {
JSONObject urlObject = jsonObject.has("url") ? jsonObject.getJSONObject("url") : null;
if(urlObject == null) return null;
JSONObject androidObject = urlObject.has("android") ? urlObject.getJSONObject("android") : null;
if(androidObject != null){
return androidObject.has("text") ? androidObject.getString("text") : "";
}else{
return "";
}
} catch (JSONException e) {
Logger.v("Unable to get Link URL with JSON - "+e.getLocalizedMessage());
return null;
}
} | java | public String getLinkUrl(JSONObject jsonObject){
if(jsonObject == null) return null;
try {
JSONObject urlObject = jsonObject.has("url") ? jsonObject.getJSONObject("url") : null;
if(urlObject == null) return null;
JSONObject androidObject = urlObject.has("android") ? urlObject.getJSONObject("android") : null;
if(androidObject != null){
return androidObject.has("text") ? androidObject.getString("text") : "";
}else{
return "";
}
} catch (JSONException e) {
Logger.v("Unable to get Link URL with JSON - "+e.getLocalizedMessage());
return null;
}
} | [
"public",
"String",
"getLinkUrl",
"(",
"JSONObject",
"jsonObject",
")",
"{",
"if",
"(",
"jsonObject",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"JSONObject",
"urlObject",
"=",
"jsonObject",
".",
"has",
"(",
"\"url\"",
")",
"?",
"jsonObject",
".... | Returns the text for the JSONObject of Link provided
The JSONObject of Link provided should be of the type "url"
@param jsonObject of Link
@return String | [
"Returns",
"the",
"text",
"for",
"the",
"JSONObject",
"of",
"Link",
"provided",
"The",
"JSONObject",
"of",
"Link",
"provided",
"should",
"be",
"of",
"the",
"type",
"url"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java#L300-L315 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java | CTInboxMessageContent.getLinkColor | public String getLinkColor(JSONObject jsonObject){
if(jsonObject == null) return null;
try {
return jsonObject.has("color") ? jsonObject.getString("color") : "";
} catch (JSONException e) {
Logger.v("Unable to get Link Text Color with JSON - "+e.getLocalizedMessage());
return null;
}
} | java | public String getLinkColor(JSONObject jsonObject){
if(jsonObject == null) return null;
try {
return jsonObject.has("color") ? jsonObject.getString("color") : "";
} catch (JSONException e) {
Logger.v("Unable to get Link Text Color with JSON - "+e.getLocalizedMessage());
return null;
}
} | [
"public",
"String",
"getLinkColor",
"(",
"JSONObject",
"jsonObject",
")",
"{",
"if",
"(",
"jsonObject",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"jsonObject",
".",
"has",
"(",
"\"color\"",
")",
"?",
"jsonObject",
".",
"getString",
"(... | Returns the text color for the JSONObject of Link provided
@param jsonObject of Link
@return String | [
"Returns",
"the",
"text",
"color",
"for",
"the",
"JSONObject",
"of",
"Link",
"provided"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessageContent.java#L322-L330 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.onActivityCreated | static void onActivityCreated(Activity activity) {
// make sure we have at least the default instance created here.
if (instances == null) {
CleverTapAPI.createInstanceIfAvailable(activity, null);
}
if (instances == null) {
Logger.v("Instances is null in onActivityCreated!");
return;
}
boolean alreadyProcessedByCleverTap = false;
Bundle notification = null;
Uri deepLink = null;
String _accountId = null;
// check for launch deep link
try {
Intent intent = activity.getIntent();
deepLink = intent.getData();
if (deepLink != null) {
Bundle queryArgs = UriHelper.getAllKeyValuePairs(deepLink.toString(), true);
_accountId = queryArgs.getString(Constants.WZRK_ACCT_ID_KEY);
}
} catch (Throwable t) {
// Ignore
}
// check for launch via notification click
try {
notification = activity.getIntent().getExtras();
if (notification != null && !notification.isEmpty()) {
try {
alreadyProcessedByCleverTap = (notification.containsKey(Constants.WZRK_FROM_KEY) && Constants.WZRK_FROM.equals(notification.get(Constants.WZRK_FROM_KEY)));
if (alreadyProcessedByCleverTap){
Logger.v("ActivityLifecycleCallback: Notification Clicked already processed for "+ notification.toString() +", dropping duplicate.");
}
if (notification.containsKey(Constants.WZRK_ACCT_ID_KEY)) {
_accountId = (String) notification.get(Constants.WZRK_ACCT_ID_KEY);
}
} catch (Throwable t) {
// no-op
}
}
} catch (Throwable t) {
// Ignore
}
if (alreadyProcessedByCleverTap && deepLink == null) return;
for (String accountId: CleverTapAPI.instances.keySet()) {
CleverTapAPI instance = CleverTapAPI.instances.get(accountId);
boolean shouldProcess = false;
if (instance != null) {
shouldProcess = (_accountId == null && instance.config.isDefaultInstance()) || instance.getAccountId().equals(_accountId);
}
if (shouldProcess) {
if (notification != null && !notification.isEmpty() && notification.containsKey(Constants.NOTIFICATION_TAG)) {
instance.pushNotificationClickedEvent(notification);
}
if (deepLink != null) {
try {
instance.pushDeepLink(deepLink);
} catch (Throwable t) {
// no-op
}
}
break;
}
}
} | java | static void onActivityCreated(Activity activity) {
// make sure we have at least the default instance created here.
if (instances == null) {
CleverTapAPI.createInstanceIfAvailable(activity, null);
}
if (instances == null) {
Logger.v("Instances is null in onActivityCreated!");
return;
}
boolean alreadyProcessedByCleverTap = false;
Bundle notification = null;
Uri deepLink = null;
String _accountId = null;
// check for launch deep link
try {
Intent intent = activity.getIntent();
deepLink = intent.getData();
if (deepLink != null) {
Bundle queryArgs = UriHelper.getAllKeyValuePairs(deepLink.toString(), true);
_accountId = queryArgs.getString(Constants.WZRK_ACCT_ID_KEY);
}
} catch (Throwable t) {
// Ignore
}
// check for launch via notification click
try {
notification = activity.getIntent().getExtras();
if (notification != null && !notification.isEmpty()) {
try {
alreadyProcessedByCleverTap = (notification.containsKey(Constants.WZRK_FROM_KEY) && Constants.WZRK_FROM.equals(notification.get(Constants.WZRK_FROM_KEY)));
if (alreadyProcessedByCleverTap){
Logger.v("ActivityLifecycleCallback: Notification Clicked already processed for "+ notification.toString() +", dropping duplicate.");
}
if (notification.containsKey(Constants.WZRK_ACCT_ID_KEY)) {
_accountId = (String) notification.get(Constants.WZRK_ACCT_ID_KEY);
}
} catch (Throwable t) {
// no-op
}
}
} catch (Throwable t) {
// Ignore
}
if (alreadyProcessedByCleverTap && deepLink == null) return;
for (String accountId: CleverTapAPI.instances.keySet()) {
CleverTapAPI instance = CleverTapAPI.instances.get(accountId);
boolean shouldProcess = false;
if (instance != null) {
shouldProcess = (_accountId == null && instance.config.isDefaultInstance()) || instance.getAccountId().equals(_accountId);
}
if (shouldProcess) {
if (notification != null && !notification.isEmpty() && notification.containsKey(Constants.NOTIFICATION_TAG)) {
instance.pushNotificationClickedEvent(notification);
}
if (deepLink != null) {
try {
instance.pushDeepLink(deepLink);
} catch (Throwable t) {
// no-op
}
}
break;
}
}
} | [
"static",
"void",
"onActivityCreated",
"(",
"Activity",
"activity",
")",
"{",
"// make sure we have at least the default instance created here.",
"if",
"(",
"instances",
"==",
"null",
")",
"{",
"CleverTapAPI",
".",
"createInstanceIfAvailable",
"(",
"activity",
",",
"null"... | static lifecycle callbacks | [
"static",
"lifecycle",
"callbacks"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L307-L380 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.handleNotificationClicked | static void handleNotificationClicked(Context context,Bundle notification) {
if (notification == null) return;
String _accountId = null;
try {
_accountId = notification.getString(Constants.WZRK_ACCT_ID_KEY);
} catch (Throwable t) {
// no-op
}
if (instances == null) {
CleverTapAPI instance = createInstanceIfAvailable(context, _accountId);
if (instance != null) {
instance.pushNotificationClickedEvent(notification);
}
return;
}
for (String accountId: instances.keySet()) {
CleverTapAPI instance = CleverTapAPI.instances.get(accountId);
boolean shouldProcess = false;
if (instance != null) {
shouldProcess = (_accountId == null && instance.config.isDefaultInstance()) || instance.getAccountId().equals(_accountId);
}
if (shouldProcess) {
instance.pushNotificationClickedEvent(notification);
break;
}
}
} | java | static void handleNotificationClicked(Context context,Bundle notification) {
if (notification == null) return;
String _accountId = null;
try {
_accountId = notification.getString(Constants.WZRK_ACCT_ID_KEY);
} catch (Throwable t) {
// no-op
}
if (instances == null) {
CleverTapAPI instance = createInstanceIfAvailable(context, _accountId);
if (instance != null) {
instance.pushNotificationClickedEvent(notification);
}
return;
}
for (String accountId: instances.keySet()) {
CleverTapAPI instance = CleverTapAPI.instances.get(accountId);
boolean shouldProcess = false;
if (instance != null) {
shouldProcess = (_accountId == null && instance.config.isDefaultInstance()) || instance.getAccountId().equals(_accountId);
}
if (shouldProcess) {
instance.pushNotificationClickedEvent(notification);
break;
}
}
} | [
"static",
"void",
"handleNotificationClicked",
"(",
"Context",
"context",
",",
"Bundle",
"notification",
")",
"{",
"if",
"(",
"notification",
"==",
"null",
")",
"return",
";",
"String",
"_accountId",
"=",
"null",
";",
"try",
"{",
"_accountId",
"=",
"notificati... | other static handlers | [
"other",
"static",
"handlers"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L435-L464 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getInstance | public static @Nullable CleverTapAPI getInstance(Context context) throws CleverTapMetaDataNotFoundException, CleverTapPermissionsNotSatisfied {
// For Google Play Store/Android Studio tracking
sdkVersion = BuildConfig.SDK_VERSION_STRING;
return getDefaultInstance(context);
} | java | public static @Nullable CleverTapAPI getInstance(Context context) throws CleverTapMetaDataNotFoundException, CleverTapPermissionsNotSatisfied {
// For Google Play Store/Android Studio tracking
sdkVersion = BuildConfig.SDK_VERSION_STRING;
return getDefaultInstance(context);
} | [
"public",
"static",
"@",
"Nullable",
"CleverTapAPI",
"getInstance",
"(",
"Context",
"context",
")",
"throws",
"CleverTapMetaDataNotFoundException",
",",
"CleverTapPermissionsNotSatisfied",
"{",
"// For Google Play Store/Android Studio tracking",
"sdkVersion",
"=",
"BuildConfig",
... | Returns an instance of the CleverTap SDK.
@param context The Android context
@return The {@link CleverTapAPI} object
@deprecated use {@link CleverTapAPI#getDefaultInstance(Context context)} | [
"Returns",
"an",
"instance",
"of",
"the",
"CleverTap",
"SDK",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L473-L477 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getDefaultInstance | @SuppressWarnings("WeakerAccess")
public static @Nullable CleverTapAPI getDefaultInstance(Context context) {
// For Google Play Store/Android Studio tracking
sdkVersion = BuildConfig.SDK_VERSION_STRING;
if (defaultConfig == null) {
ManifestInfo manifest = ManifestInfo.getInstance(context);
String accountId = manifest.getAccountId();
String accountToken = manifest.getAcountToken();
String accountRegion = manifest.getAccountRegion();
if(accountId == null || accountToken == null) {
Logger.i("Account ID or Account token is missing from AndroidManifest.xml, unable to create default instance");
return null;
}
if (accountRegion == null) {
Logger.i("Account Region not specified in the AndroidManifest - using default region");
}
defaultConfig = CleverTapInstanceConfig.createDefaultInstance(context, accountId, accountToken, accountRegion);
defaultConfig.setDebugLevel(getDebugLevel());
}
return instanceWithConfig(context, defaultConfig);
} | java | @SuppressWarnings("WeakerAccess")
public static @Nullable CleverTapAPI getDefaultInstance(Context context) {
// For Google Play Store/Android Studio tracking
sdkVersion = BuildConfig.SDK_VERSION_STRING;
if (defaultConfig == null) {
ManifestInfo manifest = ManifestInfo.getInstance(context);
String accountId = manifest.getAccountId();
String accountToken = manifest.getAcountToken();
String accountRegion = manifest.getAccountRegion();
if(accountId == null || accountToken == null) {
Logger.i("Account ID or Account token is missing from AndroidManifest.xml, unable to create default instance");
return null;
}
if (accountRegion == null) {
Logger.i("Account Region not specified in the AndroidManifest - using default region");
}
defaultConfig = CleverTapInstanceConfig.createDefaultInstance(context, accountId, accountToken, accountRegion);
defaultConfig.setDebugLevel(getDebugLevel());
}
return instanceWithConfig(context, defaultConfig);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"static",
"@",
"Nullable",
"CleverTapAPI",
"getDefaultInstance",
"(",
"Context",
"context",
")",
"{",
"// For Google Play Store/Android Studio tracking",
"sdkVersion",
"=",
"BuildConfig",
".",
"SDK_VERSION_STR... | Returns the default shared instance of the CleverTap SDK.
@param context The Android context
@return The {@link CleverTapAPI} object | [
"Returns",
"the",
"default",
"shared",
"instance",
"of",
"the",
"CleverTap",
"SDK",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L485-L505 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.destroySession | private void destroySession() {
currentSessionId = 0;
setAppLaunchPushed(false);
getConfigLogger().verbose(getAccountId(),"Session destroyed; Session ID is now 0");
clearSource();
clearMedium();
clearCampaign();
clearWzrkParams();
} | java | private void destroySession() {
currentSessionId = 0;
setAppLaunchPushed(false);
getConfigLogger().verbose(getAccountId(),"Session destroyed; Session ID is now 0");
clearSource();
clearMedium();
clearCampaign();
clearWzrkParams();
} | [
"private",
"void",
"destroySession",
"(",
")",
"{",
"currentSessionId",
"=",
"0",
";",
"setAppLaunchPushed",
"(",
"false",
")",
";",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"getAccountId",
"(",
")",
",",
"\"Session destroyed; Session ID is now 0\"",
")",... | Destroys the current session | [
"Destroys",
"the",
"current",
"session"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L562-L570 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.FCMGetFreshToken | private String FCMGetFreshToken(final String senderID) {
String token = null;
try {
if(senderID != null){
getConfigLogger().verbose(getAccountId(), "FcmManager: Requesting a FCM token with Sender Id - "+senderID);
token = FirebaseInstanceId.getInstance().getToken(senderID, FirebaseMessaging.INSTANCE_ID_SCOPE);
}else {
getConfigLogger().verbose(getAccountId(), "FcmManager: Requesting a FCM token");
token = FirebaseInstanceId.getInstance().getToken();
}
getConfigLogger().info(getAccountId(),"FCM token: "+token);
} catch (Throwable t) {
getConfigLogger().verbose(getAccountId(), "FcmManager: Error requesting FCM token", t);
}
return token;
} | java | private String FCMGetFreshToken(final String senderID) {
String token = null;
try {
if(senderID != null){
getConfigLogger().verbose(getAccountId(), "FcmManager: Requesting a FCM token with Sender Id - "+senderID);
token = FirebaseInstanceId.getInstance().getToken(senderID, FirebaseMessaging.INSTANCE_ID_SCOPE);
}else {
getConfigLogger().verbose(getAccountId(), "FcmManager: Requesting a FCM token");
token = FirebaseInstanceId.getInstance().getToken();
}
getConfigLogger().info(getAccountId(),"FCM token: "+token);
} catch (Throwable t) {
getConfigLogger().verbose(getAccountId(), "FcmManager: Error requesting FCM token", t);
}
return token;
} | [
"private",
"String",
"FCMGetFreshToken",
"(",
"final",
"String",
"senderID",
")",
"{",
"String",
"token",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"senderID",
"!=",
"null",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"getAccountId",
"(",
... | request token from FCM | [
"request",
"token",
"from",
"FCM"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L789-L804 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.GCMGetFreshToken | private String GCMGetFreshToken(final String senderID) {
getConfigLogger().verbose(getAccountId(), "GcmManager: Requesting a GCM token for Sender ID - " + senderID);
String token = null;
try {
token = InstanceID.getInstance(context)
.getToken(senderID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
getConfigLogger().info(getAccountId(), "GCM token : " + token);
} catch (Throwable t) {
getConfigLogger().verbose(getAccountId(), "GcmManager: Error requesting GCM token", t);
}
return token;
} | java | private String GCMGetFreshToken(final String senderID) {
getConfigLogger().verbose(getAccountId(), "GcmManager: Requesting a GCM token for Sender ID - " + senderID);
String token = null;
try {
token = InstanceID.getInstance(context)
.getToken(senderID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
getConfigLogger().info(getAccountId(), "GCM token : " + token);
} catch (Throwable t) {
getConfigLogger().verbose(getAccountId(), "GcmManager: Error requesting GCM token", t);
}
return token;
} | [
"private",
"String",
"GCMGetFreshToken",
"(",
"final",
"String",
"senderID",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"getAccountId",
"(",
")",
",",
"\"GcmManager: Requesting a GCM token for Sender ID - \"",
"+",
"senderID",
")",
";",
"String",
"t... | request token from GCM | [
"request",
"token",
"from",
"GCM"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L810-L821 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.setOffline | @SuppressWarnings({"unused", "WeakerAccess"})
public void setOffline(boolean value){
offline = value;
if (offline) {
getConfigLogger().debug(getAccountId(), "CleverTap Instance has been set to offline, won't send events queue");
} else {
getConfigLogger().debug(getAccountId(), "CleverTap Instance has been set to online, sending events queue");
flush();
}
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void setOffline(boolean value){
offline = value;
if (offline) {
getConfigLogger().debug(getAccountId(), "CleverTap Instance has been set to offline, won't send events queue");
} else {
getConfigLogger().debug(getAccountId(), "CleverTap Instance has been set to online, sending events queue");
flush();
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"setOffline",
"(",
"boolean",
"value",
")",
"{",
"offline",
"=",
"value",
";",
"if",
"(",
"offline",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"debug",
... | If you want to stop recorded events from being sent to the server, use this method to set the SDK instance to offline.
Once offline, events will be recorded and queued locally but will not be sent to the server until offline is disabled.
Calling this method again with offline set to false will allow events to be sent to server and the SDK instance will immediately attempt to send events that have been queued while offline.
@param value boolean, true sets the sdk offline, false sets the sdk back online | [
"If",
"you",
"want",
"to",
"stop",
"recorded",
"events",
"from",
"being",
"sent",
"to",
"the",
"server",
"use",
"this",
"method",
"to",
"set",
"the",
"SDK",
"instance",
"to",
"offline",
".",
"Once",
"offline",
"events",
"will",
"be",
"recorded",
"and",
"... | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1060-L1069 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.enableDeviceNetworkInfoReporting | @SuppressWarnings({"unused", "WeakerAccess"})
public void enableDeviceNetworkInfoReporting(boolean value){
enableNetworkInfoReporting = value;
StorageHelper.putBoolean(context,storageKeyWithSuffix(Constants.NETWORK_INFO),enableNetworkInfoReporting);
getConfigLogger().verbose(getAccountId(), "Device Network Information reporting set to " + enableNetworkInfoReporting);
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void enableDeviceNetworkInfoReporting(boolean value){
enableNetworkInfoReporting = value;
StorageHelper.putBoolean(context,storageKeyWithSuffix(Constants.NETWORK_INFO),enableNetworkInfoReporting);
getConfigLogger().verbose(getAccountId(), "Device Network Information reporting set to " + enableNetworkInfoReporting);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"enableDeviceNetworkInfoReporting",
"(",
"boolean",
"value",
")",
"{",
"enableNetworkInfoReporting",
"=",
"value",
";",
"StorageHelper",
".",
"putBoolean",
"(",
"co... | Use this method to enable device network-related information tracking, including IP address.
This reporting is disabled by default. To re-disable tracking call this method with enabled set to false.
@param value boolean Whether device network info reporting should be enabled/disabled. | [
"Use",
"this",
"method",
"to",
"enable",
"device",
"network",
"-",
"related",
"information",
"tracking",
"including",
"IP",
"address",
".",
"This",
"reporting",
"is",
"disabled",
"by",
"default",
".",
"To",
"re",
"-",
"disable",
"tracking",
"call",
"this",
"... | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1082-L1087 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getDevicePushToken | @SuppressWarnings("unused")
public String getDevicePushToken(final PushType type) {
switch (type) {
case GCM:
return getCachedGCMToken();
case FCM:
return getCachedFCMToken();
default:
return null;
}
} | java | @SuppressWarnings("unused")
public String getDevicePushToken(final PushType type) {
switch (type) {
case GCM:
return getCachedGCMToken();
case FCM:
return getCachedFCMToken();
default:
return null;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"String",
"getDevicePushToken",
"(",
"final",
"PushType",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"GCM",
":",
"return",
"getCachedGCMToken",
"(",
")",
";",
"case",
"FCM",
":",
"r... | Returns the device push token or null
@param type com.clevertap.android.sdk.PushType (FCM or GCM)
@return String device token or null
NOTE: on initial install calling getDevicePushToken may return null, as the device token is
not yet available
Implement CleverTapAPI.DevicePushTokenRefreshListener to get a callback once the token is
available | [
"Returns",
"the",
"device",
"push",
"token",
"or",
"null"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1205-L1215 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.attachMeta | private void attachMeta(final JSONObject o, final Context context) {
// Memory consumption
try {
o.put("mc", Utils.getMemoryConsumption());
} catch (Throwable t) {
// Ignore
}
// Attach the network type
try {
o.put("nt", Utils.getCurrentNetworkType(context));
} catch (Throwable t) {
// Ignore
}
} | java | private void attachMeta(final JSONObject o, final Context context) {
// Memory consumption
try {
o.put("mc", Utils.getMemoryConsumption());
} catch (Throwable t) {
// Ignore
}
// Attach the network type
try {
o.put("nt", Utils.getCurrentNetworkType(context));
} catch (Throwable t) {
// Ignore
}
} | [
"private",
"void",
"attachMeta",
"(",
"final",
"JSONObject",
"o",
",",
"final",
"Context",
"context",
")",
"{",
"// Memory consumption",
"try",
"{",
"o",
".",
"put",
"(",
"\"mc\"",
",",
"Utils",
".",
"getMemoryConsumption",
"(",
")",
")",
";",
"}",
"catch"... | Attaches meta info about the current state of the device to an event.
Typically, this meta is added only to the ping event. | [
"Attaches",
"meta",
"info",
"about",
"the",
"current",
"state",
"of",
"the",
"device",
"to",
"an",
"event",
".",
"Typically",
"this",
"meta",
"is",
"added",
"only",
"to",
"the",
"ping",
"event",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1490-L1504 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.recordScreen | @SuppressWarnings({"unused", "WeakerAccess"})
public void recordScreen(String screenName){
if(screenName == null || (!currentScreenName.isEmpty() && currentScreenName.equals(screenName))) return;
getConfigLogger().debug(getAccountId(), "Screen changed to " + screenName);
currentScreenName = screenName;
recordPageEventWithExtras(null);
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void recordScreen(String screenName){
if(screenName == null || (!currentScreenName.isEmpty() && currentScreenName.equals(screenName))) return;
getConfigLogger().debug(getAccountId(), "Screen changed to " + screenName);
currentScreenName = screenName;
recordPageEventWithExtras(null);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"recordScreen",
"(",
"String",
"screenName",
")",
"{",
"if",
"(",
"screenName",
"==",
"null",
"||",
"(",
"!",
"currentScreenName",
".",
"isEmpty",
"(",
")",... | Record a Screen View event
@param screenName String, the name of the screen | [
"Record",
"a",
"Screen",
"View",
"event"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1510-L1516 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.clearQueues | private void clearQueues(final Context context) {
synchronized (eventLock) {
DBAdapter adapter = loadDBAdapter(context);
DBAdapter.Table tableName = DBAdapter.Table.EVENTS;
adapter.removeEvents(tableName);
tableName = DBAdapter.Table.PROFILE_EVENTS;
adapter.removeEvents(tableName);
clearUserContext(context);
}
} | java | private void clearQueues(final Context context) {
synchronized (eventLock) {
DBAdapter adapter = loadDBAdapter(context);
DBAdapter.Table tableName = DBAdapter.Table.EVENTS;
adapter.removeEvents(tableName);
tableName = DBAdapter.Table.PROFILE_EVENTS;
adapter.removeEvents(tableName);
clearUserContext(context);
}
} | [
"private",
"void",
"clearQueues",
"(",
"final",
"Context",
"context",
")",
"{",
"synchronized",
"(",
"eventLock",
")",
"{",
"DBAdapter",
"adapter",
"=",
"loadDBAdapter",
"(",
"context",
")",
";",
"DBAdapter",
".",
"Table",
"tableName",
"=",
"DBAdapter",
".",
... | Only call async | [
"Only",
"call",
"async"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1874-L1886 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.updateCursorForDBObject | private QueueCursor updateCursorForDBObject(JSONObject dbObject, QueueCursor cursor) {
if (dbObject == null) return cursor;
Iterator<String> keys = dbObject.keys();
if (keys.hasNext()) {
String key = keys.next();
cursor.setLastId(key);
try {
cursor.setData(dbObject.getJSONArray(key));
} catch (JSONException e) {
cursor.setLastId(null);
cursor.setData(null);
}
}
return cursor;
} | java | private QueueCursor updateCursorForDBObject(JSONObject dbObject, QueueCursor cursor) {
if (dbObject == null) return cursor;
Iterator<String> keys = dbObject.keys();
if (keys.hasNext()) {
String key = keys.next();
cursor.setLastId(key);
try {
cursor.setData(dbObject.getJSONArray(key));
} catch (JSONException e) {
cursor.setLastId(null);
cursor.setData(null);
}
}
return cursor;
} | [
"private",
"QueueCursor",
"updateCursorForDBObject",
"(",
"JSONObject",
"dbObject",
",",
"QueueCursor",
"cursor",
")",
"{",
"if",
"(",
"dbObject",
"==",
"null",
")",
"return",
"cursor",
";",
"Iterator",
"<",
"String",
">",
"keys",
"=",
"dbObject",
".",
"keys",... | helper extracts the cursor data from the db object | [
"helper",
"extracts",
"the",
"cursor",
"data",
"from",
"the",
"db",
"object"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L1981-L1998 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getARP | private JSONObject getARP(final Context context) {
try {
final String nameSpaceKey = getNamespaceARPKey();
if (nameSpaceKey == null) return null;
final SharedPreferences prefs = StorageHelper.getPreferences(context, nameSpaceKey);
final Map<String, ?> all = prefs.getAll();
final Iterator<? extends Map.Entry<String, ?>> iter = all.entrySet().iterator();
while (iter.hasNext()) {
final Map.Entry<String, ?> kv = iter.next();
final Object o = kv.getValue();
if (o instanceof Number && ((Number) o).intValue() == -1) {
iter.remove();
}
}
final JSONObject ret = new JSONObject(all);
getConfigLogger().verbose(getAccountId(), "Fetched ARP for namespace key: " + nameSpaceKey + " values: " + all.toString());
return ret;
} catch (Throwable t) {
getConfigLogger().verbose(getAccountId(), "Failed to construct ARP object", t);
return null;
}
} | java | private JSONObject getARP(final Context context) {
try {
final String nameSpaceKey = getNamespaceARPKey();
if (nameSpaceKey == null) return null;
final SharedPreferences prefs = StorageHelper.getPreferences(context, nameSpaceKey);
final Map<String, ?> all = prefs.getAll();
final Iterator<? extends Map.Entry<String, ?>> iter = all.entrySet().iterator();
while (iter.hasNext()) {
final Map.Entry<String, ?> kv = iter.next();
final Object o = kv.getValue();
if (o instanceof Number && ((Number) o).intValue() == -1) {
iter.remove();
}
}
final JSONObject ret = new JSONObject(all);
getConfigLogger().verbose(getAccountId(), "Fetched ARP for namespace key: " + nameSpaceKey + " values: " + all.toString());
return ret;
} catch (Throwable t) {
getConfigLogger().verbose(getAccountId(), "Failed to construct ARP object", t);
return null;
}
} | [
"private",
"JSONObject",
"getARP",
"(",
"final",
"Context",
"context",
")",
"{",
"try",
"{",
"final",
"String",
"nameSpaceKey",
"=",
"getNamespaceARPKey",
"(",
")",
";",
"if",
"(",
"nameSpaceKey",
"==",
"null",
")",
"return",
"null",
";",
"final",
"SharedPre... | The ARP is additional request parameters, which must be sent once
received after any HTTP call. This is sort of a proxy for cookies.
@return A JSON object containing the ARP key/values. Can be null. | [
"The",
"ARP",
"is",
"additional",
"request",
"parameters",
"which",
"must",
"be",
"sent",
"once",
"received",
"after",
"any",
"HTTP",
"call",
".",
"This",
"is",
"sort",
"of",
"a",
"proxy",
"for",
"cookies",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L2893-L2916 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getTotalVisits | @SuppressWarnings({"unused", "WeakerAccess"})
public int getTotalVisits() {
EventDetail ed = getLocalDataStore().getEventDetail(Constants.APP_LAUNCHED_EVENT);
if (ed != null) return ed.getCount();
return 0;
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public int getTotalVisits() {
EventDetail ed = getLocalDataStore().getEventDetail(Constants.APP_LAUNCHED_EVENT);
if (ed != null) return ed.getCount();
return 0;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"int",
"getTotalVisits",
"(",
")",
"{",
"EventDetail",
"ed",
"=",
"getLocalDataStore",
"(",
")",
".",
"getEventDetail",
"(",
"Constants",
".",
"APP_LAUNCHED_EVENT",
")"... | Returns the total number of times the app has been launched
@return Total number of app launches in int | [
"Returns",
"the",
"total",
"number",
"of",
"times",
"the",
"app",
"has",
"been",
"launched"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3310-L3316 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getTimeElapsed | @SuppressWarnings({"unused", "WeakerAccess"})
public int getTimeElapsed() {
int currentSession = getCurrentSession();
if (currentSession == 0) return -1;
int now = (int) (System.currentTimeMillis() / 1000);
return now - currentSession;
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public int getTimeElapsed() {
int currentSession = getCurrentSession();
if (currentSession == 0) return -1;
int now = (int) (System.currentTimeMillis() / 1000);
return now - currentSession;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"int",
"getTimeElapsed",
"(",
")",
"{",
"int",
"currentSession",
"=",
"getCurrentSession",
"(",
")",
";",
"if",
"(",
"currentSession",
"==",
"0",
")",
"return",
"-"... | Returns the time elapsed by the user on the app
@return Time elapsed by user on the app in int | [
"Returns",
"the",
"time",
"elapsed",
"by",
"the",
"user",
"on",
"the",
"app"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3331-L3338 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getUTMDetails | @SuppressWarnings({"unused", "WeakerAccess"})
public UTMDetail getUTMDetails() {
UTMDetail ud = new UTMDetail();
ud.setSource(source);
ud.setMedium(medium);
ud.setCampaign(campaign);
return ud;
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public UTMDetail getUTMDetails() {
UTMDetail ud = new UTMDetail();
ud.setSource(source);
ud.setMedium(medium);
ud.setCampaign(campaign);
return ud;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"UTMDetail",
"getUTMDetails",
"(",
")",
"{",
"UTMDetail",
"ud",
"=",
"new",
"UTMDetail",
"(",
")",
";",
"ud",
".",
"setSource",
"(",
"source",
")",
";",
"ud",
"... | Returns a UTMDetail object which consists of UTM parameters like source, medium & campaign
@return The {@link UTMDetail} object | [
"Returns",
"a",
"UTMDetail",
"object",
"which",
"consists",
"of",
"UTM",
"parameters",
"like",
"source",
"medium",
"&",
"campaign"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3353-L3360 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI._handleMultiValues | private void _handleMultiValues(ArrayList<String> values, String key, String command) {
if (key == null) return;
if (values == null || values.isEmpty()) {
_generateEmptyMultiValueError(key);
return;
}
ValidationResult vr;
// validate the key
vr = validator.cleanMultiValuePropertyKey(key);
// Check for an error
if (vr.getErrorCode() != 0) {
pushValidationResult(vr);
}
// reset the key
Object _key = vr.getObject();
String cleanKey = (_key != null) ? vr.getObject().toString() : null;
// if key is empty generate an error and return
if (cleanKey == null || cleanKey.isEmpty()) {
_generateInvalidMultiValueKeyError(key);
return;
}
key = cleanKey;
try {
JSONArray currentValues = _constructExistingMultiValue(key, command);
JSONArray newValues = _cleanMultiValues(values, key);
_validateAndPushMultiValue(currentValues, newValues, values, key, command);
} catch (Throwable t) {
getConfigLogger().verbose(getAccountId(), "Error handling multi value operation for key " + key, t);
}
} | java | private void _handleMultiValues(ArrayList<String> values, String key, String command) {
if (key == null) return;
if (values == null || values.isEmpty()) {
_generateEmptyMultiValueError(key);
return;
}
ValidationResult vr;
// validate the key
vr = validator.cleanMultiValuePropertyKey(key);
// Check for an error
if (vr.getErrorCode() != 0) {
pushValidationResult(vr);
}
// reset the key
Object _key = vr.getObject();
String cleanKey = (_key != null) ? vr.getObject().toString() : null;
// if key is empty generate an error and return
if (cleanKey == null || cleanKey.isEmpty()) {
_generateInvalidMultiValueKeyError(key);
return;
}
key = cleanKey;
try {
JSONArray currentValues = _constructExistingMultiValue(key, command);
JSONArray newValues = _cleanMultiValues(values, key);
_validateAndPushMultiValue(currentValues, newValues, values, key, command);
} catch (Throwable t) {
getConfigLogger().verbose(getAccountId(), "Error handling multi value operation for key " + key, t);
}
} | [
"private",
"void",
"_handleMultiValues",
"(",
"ArrayList",
"<",
"String",
">",
"values",
",",
"String",
"key",
",",
"String",
"command",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"return",
";",
"if",
"(",
"values",
"==",
"null",
"||",
"values",
".... | private multi-value handlers and helpers | [
"private",
"multi",
"-",
"value",
"handlers",
"and",
"helpers"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3786-L3824 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.pushEvent | @SuppressWarnings({"unused", "WeakerAccess"})
public void pushEvent(String eventName) {
if (eventName == null || eventName.trim().equals(""))
return;
pushEvent(eventName, null);
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void pushEvent(String eventName) {
if (eventName == null || eventName.trim().equals(""))
return;
pushEvent(eventName, null);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"pushEvent",
"(",
"String",
"eventName",
")",
"{",
"if",
"(",
"eventName",
"==",
"null",
"||",
"eventName",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"... | Pushes a basic event.
@param eventName The name of the event | [
"Pushes",
"a",
"basic",
"event",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L4374-L4380 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.pushNotificationViewedEvent | @SuppressWarnings({"unused", "WeakerAccess"})
public void pushNotificationViewedEvent(Bundle extras){
if (extras == null || extras.isEmpty() || extras.get(Constants.NOTIFICATION_TAG) == null) {
getConfigLogger().debug(getAccountId(), "Push notification: " + (extras == null ? "NULL" : extras.toString()) + " not from CleverTap - will not process Notification Viewed event.");
return;
}
if (!extras.containsKey(Constants.NOTIFICATION_ID_TAG) || (extras.getString(Constants.NOTIFICATION_ID_TAG) == null)) {
getConfigLogger().debug(getAccountId(), "Push notification ID Tag is null, not processing Notification Viewed event for: " + extras.toString());
return;
}
// Check for dupe notification views; if same notficationdId within specified time interval (2 secs) don't process
boolean isDuplicate = checkDuplicateNotificationIds(extras, notificationViewedIdTagMap, Constants.NOTIFICATION_VIEWED_ID_TAG_INTERVAL);
if (isDuplicate) {
getConfigLogger().debug(getAccountId(), "Already processed Notification Viewed event for " + extras.toString() + ", dropping duplicate.");
return;
}
JSONObject event = new JSONObject();
try {
JSONObject notif = getWzrkFields(extras);
event.put("evtName", Constants.NOTIFICATION_VIEWED_EVENT_NAME);
event.put("evtData", notif);
} catch (Throwable ignored) {
//no-op
}
queueEvent(context, event, Constants.RAISED_EVENT);
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void pushNotificationViewedEvent(Bundle extras){
if (extras == null || extras.isEmpty() || extras.get(Constants.NOTIFICATION_TAG) == null) {
getConfigLogger().debug(getAccountId(), "Push notification: " + (extras == null ? "NULL" : extras.toString()) + " not from CleverTap - will not process Notification Viewed event.");
return;
}
if (!extras.containsKey(Constants.NOTIFICATION_ID_TAG) || (extras.getString(Constants.NOTIFICATION_ID_TAG) == null)) {
getConfigLogger().debug(getAccountId(), "Push notification ID Tag is null, not processing Notification Viewed event for: " + extras.toString());
return;
}
// Check for dupe notification views; if same notficationdId within specified time interval (2 secs) don't process
boolean isDuplicate = checkDuplicateNotificationIds(extras, notificationViewedIdTagMap, Constants.NOTIFICATION_VIEWED_ID_TAG_INTERVAL);
if (isDuplicate) {
getConfigLogger().debug(getAccountId(), "Already processed Notification Viewed event for " + extras.toString() + ", dropping duplicate.");
return;
}
JSONObject event = new JSONObject();
try {
JSONObject notif = getWzrkFields(extras);
event.put("evtName", Constants.NOTIFICATION_VIEWED_EVENT_NAME);
event.put("evtData", notif);
} catch (Throwable ignored) {
//no-op
}
queueEvent(context, event, Constants.RAISED_EVENT);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"pushNotificationViewedEvent",
"(",
"Bundle",
"extras",
")",
"{",
"if",
"(",
"extras",
"==",
"null",
"||",
"extras",
".",
"isEmpty",
"(",
")",
"||",
"extras... | Pushes the Notification Viewed event to CleverTap.
@param extras The {@link Bundle} object that contains the
notification details | [
"Pushes",
"the",
"Notification",
"Viewed",
"event",
"to",
"CleverTap",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L4389-L4418 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getCount | @SuppressWarnings({"unused", "WeakerAccess"})
public int getCount(String event) {
EventDetail eventDetail = getLocalDataStore().getEventDetail(event);
if (eventDetail != null) return eventDetail.getCount();
return -1;
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public int getCount(String event) {
EventDetail eventDetail = getLocalDataStore().getEventDetail(event);
if (eventDetail != null) return eventDetail.getCount();
return -1;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"int",
"getCount",
"(",
"String",
"event",
")",
"{",
"EventDetail",
"eventDetail",
"=",
"getLocalDataStore",
"(",
")",
".",
"getEventDetail",
"(",
"event",
")",
";",
... | Returns the total count of the specified event
@param event The event for which you want to get the total count
@return Total count in int | [
"Returns",
"the",
"total",
"count",
"of",
"the",
"specified",
"event"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L4554-L4560 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.pushDeviceToken | private void pushDeviceToken(final String token, final boolean register, final PushType type) {
pushDeviceToken(this.context, token, register, type);
} | java | private void pushDeviceToken(final String token, final boolean register, final PushType type) {
pushDeviceToken(this.context, token, register, type);
} | [
"private",
"void",
"pushDeviceToken",
"(",
"final",
"String",
"token",
",",
"final",
"boolean",
"register",
",",
"final",
"PushType",
"type",
")",
"{",
"pushDeviceToken",
"(",
"this",
".",
"context",
",",
"token",
",",
"register",
",",
"type",
")",
";",
"}... | For internal use, don't call the public API internally | [
"For",
"internal",
"use",
"don",
"t",
"call",
"the",
"public",
"API",
"internally"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L4830-L4832 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getNotificationInfo | @SuppressWarnings({"unused", "WeakerAccess"})
public static NotificationInfo getNotificationInfo(final Bundle extras) {
if (extras == null) return new NotificationInfo(false, false);
boolean fromCleverTap = extras.containsKey(Constants.NOTIFICATION_TAG);
boolean shouldRender = fromCleverTap && extras.containsKey("nm");
return new NotificationInfo(fromCleverTap, shouldRender);
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public static NotificationInfo getNotificationInfo(final Bundle extras) {
if (extras == null) return new NotificationInfo(false, false);
boolean fromCleverTap = extras.containsKey(Constants.NOTIFICATION_TAG);
boolean shouldRender = fromCleverTap && extras.containsKey("nm");
return new NotificationInfo(fromCleverTap, shouldRender);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"static",
"NotificationInfo",
"getNotificationInfo",
"(",
"final",
"Bundle",
"extras",
")",
"{",
"if",
"(",
"extras",
"==",
"null",
")",
"return",
"new",
"NotificationI... | Checks whether this notification is from CleverTap.
@param extras The payload from the GCM intent
@return See {@link NotificationInfo} | [
"Checks",
"whether",
"this",
"notification",
"is",
"from",
"CleverTap",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5092-L5099 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.pushInstallReferrer | @SuppressWarnings({"unused", "WeakerAccess"})
public void pushInstallReferrer(Intent intent) {
try {
final Bundle extras = intent.getExtras();
// Preliminary checks
if (extras == null || !extras.containsKey("referrer")) {
return;
}
final String url;
try {
url = URLDecoder.decode(extras.getString("referrer"), "UTF-8");
getConfigLogger().verbose(getAccountId(), "Referrer received: " + url);
} catch (Throwable e) {
// Could not decode
return;
}
if (url == null) {
return;
}
int now = (int) (System.currentTimeMillis() / 1000);
if (installReferrerMap.containsKey(url) && now - installReferrerMap.get(url) < 10) {
getConfigLogger().verbose(getAccountId(),"Skipping install referrer due to duplicate within 10 seconds");
return;
}
installReferrerMap.put(url, now);
Uri uri = Uri.parse("wzrk://track?install=true&" + url);
pushDeepLink(uri, true);
} catch (Throwable t) {
// no-op
}
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void pushInstallReferrer(Intent intent) {
try {
final Bundle extras = intent.getExtras();
// Preliminary checks
if (extras == null || !extras.containsKey("referrer")) {
return;
}
final String url;
try {
url = URLDecoder.decode(extras.getString("referrer"), "UTF-8");
getConfigLogger().verbose(getAccountId(), "Referrer received: " + url);
} catch (Throwable e) {
// Could not decode
return;
}
if (url == null) {
return;
}
int now = (int) (System.currentTimeMillis() / 1000);
if (installReferrerMap.containsKey(url) && now - installReferrerMap.get(url) < 10) {
getConfigLogger().verbose(getAccountId(),"Skipping install referrer due to duplicate within 10 seconds");
return;
}
installReferrerMap.put(url, now);
Uri uri = Uri.parse("wzrk://track?install=true&" + url);
pushDeepLink(uri, true);
} catch (Throwable t) {
// no-op
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"pushInstallReferrer",
"(",
"Intent",
"intent",
")",
"{",
"try",
"{",
"final",
"Bundle",
"extras",
"=",
"intent",
".",
"getExtras",
"(",
")",
";",
"// Preli... | This method is used to push install referrer via Intent
@param intent An Intent with the install referrer parameters | [
"This",
"method",
"is",
"used",
"to",
"push",
"install",
"referrer",
"via",
"Intent"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5896-L5931 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.pushInstallReferrer | @SuppressWarnings({"unused", "WeakerAccess"})
public synchronized void pushInstallReferrer(String source, String medium, String campaign) {
if (source == null && medium == null && campaign == null) return;
try {
// If already pushed, don't send it again
int status = StorageHelper.getInt(context, "app_install_status", 0);
if (status != 0) {
Logger.d("Install referrer has already been set. Will not override it");
return;
}
StorageHelper.putInt(context, "app_install_status", 1);
if (source != null) source = Uri.encode(source);
if (medium != null) medium = Uri.encode(medium);
if (campaign != null) campaign = Uri.encode(campaign);
String uriStr = "wzrk://track?install=true";
if (source != null) uriStr += "&utm_source=" + source;
if (medium != null) uriStr += "&utm_medium=" + medium;
if (campaign != null) uriStr += "&utm_campaign=" + campaign;
Uri uri = Uri.parse(uriStr);
pushDeepLink(uri, true);
} catch (Throwable t) {
Logger.v("Failed to push install referrer", t);
}
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public synchronized void pushInstallReferrer(String source, String medium, String campaign) {
if (source == null && medium == null && campaign == null) return;
try {
// If already pushed, don't send it again
int status = StorageHelper.getInt(context, "app_install_status", 0);
if (status != 0) {
Logger.d("Install referrer has already been set. Will not override it");
return;
}
StorageHelper.putInt(context, "app_install_status", 1);
if (source != null) source = Uri.encode(source);
if (medium != null) medium = Uri.encode(medium);
if (campaign != null) campaign = Uri.encode(campaign);
String uriStr = "wzrk://track?install=true";
if (source != null) uriStr += "&utm_source=" + source;
if (medium != null) uriStr += "&utm_medium=" + medium;
if (campaign != null) uriStr += "&utm_campaign=" + campaign;
Uri uri = Uri.parse(uriStr);
pushDeepLink(uri, true);
} catch (Throwable t) {
Logger.v("Failed to push install referrer", t);
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"synchronized",
"void",
"pushInstallReferrer",
"(",
"String",
"source",
",",
"String",
"medium",
",",
"String",
"campaign",
")",
"{",
"if",
"(",
"source",
"==",
"null... | This method is used to push install referrer via UTM source, medium & campaign parameters
@param source The UTM source parameter
@param medium The UTM medium parameter
@param campaign The UTM campaign parameter | [
"This",
"method",
"is",
"used",
"to",
"push",
"install",
"referrer",
"via",
"UTM",
"source",
"medium",
"&",
"campaign",
"parameters"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5939-L5965 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.changeCredentials | @SuppressWarnings("unused")
public static void changeCredentials(String accountID, String token) {
changeCredentials(accountID, token, null);
} | java | @SuppressWarnings("unused")
public static void changeCredentials(String accountID, String token) {
changeCredentials(accountID, token, null);
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"static",
"void",
"changeCredentials",
"(",
"String",
"accountID",
",",
"String",
"token",
")",
"{",
"changeCredentials",
"(",
"accountID",
",",
"token",
",",
"null",
")",
";",
"}"
] | This method is used to change the credentials of CleverTap account Id and token programmatically
@param accountID CleverTap Account Id
@param token CleverTap Account Token | [
"This",
"method",
"is",
"used",
"to",
"change",
"the",
"credentials",
"of",
"CleverTap",
"account",
"Id",
"and",
"token",
"programmatically"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5972-L5975 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.changeCredentials | @SuppressWarnings({"unused", "WeakerAccess"})
public static void changeCredentials(String accountID, String token, String region) {
if(defaultConfig != null){
Logger.i("CleverTap SDK already initialized with accountID:"+defaultConfig.getAccountId()
+" and token:"+defaultConfig.getAccountToken()+". Cannot change credentials to "
+ accountID + " and " + token);
return;
}
ManifestInfo.changeCredentials(accountID,token,region);
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public static void changeCredentials(String accountID, String token, String region) {
if(defaultConfig != null){
Logger.i("CleverTap SDK already initialized with accountID:"+defaultConfig.getAccountId()
+" and token:"+defaultConfig.getAccountToken()+". Cannot change credentials to "
+ accountID + " and " + token);
return;
}
ManifestInfo.changeCredentials(accountID,token,region);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"static",
"void",
"changeCredentials",
"(",
"String",
"accountID",
",",
"String",
"token",
",",
"String",
"region",
")",
"{",
"if",
"(",
"defaultConfig",
"!=",
"null"... | This method is used to change the credentials of CleverTap account Id, token and region programmatically
@param accountID CleverTap Account Id
@param token CleverTap Account Token
@param region Clever Tap Account Region | [
"This",
"method",
"is",
"used",
"to",
"change",
"the",
"credentials",
"of",
"CleverTap",
"account",
"Id",
"token",
"and",
"region",
"programmatically"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L5983-L5993 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getInboxMessageCount | @SuppressWarnings({"unused", "WeakerAccess"})
public int getInboxMessageCount(){
synchronized (inboxControllerLock) {
if (this.ctInboxController != null) {
return ctInboxController.count();
} else {
getConfigLogger().debug(getAccountId(),"Notification Inbox not initialized");
return -1;
}
}
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public int getInboxMessageCount(){
synchronized (inboxControllerLock) {
if (this.ctInboxController != null) {
return ctInboxController.count();
} else {
getConfigLogger().debug(getAccountId(),"Notification Inbox not initialized");
return -1;
}
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"int",
"getInboxMessageCount",
"(",
")",
"{",
"synchronized",
"(",
"inboxControllerLock",
")",
"{",
"if",
"(",
"this",
".",
"ctInboxController",
"!=",
"null",
")",
"{... | Returns the count of all inbox messages for the user
@return int - count of all inbox messages | [
"Returns",
"the",
"count",
"of",
"all",
"inbox",
"messages",
"for",
"the",
"user"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L6187-L6197 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.getInboxMessageUnreadCount | @SuppressWarnings({"unused", "WeakerAccess"})
public int getInboxMessageUnreadCount(){
synchronized (inboxControllerLock) {
if (this.ctInboxController != null) {
return ctInboxController.unreadCount();
} else {
getConfigLogger().debug(getAccountId(), "Notification Inbox not initialized");
return -1;
}
}
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public int getInboxMessageUnreadCount(){
synchronized (inboxControllerLock) {
if (this.ctInboxController != null) {
return ctInboxController.unreadCount();
} else {
getConfigLogger().debug(getAccountId(), "Notification Inbox not initialized");
return -1;
}
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"int",
"getInboxMessageUnreadCount",
"(",
")",
"{",
"synchronized",
"(",
"inboxControllerLock",
")",
"{",
"if",
"(",
"this",
".",
"ctInboxController",
"!=",
"null",
")"... | Returns the count of total number of unread inbox messages for the user
@return int - count of all unread messages | [
"Returns",
"the",
"count",
"of",
"total",
"number",
"of",
"unread",
"inbox",
"messages",
"for",
"the",
"user"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L6203-L6213 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.markReadInboxMessage | @SuppressWarnings({"unused", "WeakerAccess"})
public void markReadInboxMessage(final CTInboxMessage message){
postAsyncSafely("markReadInboxMessage", new Runnable() {
@Override
public void run() {
synchronized (inboxControllerLock) {
if(ctInboxController != null){
boolean read = ctInboxController.markReadForMessageWithId(message.getMessageId());
if (read) {
_notifyInboxMessagesDidUpdate();
}
} else {
getConfigLogger().debug(getAccountId(),"Notification Inbox not initialized");
}
}
}
});
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void markReadInboxMessage(final CTInboxMessage message){
postAsyncSafely("markReadInboxMessage", new Runnable() {
@Override
public void run() {
synchronized (inboxControllerLock) {
if(ctInboxController != null){
boolean read = ctInboxController.markReadForMessageWithId(message.getMessageId());
if (read) {
_notifyInboxMessagesDidUpdate();
}
} else {
getConfigLogger().debug(getAccountId(),"Notification Inbox not initialized");
}
}
}
});
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"markReadInboxMessage",
"(",
"final",
"CTInboxMessage",
"message",
")",
"{",
"postAsyncSafely",
"(",
"\"markReadInboxMessage\"",
",",
"new",
"Runnable",
"(",
")",
... | marks the message as read | [
"marks",
"the",
"message",
"as",
"read"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L6260-L6277 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java | GifDecoder.advance | boolean advance() {
if (header.frameCount <= 0) {
return false;
}
if(framePointer == getFrameCount() - 1) {
loopIndex++;
}
if(header.loopCount != LOOP_FOREVER && loopIndex > header.loopCount) {
return false;
}
framePointer = (framePointer + 1) % header.frameCount;
return true;
} | java | boolean advance() {
if (header.frameCount <= 0) {
return false;
}
if(framePointer == getFrameCount() - 1) {
loopIndex++;
}
if(header.loopCount != LOOP_FOREVER && loopIndex > header.loopCount) {
return false;
}
framePointer = (framePointer + 1) % header.frameCount;
return true;
} | [
"boolean",
"advance",
"(",
")",
"{",
"if",
"(",
"header",
".",
"frameCount",
"<=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"framePointer",
"==",
"getFrameCount",
"(",
")",
"-",
"1",
")",
"{",
"loopIndex",
"++",
";",
"}",
"if",
"(",
... | Move the animation frame counter forward.
@return boolean specifying if animation should continue or if loopCount has been fulfilled. | [
"Move",
"the",
"animation",
"frame",
"counter",
"forward",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L219-L234 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java | GifDecoder.getDelay | int getDelay(int n) {
int delay = -1;
if ((n >= 0) && (n < header.frameCount)) {
delay = header.frames.get(n).delay;
}
return delay;
} | java | int getDelay(int n) {
int delay = -1;
if ((n >= 0) && (n < header.frameCount)) {
delay = header.frames.get(n).delay;
}
return delay;
} | [
"int",
"getDelay",
"(",
"int",
"n",
")",
"{",
"int",
"delay",
"=",
"-",
"1",
";",
"if",
"(",
"(",
"n",
">=",
"0",
")",
"&&",
"(",
"n",
"<",
"header",
".",
"frameCount",
")",
")",
"{",
"delay",
"=",
"header",
".",
"frames",
".",
"get",
"(",
... | Gets display duration for specified frame.
@param n int index of frame.
@return delay in milliseconds. | [
"Gets",
"display",
"duration",
"for",
"specified",
"frame",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L242-L248 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java | GifDecoder.setFrameIndex | boolean setFrameIndex(int frame) {
if(frame < INITIAL_FRAME_POINTER || frame >= getFrameCount()) {
return false;
}
framePointer = frame;
return true;
} | java | boolean setFrameIndex(int frame) {
if(frame < INITIAL_FRAME_POINTER || frame >= getFrameCount()) {
return false;
}
framePointer = frame;
return true;
} | [
"boolean",
"setFrameIndex",
"(",
"int",
"frame",
")",
"{",
"if",
"(",
"frame",
"<",
"INITIAL_FRAME_POINTER",
"||",
"frame",
">=",
"getFrameCount",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"framePointer",
"=",
"frame",
";",
"return",
"true",
";",
... | Sets the frame pointer to a specific frame
@return boolean true if the move was successful | [
"Sets",
"the",
"frame",
"pointer",
"to",
"a",
"specific",
"frame"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L284-L290 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java | GifDecoder.read | int read(InputStream is, int contentLength) {
if (is != null) {
try {
int capacity = (contentLength > 0) ? (contentLength + 4096) : 16384;
ByteArrayOutputStream buffer = new ByteArrayOutputStream(capacity);
int nRead;
byte[] data = new byte[16384];
while ((nRead = is.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
read(buffer.toByteArray());
} catch (IOException e) {
Logger.d(TAG, "Error reading data from stream", e);
}
} else {
status = STATUS_OPEN_ERROR;
}
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
Logger.d(TAG, "Error closing stream", e);
}
return status;
} | java | int read(InputStream is, int contentLength) {
if (is != null) {
try {
int capacity = (contentLength > 0) ? (contentLength + 4096) : 16384;
ByteArrayOutputStream buffer = new ByteArrayOutputStream(capacity);
int nRead;
byte[] data = new byte[16384];
while ((nRead = is.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
read(buffer.toByteArray());
} catch (IOException e) {
Logger.d(TAG, "Error reading data from stream", e);
}
} else {
status = STATUS_OPEN_ERROR;
}
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
Logger.d(TAG, "Error closing stream", e);
}
return status;
} | [
"int",
"read",
"(",
"InputStream",
"is",
",",
"int",
"contentLength",
")",
"{",
"if",
"(",
"is",
"!=",
"null",
")",
"{",
"try",
"{",
"int",
"capacity",
"=",
"(",
"contentLength",
">",
"0",
")",
"?",
"(",
"contentLength",
"+",
"4096",
")",
":",
"163... | Reads GIF image from stream.
@param is containing GIF file.
@return read status code (0 = no errors). | [
"Reads",
"GIF",
"image",
"from",
"stream",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L388-L417 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java | GifDecoder.read | synchronized int read(byte[] data) {
this.header = getHeaderParser().setData(data).parseHeader();
if (data != null) {
setData(header, data);
}
return status;
} | java | synchronized int read(byte[] data) {
this.header = getHeaderParser().setData(data).parseHeader();
if (data != null) {
setData(header, data);
}
return status;
} | [
"synchronized",
"int",
"read",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"this",
".",
"header",
"=",
"getHeaderParser",
"(",
")",
".",
"setData",
"(",
"data",
")",
".",
"parseHeader",
"(",
")",
";",
"if",
"(",
"data",
"!=",
"null",
")",
"{",
"setDat... | Reads GIF image from byte array.
@param data containing GIF file.
@return read status code (0 = no errors). | [
"Reads",
"GIF",
"image",
"from",
"byte",
"array",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L496-L503 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java | GifDecoder.readChunkIfNeeded | private void readChunkIfNeeded() {
if (workBufferSize > workBufferPosition) {
return;
}
if (workBuffer == null) {
workBuffer = bitmapProvider.obtainByteArray(WORK_BUFFER_SIZE);
}
workBufferPosition = 0;
workBufferSize = Math.min(rawData.remaining(), WORK_BUFFER_SIZE);
rawData.get(workBuffer, 0, workBufferSize);
} | java | private void readChunkIfNeeded() {
if (workBufferSize > workBufferPosition) {
return;
}
if (workBuffer == null) {
workBuffer = bitmapProvider.obtainByteArray(WORK_BUFFER_SIZE);
}
workBufferPosition = 0;
workBufferSize = Math.min(rawData.remaining(), WORK_BUFFER_SIZE);
rawData.get(workBuffer, 0, workBufferSize);
} | [
"private",
"void",
"readChunkIfNeeded",
"(",
")",
"{",
"if",
"(",
"workBufferSize",
">",
"workBufferPosition",
")",
"{",
"return",
";",
"}",
"if",
"(",
"workBuffer",
"==",
"null",
")",
"{",
"workBuffer",
"=",
"bitmapProvider",
".",
"obtainByteArray",
"(",
"W... | Reads the next chunk for the intermediate work buffer. | [
"Reads",
"the",
"next",
"chunk",
"for",
"the",
"intermediate",
"work",
"buffer",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifDecoder.java#L838-L848 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/ActivityLifecycleCallback.java | ActivityLifecycleCallback.register | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static synchronized void register(android.app.Application application) {
if (application == null) {
Logger.i("Application instance is null/system API is too old");
return;
}
if (registered) {
Logger.v("Lifecycle callbacks have already been registered");
return;
}
registered = true;
application.registerActivityLifecycleCallbacks(
new android.app.Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
CleverTapAPI.onActivityCreated(activity);
}
@Override
public void onActivityStarted(Activity activity) {}
@Override
public void onActivityResumed(Activity activity) {
CleverTapAPI.onActivityResumed(activity);
}
@Override
public void onActivityPaused(Activity activity) {
CleverTapAPI.onActivityPaused();
}
@Override
public void onActivityStopped(Activity activity) {}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {}
@Override
public void onActivityDestroyed(Activity activity) {}
}
);
Logger.i("Activity Lifecycle Callback successfully registered");
} | java | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static synchronized void register(android.app.Application application) {
if (application == null) {
Logger.i("Application instance is null/system API is too old");
return;
}
if (registered) {
Logger.v("Lifecycle callbacks have already been registered");
return;
}
registered = true;
application.registerActivityLifecycleCallbacks(
new android.app.Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
CleverTapAPI.onActivityCreated(activity);
}
@Override
public void onActivityStarted(Activity activity) {}
@Override
public void onActivityResumed(Activity activity) {
CleverTapAPI.onActivityResumed(activity);
}
@Override
public void onActivityPaused(Activity activity) {
CleverTapAPI.onActivityPaused();
}
@Override
public void onActivityStopped(Activity activity) {}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {}
@Override
public void onActivityDestroyed(Activity activity) {}
}
);
Logger.i("Activity Lifecycle Callback successfully registered");
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"ICE_CREAM_SANDWICH",
")",
"public",
"static",
"synchronized",
"void",
"register",
"(",
"android",
".",
"app",
".",
"Application",
"application",
")",
"{",
"if",
"(",
"application",
"==",
"null",
")",
... | Enables lifecycle callbacks for Android devices
@param application App's Application object | [
"Enables",
"lifecycle",
"callbacks",
"for",
"Android",
"devices"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/ActivityLifecycleCallback.java#L19-L65 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java | Validator.cleanObjectKey | ValidationResult cleanObjectKey(String name) {
ValidationResult vr = new ValidationResult();
name = name.trim();
for (String x : objectKeyCharsNotAllowed)
name = name.replace(x, "");
if (name.length() > Constants.MAX_KEY_LENGTH) {
name = name.substring(0, Constants.MAX_KEY_LENGTH-1);
vr.setErrorDesc(name.trim() + "... exceeds the limit of "+ Constants.MAX_KEY_LENGTH + " characters. Trimmed");
vr.setErrorCode(520);
}
vr.setObject(name.trim());
return vr;
} | java | ValidationResult cleanObjectKey(String name) {
ValidationResult vr = new ValidationResult();
name = name.trim();
for (String x : objectKeyCharsNotAllowed)
name = name.replace(x, "");
if (name.length() > Constants.MAX_KEY_LENGTH) {
name = name.substring(0, Constants.MAX_KEY_LENGTH-1);
vr.setErrorDesc(name.trim() + "... exceeds the limit of "+ Constants.MAX_KEY_LENGTH + " characters. Trimmed");
vr.setErrorCode(520);
}
vr.setObject(name.trim());
return vr;
} | [
"ValidationResult",
"cleanObjectKey",
"(",
"String",
"name",
")",
"{",
"ValidationResult",
"vr",
"=",
"new",
"ValidationResult",
"(",
")",
";",
"name",
"=",
"name",
".",
"trim",
"(",
")",
";",
"for",
"(",
"String",
"x",
":",
"objectKeyCharsNotAllowed",
")",
... | Cleans the object key.
@param name Name of the object key
@return The {@link ValidationResult} object containing the object,
and the error code(if any) | [
"Cleans",
"the",
"object",
"key",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java#L75-L90 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java | Validator.cleanMultiValuePropertyKey | ValidationResult cleanMultiValuePropertyKey(String name) {
ValidationResult vr = cleanObjectKey(name);
name = (String) vr.getObject();
// make sure its not a known property key (reserved in the case of multi-value)
try {
RestrictedMultiValueFields rf = RestrictedMultiValueFields.valueOf(name);
//noinspection ConstantConditions
if (rf != null) {
vr.setErrorDesc(name + "... is a restricted key for multi-value properties. Operation aborted.");
vr.setErrorCode(523);
vr.setObject(null);
}
} catch (Throwable t) {
//no-op
}
return vr;
} | java | ValidationResult cleanMultiValuePropertyKey(String name) {
ValidationResult vr = cleanObjectKey(name);
name = (String) vr.getObject();
// make sure its not a known property key (reserved in the case of multi-value)
try {
RestrictedMultiValueFields rf = RestrictedMultiValueFields.valueOf(name);
//noinspection ConstantConditions
if (rf != null) {
vr.setErrorDesc(name + "... is a restricted key for multi-value properties. Operation aborted.");
vr.setErrorCode(523);
vr.setObject(null);
}
} catch (Throwable t) {
//no-op
}
return vr;
} | [
"ValidationResult",
"cleanMultiValuePropertyKey",
"(",
"String",
"name",
")",
"{",
"ValidationResult",
"vr",
"=",
"cleanObjectKey",
"(",
"name",
")",
";",
"name",
"=",
"(",
"String",
")",
"vr",
".",
"getObject",
"(",
")",
";",
"// make sure its not a known propert... | Cleans a multi-value property key.
@param name Name of the property key
@return The {@link ValidationResult} object containing the key,
and the error code(if any)
<p/>
First calls cleanObjectKey
Known property keys are reserved for multi-value properties, subsequent validation is done for those | [
"Cleans",
"a",
"multi",
"-",
"value",
"property",
"key",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java#L102-L122 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java | Validator.isRestrictedEventName | ValidationResult isRestrictedEventName(String name) {
ValidationResult error = new ValidationResult();
if (name == null) {
error.setErrorCode(510);
error.setErrorDesc("Event Name is null");
return error;
}
for (String x : restrictedNames)
if (name.equalsIgnoreCase(x)) {
// The event name is restricted
error.setErrorCode(513);
error.setErrorDesc(name + " is a restricted event name. Last event aborted.");
Logger.v(name + " is a restricted system event name. Last event aborted.");
return error;
}
return error;
} | java | ValidationResult isRestrictedEventName(String name) {
ValidationResult error = new ValidationResult();
if (name == null) {
error.setErrorCode(510);
error.setErrorDesc("Event Name is null");
return error;
}
for (String x : restrictedNames)
if (name.equalsIgnoreCase(x)) {
// The event name is restricted
error.setErrorCode(513);
error.setErrorDesc(name + " is a restricted event name. Last event aborted.");
Logger.v(name + " is a restricted system event name. Last event aborted.");
return error;
}
return error;
} | [
"ValidationResult",
"isRestrictedEventName",
"(",
"String",
"name",
")",
"{",
"ValidationResult",
"error",
"=",
"new",
"ValidationResult",
"(",
")",
";",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"error",
".",
"setErrorCode",
"(",
"510",
")",
";",
"error",
... | Checks whether the specified event name is restricted. If it is,
then create a pending error, and abort.
@param name The event name
@return Boolean indication whether the event name is restricted | [
"Checks",
"whether",
"the",
"specified",
"event",
"name",
"is",
"restricted",
".",
"If",
"it",
"is",
"then",
"create",
"a",
"pending",
"error",
"and",
"abort",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java#L290-L307 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java | Validator._mergeListInternalForKey | private ValidationResult _mergeListInternalForKey(String key, JSONArray left,
JSONArray right, boolean remove, ValidationResult vr) {
if (left == null) {
vr.setObject(null);
return vr;
}
if (right == null) {
vr.setObject(left);
return vr;
}
int maxValNum = Constants.MAX_MULTI_VALUE_ARRAY_LENGTH;
JSONArray mergedList = new JSONArray();
HashSet<String> set = new HashSet<>();
int lsize = left.length(), rsize = right.length();
BitSet dupSetForAdd = null;
if (!remove)
dupSetForAdd = new BitSet(lsize + rsize);
int lidx = 0;
int ridx = scan(right, set, dupSetForAdd, lsize);
if (!remove && set.size() < maxValNum) {
lidx = scan(left, set, dupSetForAdd, 0);
}
for (int i = lidx; i < lsize; i++) {
try {
if (remove) {
String _j = (String) left.get(i);
if (!set.contains(_j)) {
mergedList.put(_j);
}
} else if (!dupSetForAdd.get(i)) {
mergedList.put(left.get(i));
}
} catch (Throwable t) {
//no-op
}
}
if (!remove && mergedList.length() < maxValNum) {
for (int i = ridx; i < rsize; i++) {
try {
if (!dupSetForAdd.get(i + lsize)) {
mergedList.put(right.get(i));
}
} catch (Throwable t) {
//no-op
}
}
}
// check to see if the list got trimmed in the merge
if (ridx > 0 || lidx > 0) {
vr.setErrorDesc("Multi value property for key " + key + " exceeds the limit of " + maxValNum + " items. Trimmed");
vr.setErrorCode(521);
}
vr.setObject(mergedList);
return vr;
} | java | private ValidationResult _mergeListInternalForKey(String key, JSONArray left,
JSONArray right, boolean remove, ValidationResult vr) {
if (left == null) {
vr.setObject(null);
return vr;
}
if (right == null) {
vr.setObject(left);
return vr;
}
int maxValNum = Constants.MAX_MULTI_VALUE_ARRAY_LENGTH;
JSONArray mergedList = new JSONArray();
HashSet<String> set = new HashSet<>();
int lsize = left.length(), rsize = right.length();
BitSet dupSetForAdd = null;
if (!remove)
dupSetForAdd = new BitSet(lsize + rsize);
int lidx = 0;
int ridx = scan(right, set, dupSetForAdd, lsize);
if (!remove && set.size() < maxValNum) {
lidx = scan(left, set, dupSetForAdd, 0);
}
for (int i = lidx; i < lsize; i++) {
try {
if (remove) {
String _j = (String) left.get(i);
if (!set.contains(_j)) {
mergedList.put(_j);
}
} else if (!dupSetForAdd.get(i)) {
mergedList.put(left.get(i));
}
} catch (Throwable t) {
//no-op
}
}
if (!remove && mergedList.length() < maxValNum) {
for (int i = ridx; i < rsize; i++) {
try {
if (!dupSetForAdd.get(i + lsize)) {
mergedList.put(right.get(i));
}
} catch (Throwable t) {
//no-op
}
}
}
// check to see if the list got trimmed in the merge
if (ridx > 0 || lidx > 0) {
vr.setErrorDesc("Multi value property for key " + key + " exceeds the limit of " + maxValNum + " items. Trimmed");
vr.setErrorCode(521);
}
vr.setObject(mergedList);
return vr;
} | [
"private",
"ValidationResult",
"_mergeListInternalForKey",
"(",
"String",
"key",
",",
"JSONArray",
"left",
",",
"JSONArray",
"right",
",",
"boolean",
"remove",
",",
"ValidationResult",
"vr",
")",
"{",
"if",
"(",
"left",
"==",
"null",
")",
"{",
"vr",
".",
"se... | scans right to left until max to maintain latest max values for the multi-value property specified by key.
@param key the property key
@param left original list
@param right new list
@param remove if remove new list from original
@param vr ValidationResult for error and merged list return | [
"scans",
"right",
"to",
"left",
"until",
"max",
"to",
"maintain",
"latest",
"max",
"values",
"for",
"the",
"multi",
"-",
"value",
"property",
"specified",
"by",
"key",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Validator.java#L321-L395 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DeviceInfo.java | DeviceInfo.initDeviceID | @SuppressWarnings({"WeakerAccess"})
protected void initDeviceID() {
getDeviceCachedInfo(); // put this here to avoid running on main thread
// generate a provisional while we do the rest async
generateProvisionalGUID();
// grab and cache the googleAdID in any event if available
// if we already have a deviceID we won't user ad id as the guid
cacheGoogleAdID();
// if we already have a device ID use it and just notify
// otherwise generate one, either from ad id if available or the provisional
String deviceID = getDeviceID();
if (deviceID == null || deviceID.trim().length() <= 2) {
generateDeviceID();
}
} | java | @SuppressWarnings({"WeakerAccess"})
protected void initDeviceID() {
getDeviceCachedInfo(); // put this here to avoid running on main thread
// generate a provisional while we do the rest async
generateProvisionalGUID();
// grab and cache the googleAdID in any event if available
// if we already have a deviceID we won't user ad id as the guid
cacheGoogleAdID();
// if we already have a device ID use it and just notify
// otherwise generate one, either from ad id if available or the provisional
String deviceID = getDeviceID();
if (deviceID == null || deviceID.trim().length() <= 2) {
generateDeviceID();
}
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
"}",
")",
"protected",
"void",
"initDeviceID",
"(",
")",
"{",
"getDeviceCachedInfo",
"(",
")",
";",
"// put this here to avoid running on main thread",
"// generate a provisional while we do the rest async",
"generateProvis... | don't run on main thread | [
"don",
"t",
"run",
"on",
"main",
"thread"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DeviceInfo.java#L78-L95 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Logger.java | Logger.i | static void i(String message){
if (getStaticDebugLevel() >= CleverTapAPI.LogLevel.INFO.intValue()){
Log.i(Constants.CLEVERTAP_LOG_TAG,message);
}
} | java | static void i(String message){
if (getStaticDebugLevel() >= CleverTapAPI.LogLevel.INFO.intValue()){
Log.i(Constants.CLEVERTAP_LOG_TAG,message);
}
} | [
"static",
"void",
"i",
"(",
"String",
"message",
")",
"{",
"if",
"(",
"getStaticDebugLevel",
"(",
")",
">=",
"CleverTapAPI",
".",
"LogLevel",
".",
"INFO",
".",
"intValue",
"(",
")",
")",
"{",
"Log",
".",
"i",
"(",
"Constants",
".",
"CLEVERTAP_LOG_TAG",
... | Logs to Info if the debug level is greater than or equal to 1. | [
"Logs",
"to",
"Info",
"if",
"the",
"debug",
"level",
"is",
"greater",
"than",
"or",
"equal",
"to",
"1",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/Logger.java#L114-L118 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxBaseMessageViewHolder.java | CTInboxBaseMessageViewHolder.calculateDisplayTimestamp | String calculateDisplayTimestamp(long time){
long now = System.currentTimeMillis()/1000;
long diff = now-time;
if(diff < 60){
return "Just Now";
}else if(diff > 60 && diff < 59*60){
return (diff/(60)) + " mins ago";
}else if(diff > 59*60 && diff < 23*59*60 ){
return diff/(60*60) > 1 ? diff/(60*60) + " hours ago" : diff/(60*60) + " hour ago";
}else if(diff > 24*60*60 && diff < 48*60*60){
return "Yesterday";
}else {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM");
return sdf.format(new Date(time));
}
} | java | String calculateDisplayTimestamp(long time){
long now = System.currentTimeMillis()/1000;
long diff = now-time;
if(diff < 60){
return "Just Now";
}else if(diff > 60 && diff < 59*60){
return (diff/(60)) + " mins ago";
}else if(diff > 59*60 && diff < 23*59*60 ){
return diff/(60*60) > 1 ? diff/(60*60) + " hours ago" : diff/(60*60) + " hour ago";
}else if(diff > 24*60*60 && diff < 48*60*60){
return "Yesterday";
}else {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM");
return sdf.format(new Date(time));
}
} | [
"String",
"calculateDisplayTimestamp",
"(",
"long",
"time",
")",
"{",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
";",
"long",
"diff",
"=",
"now",
"-",
"time",
";",
"if",
"(",
"diff",
"<",
"60",
")",
"{",
"return",
... | Logic for timestamp
@param time Epoch date of creation
@return String timestamp | [
"Logic",
"for",
"timestamp"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxBaseMessageViewHolder.java#L71-L87 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxStyleConfig.java | CTInboxStyleConfig.setTabs | public void setTabs(ArrayList<String>tabs) {
if (tabs == null || tabs.size() <= 0) return;
if (platformSupportsTabs) {
ArrayList<String> toAdd;
if (tabs.size() > MAX_TABS) {
toAdd = new ArrayList<>(tabs.subList(0, MAX_TABS));
} else {
toAdd = tabs;
}
this.tabs = toAdd.toArray(new String[0]);
} else {
Logger.d("Please upgrade com.android.support:design library to v28.0.0 to enable Tabs for App Inbox, dropping Tabs");
}
} | java | public void setTabs(ArrayList<String>tabs) {
if (tabs == null || tabs.size() <= 0) return;
if (platformSupportsTabs) {
ArrayList<String> toAdd;
if (tabs.size() > MAX_TABS) {
toAdd = new ArrayList<>(tabs.subList(0, MAX_TABS));
} else {
toAdd = tabs;
}
this.tabs = toAdd.toArray(new String[0]);
} else {
Logger.d("Please upgrade com.android.support:design library to v28.0.0 to enable Tabs for App Inbox, dropping Tabs");
}
} | [
"public",
"void",
"setTabs",
"(",
"ArrayList",
"<",
"String",
">",
"tabs",
")",
"{",
"if",
"(",
"tabs",
"==",
"null",
"||",
"tabs",
".",
"size",
"(",
")",
"<=",
"0",
")",
"return",
";",
"if",
"(",
"platformSupportsTabs",
")",
"{",
"ArrayList",
"<",
... | Sets the name of the optional two tabs.
The contents of the tabs are filtered based on the name of the tab.
@param tabs ArrayList of Strings | [
"Sets",
"the",
"name",
"of",
"the",
"optional",
"two",
"tabs",
".",
"The",
"contents",
"of",
"the",
"tabs",
"are",
"filtered",
"based",
"on",
"the",
"name",
"of",
"the",
"tab",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxStyleConfig.java#L184-L198 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/EventHandler.java | EventHandler.push | @Deprecated
@SuppressWarnings("deprecation")
public void push(String eventName, HashMap<String, Object> chargeDetails,
ArrayList<HashMap<String, Object>> items)
throws InvalidEventNameException {
// This method is for only charged events
if (!eventName.equals(Constants.CHARGED_EVENT)) {
throw new InvalidEventNameException("Not a charged event");
}
CleverTapAPI cleverTapAPI = weakReference.get();
if(cleverTapAPI == null){
Logger.d("CleverTap Instance is null.");
} else {
cleverTapAPI.pushChargedEvent(chargeDetails, items);
}
} | java | @Deprecated
@SuppressWarnings("deprecation")
public void push(String eventName, HashMap<String, Object> chargeDetails,
ArrayList<HashMap<String, Object>> items)
throws InvalidEventNameException {
// This method is for only charged events
if (!eventName.equals(Constants.CHARGED_EVENT)) {
throw new InvalidEventNameException("Not a charged event");
}
CleverTapAPI cleverTapAPI = weakReference.get();
if(cleverTapAPI == null){
Logger.d("CleverTap Instance is null.");
} else {
cleverTapAPI.pushChargedEvent(chargeDetails, items);
}
} | [
"@",
"Deprecated",
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"void",
"push",
"(",
"String",
"eventName",
",",
"HashMap",
"<",
"String",
",",
"Object",
">",
"chargeDetails",
",",
"ArrayList",
"<",
"HashMap",
"<",
"String",
",",
"Object",
... | Push an event which describes a purchase made.
@param eventName Has to be specified as "Charged". Anything other than this
will result in an {@link InvalidEventNameException} being thrown.
@param chargeDetails A {@link HashMap}, with keys as strings, and values as {@link String},
{@link Integer}, {@link Long}, {@link Boolean}, {@link Float}, {@link Double},
{@link java.util.Date}, or {@link Character}
@param items An {@link ArrayList} which contains up to 15 {@link HashMap} objects,
where each HashMap object describes a particular item purchased
@throws InvalidEventNameException Thrown if the event name is not "Charged"
@deprecated use {@link CleverTapAPI#pushChargedEvent(HashMap chargeDetails, ArrayList items)} | [
"Push",
"an",
"event",
"which",
"describes",
"a",
"purchase",
"made",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/EventHandler.java#L68-L83 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessage.java | CTInboxMessage.getCarouselImages | public ArrayList<String> getCarouselImages(){
ArrayList<String> carouselImages = new ArrayList<>();
for(CTInboxMessageContent ctInboxMessageContent: getInboxMessageContents()){
carouselImages.add(ctInboxMessageContent.getMedia());
}
return carouselImages;
} | java | public ArrayList<String> getCarouselImages(){
ArrayList<String> carouselImages = new ArrayList<>();
for(CTInboxMessageContent ctInboxMessageContent: getInboxMessageContents()){
carouselImages.add(ctInboxMessageContent.getMedia());
}
return carouselImages;
} | [
"public",
"ArrayList",
"<",
"String",
">",
"getCarouselImages",
"(",
")",
"{",
"ArrayList",
"<",
"String",
">",
"carouselImages",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"CTInboxMessageContent",
"ctInboxMessageContent",
":",
"getInboxMessageConte... | Returns an ArrayList of String URLs of the Carousel Images
@return ArrayList of Strings | [
"Returns",
"an",
"ArrayList",
"of",
"String",
"URLs",
"of",
"the",
"Carousel",
"Images"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CTInboxMessage.java#L251-L257 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.storeObject | synchronized int storeObject(JSONObject obj, Table table) {
if (!this.belowMemThreshold()) {
Logger.v("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = table.getName();
Cursor cursor = null;
int count = DB_UPDATE_ERROR;
//noinspection TryFinallyCanBeTryWithResources
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put(KEY_CREATED_AT, System.currentTimeMillis());
db.insert(tableName, null, cv);
cursor = db.rawQuery("SELECT COUNT(*) FROM " + tableName, null);
cursor.moveToFirst();
count = cursor.getInt(0);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
if (cursor != null) {
cursor.close();
cursor = null;
}
dbHelper.deleteDatabase();
} finally {
if (cursor != null) {
cursor.close();
}
dbHelper.close();
}
return count;
} | java | synchronized int storeObject(JSONObject obj, Table table) {
if (!this.belowMemThreshold()) {
Logger.v("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = table.getName();
Cursor cursor = null;
int count = DB_UPDATE_ERROR;
//noinspection TryFinallyCanBeTryWithResources
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put(KEY_CREATED_AT, System.currentTimeMillis());
db.insert(tableName, null, cv);
cursor = db.rawQuery("SELECT COUNT(*) FROM " + tableName, null);
cursor.moveToFirst();
count = cursor.getInt(0);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
if (cursor != null) {
cursor.close();
cursor = null;
}
dbHelper.deleteDatabase();
} finally {
if (cursor != null) {
cursor.close();
}
dbHelper.close();
}
return count;
} | [
"synchronized",
"int",
"storeObject",
"(",
"JSONObject",
"obj",
",",
"Table",
"table",
")",
"{",
"if",
"(",
"!",
"this",
".",
"belowMemThreshold",
"(",
")",
")",
"{",
"Logger",
".",
"v",
"(",
"\"There is not enough space left on the device to store data, data discar... | Adds a JSON string to the DB.
@param obj the JSON to record
@param table the table to insert into
@return the number of rows in the table, or DB_OUT_OF_MEMORY_ERROR/DB_UPDATE_ERROR | [
"Adds",
"a",
"JSON",
"string",
"to",
"the",
"DB",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L209-L246 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.storeUserProfile | synchronized long storeUserProfile(String id, JSONObject obj) {
if (id == null) return DB_UPDATE_ERROR;
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = Table.USER_PROFILES.getName();
long ret = DB_UPDATE_ERROR;
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put("_id", id);
ret = db.insertWithOnConflict(tableName, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
return ret;
} | java | synchronized long storeUserProfile(String id, JSONObject obj) {
if (id == null) return DB_UPDATE_ERROR;
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return DB_OUT_OF_MEMORY_ERROR;
}
final String tableName = Table.USER_PROFILES.getName();
long ret = DB_UPDATE_ERROR;
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_DATA, obj.toString());
cv.put("_id", id);
ret = db.insertWithOnConflict(tableName, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
return ret;
} | [
"synchronized",
"long",
"storeUserProfile",
"(",
"String",
"id",
",",
"JSONObject",
"obj",
")",
"{",
"if",
"(",
"id",
"==",
"null",
")",
"return",
"DB_UPDATE_ERROR",
";",
"if",
"(",
"!",
"this",
".",
"belowMemThreshold",
"(",
")",
")",
"{",
"getConfigLogge... | Adds a JSON string representing to the DB.
@param obj the JSON to record
@return the number of rows in the table, or DB_OUT_OF_MEMORY_ERROR/DB_UPDATE_ERROR | [
"Adds",
"a",
"JSON",
"string",
"representing",
"to",
"the",
"DB",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L254-L280 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.removeUserProfile | synchronized void removeUserProfile(String id) {
if (id == null) return;
final String tableName = Table.USER_PROFILES.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tableName, "_id = ?", new String[]{id});
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing user profile from " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
} | java | synchronized void removeUserProfile(String id) {
if (id == null) return;
final String tableName = Table.USER_PROFILES.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tableName, "_id = ?", new String[]{id});
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing user profile from " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
} | [
"synchronized",
"void",
"removeUserProfile",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"id",
"==",
"null",
")",
"return",
";",
"final",
"String",
"tableName",
"=",
"Table",
".",
"USER_PROFILES",
".",
"getName",
"(",
")",
";",
"try",
"{",
"final",
"SQLite... | remove the user profile with id from the db. | [
"remove",
"the",
"user",
"profile",
"with",
"id",
"from",
"the",
"db",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L285-L298 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.removeEvents | synchronized void removeEvents(Table table) {
final String tName = table.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tName, null, null);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing all events from table " + tName + " Recreating DB");
deleteDB();
} finally {
dbHelper.close();
}
} | java | synchronized void removeEvents(Table table) {
final String tName = table.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tName, null, null);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing all events from table " + tName + " Recreating DB");
deleteDB();
} finally {
dbHelper.close();
}
} | [
"synchronized",
"void",
"removeEvents",
"(",
"Table",
"table",
")",
"{",
"final",
"String",
"tName",
"=",
"table",
".",
"getName",
"(",
")",
";",
"try",
"{",
"final",
"SQLiteDatabase",
"db",
"=",
"dbHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"db",... | Removes all events from table
@param table the table to remove events | [
"Removes",
"all",
"events",
"from",
"table"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L338-L350 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.fetchEvents | synchronized JSONObject fetchEvents(Table table, final int limit) {
final String tName = table.getName();
Cursor cursor = null;
String lastId = null;
final JSONArray events = new JSONArray();
//noinspection TryFinallyCanBeTryWithResources
try {
final SQLiteDatabase db = dbHelper.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM " + tName +
" ORDER BY " + KEY_CREATED_AT + " ASC LIMIT " + limit, null);
while (cursor.moveToNext()) {
if (cursor.isLast()) {
lastId = cursor.getString(cursor.getColumnIndex("_id"));
}
try {
final JSONObject j = new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA)));
events.put(j);
} catch (final JSONException e) {
// Ignore
}
}
} catch (final SQLiteException e) {
getConfigLogger().verbose("Could not fetch records out of database " + tName + ".", e);
lastId = null;
} finally {
dbHelper.close();
if (cursor != null) {
cursor.close();
}
}
if (lastId != null) {
try {
final JSONObject ret = new JSONObject();
ret.put(lastId, events);
return ret;
} catch (JSONException e) {
// ignore
}
}
return null;
} | java | synchronized JSONObject fetchEvents(Table table, final int limit) {
final String tName = table.getName();
Cursor cursor = null;
String lastId = null;
final JSONArray events = new JSONArray();
//noinspection TryFinallyCanBeTryWithResources
try {
final SQLiteDatabase db = dbHelper.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM " + tName +
" ORDER BY " + KEY_CREATED_AT + " ASC LIMIT " + limit, null);
while (cursor.moveToNext()) {
if (cursor.isLast()) {
lastId = cursor.getString(cursor.getColumnIndex("_id"));
}
try {
final JSONObject j = new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA)));
events.put(j);
} catch (final JSONException e) {
// Ignore
}
}
} catch (final SQLiteException e) {
getConfigLogger().verbose("Could not fetch records out of database " + tName + ".", e);
lastId = null;
} finally {
dbHelper.close();
if (cursor != null) {
cursor.close();
}
}
if (lastId != null) {
try {
final JSONObject ret = new JSONObject();
ret.put(lastId, events);
return ret;
} catch (JSONException e) {
// ignore
}
}
return null;
} | [
"synchronized",
"JSONObject",
"fetchEvents",
"(",
"Table",
"table",
",",
"final",
"int",
"limit",
")",
"{",
"final",
"String",
"tName",
"=",
"table",
".",
"getName",
"(",
")",
";",
"Cursor",
"cursor",
"=",
"null",
";",
"String",
"lastId",
"=",
"null",
";... | Returns a JSONObject keyed with the lastId retrieved and a value of a JSONArray of the retrieved JSONObject events
@param table the table to read from
@return JSONObject containing the max row ID and a JSONArray of the JSONObject events or null | [
"Returns",
"a",
"JSONObject",
"keyed",
"with",
"the",
"lastId",
"retrieved",
"and",
"a",
"value",
"of",
"a",
"JSONArray",
"of",
"the",
"retrieved",
"JSONObject",
"events"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L413-L459 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.storeUninstallTimestamp | synchronized void storeUninstallTimestamp() {
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return ;
}
final String tableName = Table.UNINSTALL_TS.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_CREATED_AT, System.currentTimeMillis());
db.insert(tableName, null, cv);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
} | java | synchronized void storeUninstallTimestamp() {
if (!this.belowMemThreshold()) {
getConfigLogger().verbose("There is not enough space left on the device to store data, data discarded");
return ;
}
final String tableName = Table.UNINSTALL_TS.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final ContentValues cv = new ContentValues();
cv.put(KEY_CREATED_AT, System.currentTimeMillis());
db.insert(tableName, null, cv);
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
dbHelper.deleteDatabase();
} finally {
dbHelper.close();
}
} | [
"synchronized",
"void",
"storeUninstallTimestamp",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"belowMemThreshold",
"(",
")",
")",
"{",
"getConfigLogger",
"(",
")",
".",
"verbose",
"(",
"\"There is not enough space left on the device to store data, data discarded\"",
")... | Adds a String timestamp representing uninstall flag to the DB. | [
"Adds",
"a",
"String",
"timestamp",
"representing",
"uninstall",
"flag",
"to",
"the",
"DB",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L588-L608 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.deleteMessageForId | synchronized boolean deleteMessageForId(String messageId, String userId){
if(messageId == null || userId == null) return false;
final String tName = Table.INBOX_MESSAGES.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tName, _ID + " = ? AND " + USER_ID + " = ?", new String[]{messageId,userId});
return true;
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing stale records from " + tName, e);
return false;
} finally {
dbHelper.close();
}
} | java | synchronized boolean deleteMessageForId(String messageId, String userId){
if(messageId == null || userId == null) return false;
final String tName = Table.INBOX_MESSAGES.getName();
try {
final SQLiteDatabase db = dbHelper.getWritableDatabase();
db.delete(tName, _ID + " = ? AND " + USER_ID + " = ?", new String[]{messageId,userId});
return true;
} catch (final SQLiteException e) {
getConfigLogger().verbose("Error removing stale records from " + tName, e);
return false;
} finally {
dbHelper.close();
}
} | [
"synchronized",
"boolean",
"deleteMessageForId",
"(",
"String",
"messageId",
",",
"String",
"userId",
")",
"{",
"if",
"(",
"messageId",
"==",
"null",
"||",
"userId",
"==",
"null",
")",
"return",
"false",
";",
"final",
"String",
"tName",
"=",
"Table",
".",
... | Deletes the inbox message for given messageId
@param messageId String messageId
@return boolean value based on success of operation | [
"Deletes",
"the",
"inbox",
"message",
"for",
"given",
"messageId"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L672-L687 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.markReadMessageForId | synchronized boolean markReadMessageForId(String messageId, String userId){
if(messageId == null || userId == null) return false;
final String tName = Table.INBOX_MESSAGES.getName();
try{
final SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(IS_READ,1);
db.update(Table.INBOX_MESSAGES.getName(), cv,_ID + " = ? AND " + USER_ID + " = ?",new String[]{messageId,userId});
return true;
}catch (final SQLiteException e){
getConfigLogger().verbose("Error removing stale records from " + tName, e);
return false;
} finally {
dbHelper.close();
}
} | java | synchronized boolean markReadMessageForId(String messageId, String userId){
if(messageId == null || userId == null) return false;
final String tName = Table.INBOX_MESSAGES.getName();
try{
final SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(IS_READ,1);
db.update(Table.INBOX_MESSAGES.getName(), cv,_ID + " = ? AND " + USER_ID + " = ?",new String[]{messageId,userId});
return true;
}catch (final SQLiteException e){
getConfigLogger().verbose("Error removing stale records from " + tName, e);
return false;
} finally {
dbHelper.close();
}
} | [
"synchronized",
"boolean",
"markReadMessageForId",
"(",
"String",
"messageId",
",",
"String",
"userId",
")",
"{",
"if",
"(",
"messageId",
"==",
"null",
"||",
"userId",
"==",
"null",
")",
"return",
"false",
";",
"final",
"String",
"tName",
"=",
"Table",
".",
... | Marks inbox message as read for given messageId
@param messageId String messageId
@return boolean value depending on success of operation | [
"Marks",
"inbox",
"message",
"as",
"read",
"for",
"given",
"messageId"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L694-L710 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java | DBAdapter.getMessages | synchronized ArrayList<CTMessageDAO> getMessages(String userId){
final String tName = Table.INBOX_MESSAGES.getName();
Cursor cursor;
ArrayList<CTMessageDAO> messageDAOArrayList = new ArrayList<>();
try{
final SQLiteDatabase db = dbHelper.getWritableDatabase();
cursor= db.rawQuery("SELECT * FROM "+tName+" WHERE " + USER_ID + " = ? ORDER BY " + KEY_CREATED_AT+ " DESC", new String[]{userId});
if(cursor != null) {
while(cursor.moveToNext()){
CTMessageDAO ctMessageDAO = new CTMessageDAO();
ctMessageDAO.setId(cursor.getString(cursor.getColumnIndex(_ID)));
ctMessageDAO.setJsonData(new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA))));
ctMessageDAO.setWzrkParams(new JSONObject(cursor.getString(cursor.getColumnIndex(WZRKPARAMS))));
ctMessageDAO.setDate(cursor.getLong(cursor.getColumnIndex(KEY_CREATED_AT)));
ctMessageDAO.setExpires(cursor.getLong(cursor.getColumnIndex(EXPIRES)));
ctMessageDAO.setRead(cursor.getInt(cursor.getColumnIndex(IS_READ)));
ctMessageDAO.setUserId(cursor.getString(cursor.getColumnIndex(USER_ID)));
ctMessageDAO.setTags(cursor.getString(cursor.getColumnIndex(TAGS)));
ctMessageDAO.setCampaignId(cursor.getString(cursor.getColumnIndex(CAMPAIGN)));
messageDAOArrayList.add(ctMessageDAO);
}
cursor.close();
}
return messageDAOArrayList;
}catch (final SQLiteException e){
getConfigLogger().verbose("Error retrieving records from " + tName, e);
return null;
} catch (JSONException e) {
getConfigLogger().verbose("Error retrieving records from " + tName, e.getMessage());
return null;
} finally {
dbHelper.close();
}
} | java | synchronized ArrayList<CTMessageDAO> getMessages(String userId){
final String tName = Table.INBOX_MESSAGES.getName();
Cursor cursor;
ArrayList<CTMessageDAO> messageDAOArrayList = new ArrayList<>();
try{
final SQLiteDatabase db = dbHelper.getWritableDatabase();
cursor= db.rawQuery("SELECT * FROM "+tName+" WHERE " + USER_ID + " = ? ORDER BY " + KEY_CREATED_AT+ " DESC", new String[]{userId});
if(cursor != null) {
while(cursor.moveToNext()){
CTMessageDAO ctMessageDAO = new CTMessageDAO();
ctMessageDAO.setId(cursor.getString(cursor.getColumnIndex(_ID)));
ctMessageDAO.setJsonData(new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA))));
ctMessageDAO.setWzrkParams(new JSONObject(cursor.getString(cursor.getColumnIndex(WZRKPARAMS))));
ctMessageDAO.setDate(cursor.getLong(cursor.getColumnIndex(KEY_CREATED_AT)));
ctMessageDAO.setExpires(cursor.getLong(cursor.getColumnIndex(EXPIRES)));
ctMessageDAO.setRead(cursor.getInt(cursor.getColumnIndex(IS_READ)));
ctMessageDAO.setUserId(cursor.getString(cursor.getColumnIndex(USER_ID)));
ctMessageDAO.setTags(cursor.getString(cursor.getColumnIndex(TAGS)));
ctMessageDAO.setCampaignId(cursor.getString(cursor.getColumnIndex(CAMPAIGN)));
messageDAOArrayList.add(ctMessageDAO);
}
cursor.close();
}
return messageDAOArrayList;
}catch (final SQLiteException e){
getConfigLogger().verbose("Error retrieving records from " + tName, e);
return null;
} catch (JSONException e) {
getConfigLogger().verbose("Error retrieving records from " + tName, e.getMessage());
return null;
} finally {
dbHelper.close();
}
} | [
"synchronized",
"ArrayList",
"<",
"CTMessageDAO",
">",
"getMessages",
"(",
"String",
"userId",
")",
"{",
"final",
"String",
"tName",
"=",
"Table",
".",
"INBOX_MESSAGES",
".",
"getName",
"(",
")",
";",
"Cursor",
"cursor",
";",
"ArrayList",
"<",
"CTMessageDAO",
... | Retrieves list of inbox messages based on given userId
@param userId String userid
@return ArrayList of {@link CTMessageDAO} | [
"Retrieves",
"list",
"of",
"inbox",
"messages",
"based",
"on",
"given",
"userId"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/DBAdapter.java#L717-L750 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readContents | private void readContents(int maxFrames) {
// Read GIF file content blocks.
boolean done = false;
while (!(done || err() || header.frameCount > maxFrames)) {
int code = read();
switch (code) {
// Image separator.
case 0x2C:
// The graphics control extension is optional, but will always come first if it exists.
// If one did
// exist, there will be a non-null current frame which we should use. However if one
// did not exist,
// the current frame will be null and we must create it here. See issue #134.
if (header.currentFrame == null) {
header.currentFrame = new GifFrame();
}
readBitmap();
break;
// Extension.
case 0x21:
code = read();
switch (code) {
// Graphics control extension.
case 0xf9:
// Start a new frame.
header.currentFrame = new GifFrame();
readGraphicControlExt();
break;
// Application extension.
case 0xff:
readBlock();
String app = "";
for (int i = 0; i < 11; i++) {
app += (char) block[i];
}
if (app.equals("NETSCAPE2.0")) {
readNetscapeExt();
} else {
// Don't care.
skip();
}
break;
// Comment extension.
case 0xfe:
skip();
break;
// Plain text extension.
case 0x01:
skip();
break;
// Uninteresting extension.
default:
skip();
}
break;
// Terminator.
case 0x3b:
done = true;
break;
// Bad byte, but keep going and see what happens break;
case 0x00:
default:
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
}
} | java | private void readContents(int maxFrames) {
// Read GIF file content blocks.
boolean done = false;
while (!(done || err() || header.frameCount > maxFrames)) {
int code = read();
switch (code) {
// Image separator.
case 0x2C:
// The graphics control extension is optional, but will always come first if it exists.
// If one did
// exist, there will be a non-null current frame which we should use. However if one
// did not exist,
// the current frame will be null and we must create it here. See issue #134.
if (header.currentFrame == null) {
header.currentFrame = new GifFrame();
}
readBitmap();
break;
// Extension.
case 0x21:
code = read();
switch (code) {
// Graphics control extension.
case 0xf9:
// Start a new frame.
header.currentFrame = new GifFrame();
readGraphicControlExt();
break;
// Application extension.
case 0xff:
readBlock();
String app = "";
for (int i = 0; i < 11; i++) {
app += (char) block[i];
}
if (app.equals("NETSCAPE2.0")) {
readNetscapeExt();
} else {
// Don't care.
skip();
}
break;
// Comment extension.
case 0xfe:
skip();
break;
// Plain text extension.
case 0x01:
skip();
break;
// Uninteresting extension.
default:
skip();
}
break;
// Terminator.
case 0x3b:
done = true;
break;
// Bad byte, but keep going and see what happens break;
case 0x00:
default:
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
}
} | [
"private",
"void",
"readContents",
"(",
"int",
"maxFrames",
")",
"{",
"// Read GIF file content blocks.",
"boolean",
"done",
"=",
"false",
";",
"while",
"(",
"!",
"(",
"done",
"||",
"err",
"(",
")",
"||",
"header",
".",
"frameCount",
">",
"maxFrames",
")",
... | Main file parser. Reads GIF content blocks. Stops after reading maxFrames | [
"Main",
"file",
"parser",
".",
"Reads",
"GIF",
"content",
"blocks",
".",
"Stops",
"after",
"reading",
"maxFrames"
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L115-L180 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readBitmap | private void readBitmap() {
// (sub)image position & size.
header.currentFrame.ix = readShort();
header.currentFrame.iy = readShort();
header.currentFrame.iw = readShort();
header.currentFrame.ih = readShort();
int packed = read();
// 1 - local color table flag interlace
boolean lctFlag = (packed & 0x80) != 0;
int lctSize = (int) Math.pow(2, (packed & 0x07) + 1);
// 3 - sort flag
// 4-5 - reserved lctSize = 2 << (packed & 7); // 6-8 - local color
// table size
header.currentFrame.interlace = (packed & 0x40) != 0;
if (lctFlag) {
// Read table.
header.currentFrame.lct = readColorTable(lctSize);
} else {
// No local color table.
header.currentFrame.lct = null;
}
// Save this as the decoding position pointer.
header.currentFrame.bufferFrameStart = rawData.position();
// False decode pixel data to advance buffer.
skipImageData();
if (err()) {
return;
}
header.frameCount++;
// Add image to frame.
header.frames.add(header.currentFrame);
} | java | private void readBitmap() {
// (sub)image position & size.
header.currentFrame.ix = readShort();
header.currentFrame.iy = readShort();
header.currentFrame.iw = readShort();
header.currentFrame.ih = readShort();
int packed = read();
// 1 - local color table flag interlace
boolean lctFlag = (packed & 0x80) != 0;
int lctSize = (int) Math.pow(2, (packed & 0x07) + 1);
// 3 - sort flag
// 4-5 - reserved lctSize = 2 << (packed & 7); // 6-8 - local color
// table size
header.currentFrame.interlace = (packed & 0x40) != 0;
if (lctFlag) {
// Read table.
header.currentFrame.lct = readColorTable(lctSize);
} else {
// No local color table.
header.currentFrame.lct = null;
}
// Save this as the decoding position pointer.
header.currentFrame.bufferFrameStart = rawData.position();
// False decode pixel data to advance buffer.
skipImageData();
if (err()) {
return;
}
header.frameCount++;
// Add image to frame.
header.frames.add(header.currentFrame);
} | [
"private",
"void",
"readBitmap",
"(",
")",
"{",
"// (sub)image position & size.",
"header",
".",
"currentFrame",
".",
"ix",
"=",
"readShort",
"(",
")",
";",
"header",
".",
"currentFrame",
".",
"iy",
"=",
"readShort",
"(",
")",
";",
"header",
".",
"currentFra... | Reads next frame image. | [
"Reads",
"next",
"frame",
"image",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L213-L249 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readNetscapeExt | private void readNetscapeExt() {
do {
readBlock();
if (block[0] == 1) {
// Loop count sub-block.
int b1 = ((int) block[1]) & 0xff;
int b2 = ((int) block[2]) & 0xff;
header.loopCount = (b2 << 8) | b1;
if(header.loopCount == 0) {
header.loopCount = GifDecoder.LOOP_FOREVER;
}
}
} while ((blockSize > 0) && !err());
} | java | private void readNetscapeExt() {
do {
readBlock();
if (block[0] == 1) {
// Loop count sub-block.
int b1 = ((int) block[1]) & 0xff;
int b2 = ((int) block[2]) & 0xff;
header.loopCount = (b2 << 8) | b1;
if(header.loopCount == 0) {
header.loopCount = GifDecoder.LOOP_FOREVER;
}
}
} while ((blockSize > 0) && !err());
} | [
"private",
"void",
"readNetscapeExt",
"(",
")",
"{",
"do",
"{",
"readBlock",
"(",
")",
";",
"if",
"(",
"block",
"[",
"0",
"]",
"==",
"1",
")",
"{",
"// Loop count sub-block.",
"int",
"b1",
"=",
"(",
"(",
"int",
")",
"block",
"[",
"1",
"]",
")",
"... | Reads Netscape extension to obtain iteration count. | [
"Reads",
"Netscape",
"extension",
"to",
"obtain",
"iteration",
"count",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L254-L267 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readLSD | private void readLSD() {
// Logical screen size.
header.width = readShort();
header.height = readShort();
// Packed fields
int packed = read();
// 1 : global color table flag.
header.gctFlag = (packed & 0x80) != 0;
// 2-4 : color resolution.
// 5 : gct sort flag.
// 6-8 : gct size.
header.gctSize = 2 << (packed & 7);
// Background color index.
header.bgIndex = read();
// Pixel aspect ratio
header.pixelAspect = read();
} | java | private void readLSD() {
// Logical screen size.
header.width = readShort();
header.height = readShort();
// Packed fields
int packed = read();
// 1 : global color table flag.
header.gctFlag = (packed & 0x80) != 0;
// 2-4 : color resolution.
// 5 : gct sort flag.
// 6-8 : gct size.
header.gctSize = 2 << (packed & 7);
// Background color index.
header.bgIndex = read();
// Pixel aspect ratio
header.pixelAspect = read();
} | [
"private",
"void",
"readLSD",
"(",
")",
"{",
"// Logical screen size.",
"header",
".",
"width",
"=",
"readShort",
"(",
")",
";",
"header",
".",
"height",
"=",
"readShort",
"(",
")",
";",
"// Packed fields",
"int",
"packed",
"=",
"read",
"(",
")",
";",
"/... | Reads Logical Screen Descriptor. | [
"Reads",
"Logical",
"Screen",
"Descriptor",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L292-L308 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.readColorTable | private int[] readColorTable(int ncolors) {
int nbytes = 3 * ncolors;
int[] tab = null;
byte[] c = new byte[nbytes];
try {
rawData.get(c);
// Max size to avoid bounds checks.
tab = new int[MAX_BLOCK_SIZE];
int i = 0;
int j = 0;
while (i < ncolors) {
int r = ((int) c[j++]) & 0xff;
int g = ((int) c[j++]) & 0xff;
int b = ((int) c[j++]) & 0xff;
tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
} catch (BufferUnderflowException e) {
//if (Log.isLoggable(TAG, Log.DEBUG)) {
Logger.d(TAG, "Format Error Reading Color Table", e);
//}
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return tab;
} | java | private int[] readColorTable(int ncolors) {
int nbytes = 3 * ncolors;
int[] tab = null;
byte[] c = new byte[nbytes];
try {
rawData.get(c);
// Max size to avoid bounds checks.
tab = new int[MAX_BLOCK_SIZE];
int i = 0;
int j = 0;
while (i < ncolors) {
int r = ((int) c[j++]) & 0xff;
int g = ((int) c[j++]) & 0xff;
int b = ((int) c[j++]) & 0xff;
tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
} catch (BufferUnderflowException e) {
//if (Log.isLoggable(TAG, Log.DEBUG)) {
Logger.d(TAG, "Format Error Reading Color Table", e);
//}
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return tab;
} | [
"private",
"int",
"[",
"]",
"readColorTable",
"(",
"int",
"ncolors",
")",
"{",
"int",
"nbytes",
"=",
"3",
"*",
"ncolors",
";",
"int",
"[",
"]",
"tab",
"=",
"null",
";",
"byte",
"[",
"]",
"c",
"=",
"new",
"byte",
"[",
"nbytes",
"]",
";",
"try",
... | Reads color table as 256 RGB integer values.
@param ncolors int number of colors to read.
@return int array containing 256 colors (packed ARGB with full alpha). | [
"Reads",
"color",
"table",
"as",
"256",
"RGB",
"integer",
"values",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L316-L342 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.skip | private void skip() {
try {
int blockSize;
do {
blockSize = read();
rawData.position(rawData.position() + blockSize);
} while (blockSize > 0);
} catch (IllegalArgumentException ex) {
}
} | java | private void skip() {
try {
int blockSize;
do {
blockSize = read();
rawData.position(rawData.position() + blockSize);
} while (blockSize > 0);
} catch (IllegalArgumentException ex) {
}
} | [
"private",
"void",
"skip",
"(",
")",
"{",
"try",
"{",
"int",
"blockSize",
";",
"do",
"{",
"blockSize",
"=",
"read",
"(",
")",
";",
"rawData",
".",
"position",
"(",
"rawData",
".",
"position",
"(",
")",
"+",
"blockSize",
")",
";",
"}",
"while",
"(",... | Skips variable length blocks up to and including next zero length block. | [
"Skips",
"variable",
"length",
"blocks",
"up",
"to",
"and",
"including",
"next",
"zero",
"length",
"block",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L357-L366 | train |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java | GifHeaderParser.read | private int read() {
int curByte = 0;
try {
curByte = rawData.get() & 0xFF;
} catch (Exception e) {
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return curByte;
} | java | private int read() {
int curByte = 0;
try {
curByte = rawData.get() & 0xFF;
} catch (Exception e) {
header.status = GifDecoder.STATUS_FORMAT_ERROR;
}
return curByte;
} | [
"private",
"int",
"read",
"(",
")",
"{",
"int",
"curByte",
"=",
"0",
";",
"try",
"{",
"curByte",
"=",
"rawData",
".",
"get",
"(",
")",
"&",
"0xFF",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"header",
".",
"status",
"=",
"GifDecoder",
".... | Reads a single byte from the input stream. | [
"Reads",
"a",
"single",
"byte",
"from",
"the",
"input",
"stream",
"."
] | be134c06a4f07494c398335ad9ff4976633743e1 | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/GifHeaderParser.java#L399-L407 | train |
SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/builder/TreeScanner.java | TreeScanner.isToIgnore | private boolean isToIgnore(CtElement element) {
if (element instanceof CtStatementList && !(element instanceof CtCase)) {
if (element.getRoleInParent() == CtRole.ELSE || element.getRoleInParent() == CtRole.THEN) {
return false;
}
return true;
}
return element.isImplicit() || element instanceof CtReference;
} | java | private boolean isToIgnore(CtElement element) {
if (element instanceof CtStatementList && !(element instanceof CtCase)) {
if (element.getRoleInParent() == CtRole.ELSE || element.getRoleInParent() == CtRole.THEN) {
return false;
}
return true;
}
return element.isImplicit() || element instanceof CtReference;
} | [
"private",
"boolean",
"isToIgnore",
"(",
"CtElement",
"element",
")",
"{",
"if",
"(",
"element",
"instanceof",
"CtStatementList",
"&&",
"!",
"(",
"element",
"instanceof",
"CtCase",
")",
")",
"{",
"if",
"(",
"element",
".",
"getRoleInParent",
"(",
")",
"==",
... | Ignore some element from the AST
@param element
@return | [
"Ignore",
"some",
"element",
"from",
"the",
"AST"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/builder/TreeScanner.java#L71-L79 | train |
SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/builder/Json4SpoonGenerator.java | Json4SpoonGenerator.getJSONwithOperations | public JsonObject getJSONwithOperations(TreeContext context, ITree tree, List<Operation> operations) {
OperationNodePainter opNodePainter = new OperationNodePainter(operations);
Collection<NodePainter> painters = new ArrayList<NodePainter>();
painters.add(opNodePainter);
return getJSONwithCustorLabels(context, tree, painters);
} | java | public JsonObject getJSONwithOperations(TreeContext context, ITree tree, List<Operation> operations) {
OperationNodePainter opNodePainter = new OperationNodePainter(operations);
Collection<NodePainter> painters = new ArrayList<NodePainter>();
painters.add(opNodePainter);
return getJSONwithCustorLabels(context, tree, painters);
} | [
"public",
"JsonObject",
"getJSONwithOperations",
"(",
"TreeContext",
"context",
",",
"ITree",
"tree",
",",
"List",
"<",
"Operation",
">",
"operations",
")",
"{",
"OperationNodePainter",
"opNodePainter",
"=",
"new",
"OperationNodePainter",
"(",
"operations",
")",
";"... | Decorates a node with the affected operator, if any.
@param context
@param tree
@param operations
@return | [
"Decorates",
"a",
"node",
"with",
"the",
"affected",
"operator",
"if",
"any",
"."
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/builder/Json4SpoonGenerator.java#L76-L82 | train |
SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/diff/ActionClassifier.java | ActionClassifier.getRootActions | public List<Action> getRootActions() {
final List<Action> rootActions = srcUpdTrees.stream().map(t -> originalActionsSrc.get(t))
.collect(Collectors.toList());
rootActions.addAll(srcDelTrees.stream() //
.filter(t -> !srcDelTrees.contains(t.getParent()) && !srcUpdTrees.contains(t.getParent())) //
.map(t -> originalActionsSrc.get(t)) //
.collect(Collectors.toList()));
rootActions.addAll(dstAddTrees.stream() //
.filter(t -> !dstAddTrees.contains(t.getParent()) && !dstUpdTrees.contains(t.getParent())) //
.map(t -> originalActionsDst.get(t)) //
.collect(Collectors.toList()));
rootActions.addAll(dstMvTrees.stream() //
.filter(t -> !dstMvTrees.contains(t.getParent())) //
.map(t -> originalActionsDst.get(t)) //
.collect(Collectors.toList()));
rootActions.removeAll(Collections.singleton(null));
return rootActions;
} | java | public List<Action> getRootActions() {
final List<Action> rootActions = srcUpdTrees.stream().map(t -> originalActionsSrc.get(t))
.collect(Collectors.toList());
rootActions.addAll(srcDelTrees.stream() //
.filter(t -> !srcDelTrees.contains(t.getParent()) && !srcUpdTrees.contains(t.getParent())) //
.map(t -> originalActionsSrc.get(t)) //
.collect(Collectors.toList()));
rootActions.addAll(dstAddTrees.stream() //
.filter(t -> !dstAddTrees.contains(t.getParent()) && !dstUpdTrees.contains(t.getParent())) //
.map(t -> originalActionsDst.get(t)) //
.collect(Collectors.toList()));
rootActions.addAll(dstMvTrees.stream() //
.filter(t -> !dstMvTrees.contains(t.getParent())) //
.map(t -> originalActionsDst.get(t)) //
.collect(Collectors.toList()));
rootActions.removeAll(Collections.singleton(null));
return rootActions;
} | [
"public",
"List",
"<",
"Action",
">",
"getRootActions",
"(",
")",
"{",
"final",
"List",
"<",
"Action",
">",
"rootActions",
"=",
"srcUpdTrees",
".",
"stream",
"(",
")",
".",
"map",
"(",
"t",
"->",
"originalActionsSrc",
".",
"get",
"(",
"t",
")",
")",
... | This method retrieves ONLY the ROOT actions | [
"This",
"method",
"retrieves",
"ONLY",
"the",
"ROOT",
"actions"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/diff/ActionClassifier.java#L72-L93 | train |
SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/AstComparator.java | AstComparator.compare | public Diff compare(File f1, File f2) throws Exception {
return this.compare(getCtType(f1), getCtType(f2));
} | java | public Diff compare(File f1, File f2) throws Exception {
return this.compare(getCtType(f1), getCtType(f2));
} | [
"public",
"Diff",
"compare",
"(",
"File",
"f1",
",",
"File",
"f2",
")",
"throws",
"Exception",
"{",
"return",
"this",
".",
"compare",
"(",
"getCtType",
"(",
"f1",
")",
",",
"getCtType",
"(",
"f2",
")",
")",
";",
"}"
] | compares two java files | [
"compares",
"two",
"java",
"files"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/AstComparator.java#L76-L78 | train |
SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/AstComparator.java | AstComparator.compare | public Diff compare(String left, String right) {
return compare(getCtType(left), getCtType(right));
} | java | public Diff compare(String left, String right) {
return compare(getCtType(left), getCtType(right));
} | [
"public",
"Diff",
"compare",
"(",
"String",
"left",
",",
"String",
"right",
")",
"{",
"return",
"compare",
"(",
"getCtType",
"(",
"left",
")",
",",
"getCtType",
"(",
"right",
")",
")",
";",
"}"
] | compares two snippet | [
"compares",
"two",
"snippet"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/AstComparator.java#L83-L85 | train |
SpoonLabs/gumtree-spoon-ast-diff | src/main/java/gumtree/spoon/AstComparator.java | AstComparator.compare | public Diff compare(CtElement left, CtElement right) {
final SpoonGumTreeBuilder scanner = new SpoonGumTreeBuilder();
return new DiffImpl(scanner.getTreeContext(), scanner.getTree(left), scanner.getTree(right));
} | java | public Diff compare(CtElement left, CtElement right) {
final SpoonGumTreeBuilder scanner = new SpoonGumTreeBuilder();
return new DiffImpl(scanner.getTreeContext(), scanner.getTree(left), scanner.getTree(right));
} | [
"public",
"Diff",
"compare",
"(",
"CtElement",
"left",
",",
"CtElement",
"right",
")",
"{",
"final",
"SpoonGumTreeBuilder",
"scanner",
"=",
"new",
"SpoonGumTreeBuilder",
"(",
")",
";",
"return",
"new",
"DiffImpl",
"(",
"scanner",
".",
"getTreeContext",
"(",
")... | compares two AST nodes | [
"compares",
"two",
"AST",
"nodes"
] | 361364ddaad3e8f0921a068275d4d21b6e836e85 | https://github.com/SpoonLabs/gumtree-spoon-ast-diff/blob/361364ddaad3e8f0921a068275d4d21b6e836e85/src/main/java/gumtree/spoon/AstComparator.java#L90-L93 | train |
mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.set | public void set(int index, T object) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.set(index, object);
} else {
mObjects.set(index, object);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | java | public void set(int index, T object) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.set(index, object);
} else {
mObjects.set(index, object);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | [
"public",
"void",
"set",
"(",
"int",
"index",
",",
"T",
"object",
")",
"{",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mOriginalValues",
"!=",
"null",
")",
"{",
"mOriginalValues",
".",
"set",
"(",
"index",
",",
"object",
")",
";",
"}",
"else... | set the specified object at index
@param object The object to add at the end of the array. | [
"set",
"the",
"specified",
"object",
"at",
"index"
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L152-L161 | train |
mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.addAll | public void addAll(int index, T... items) {
List<T> collection = Arrays.asList(items);
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.addAll(index, collection);
} else {
mObjects.addAll(index, collection);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | java | public void addAll(int index, T... items) {
List<T> collection = Arrays.asList(items);
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.addAll(index, collection);
} else {
mObjects.addAll(index, collection);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | [
"public",
"void",
"addAll",
"(",
"int",
"index",
",",
"T",
"...",
"items",
")",
"{",
"List",
"<",
"T",
">",
"collection",
"=",
"Arrays",
".",
"asList",
"(",
"items",
")",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mOriginalValues",
"!="... | Inserts the specified objects at the specified index in the array.
@param items The objects to insert into the array.
@param index The index at which the object must be inserted. | [
"Inserts",
"the",
"specified",
"objects",
"at",
"the",
"specified",
"index",
"in",
"the",
"array",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L228-L238 | train |
mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.removeAt | public void removeAt(int index) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.remove(index);
} else {
mObjects.remove(index);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | java | public void removeAt(int index) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.remove(index);
} else {
mObjects.remove(index);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
} | [
"public",
"void",
"removeAt",
"(",
"int",
"index",
")",
"{",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mOriginalValues",
"!=",
"null",
")",
"{",
"mOriginalValues",
".",
"remove",
"(",
"index",
")",
";",
"}",
"else",
"{",
"mObjects",
".",
"rem... | Removes the specified object in index from the array.
@param index The index to remove. | [
"Removes",
"the",
"specified",
"object",
"in",
"index",
"from",
"the",
"array",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L316-L325 | train |
mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java | ArrayAdapterCompat.removeAll | public boolean removeAll(Collection<?> collection) {
boolean result = false;
synchronized (mLock) {
Iterator<?> it;
if (mOriginalValues != null) {
it = mOriginalValues.iterator();
} else {
it = mObjects.iterator();
}
while (it.hasNext()) {
if (collection.contains(it.next())) {
it.remove();
result = true;
}
}
}
if (mNotifyOnChange) notifyDataSetChanged();
return result;
} | java | public boolean removeAll(Collection<?> collection) {
boolean result = false;
synchronized (mLock) {
Iterator<?> it;
if (mOriginalValues != null) {
it = mOriginalValues.iterator();
} else {
it = mObjects.iterator();
}
while (it.hasNext()) {
if (collection.contains(it.next())) {
it.remove();
result = true;
}
}
}
if (mNotifyOnChange) notifyDataSetChanged();
return result;
} | [
"public",
"boolean",
"removeAll",
"(",
"Collection",
"<",
"?",
">",
"collection",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"Iterator",
"<",
"?",
">",
"it",
";",
"if",
"(",
"mOriginalValues",
"!=",
"null",
... | Removes the specified objects.
@param collection The collection to remove. | [
"Removes",
"the",
"specified",
"objects",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/widget/ArrayAdapterCompat.java#L333-L352 | train |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java | AdvancedRecyclerArrayAdapter.addAll | public void addAll(@NonNull final Collection<T> collection) {
final int length = collection.size();
if (length == 0) {
return;
}
synchronized (mLock) {
final int position = getItemCount();
mObjects.addAll(collection);
notifyItemRangeInserted(position, length);
}
} | java | public void addAll(@NonNull final Collection<T> collection) {
final int length = collection.size();
if (length == 0) {
return;
}
synchronized (mLock) {
final int position = getItemCount();
mObjects.addAll(collection);
notifyItemRangeInserted(position, length);
}
} | [
"public",
"void",
"addAll",
"(",
"@",
"NonNull",
"final",
"Collection",
"<",
"T",
">",
"collection",
")",
"{",
"final",
"int",
"length",
"=",
"collection",
".",
"size",
"(",
")",
";",
"if",
"(",
"length",
"==",
"0",
")",
"{",
"return",
";",
"}",
"s... | Adds the specified list of objects at the end of the array.
@param collection The objects to add at the end of the array. | [
"Adds",
"the",
"specified",
"list",
"of",
"objects",
"at",
"the",
"end",
"of",
"the",
"array",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java#L81-L91 | train |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java | AdvancedRecyclerArrayAdapter.getItem | @Nullable
public T getItem(final int position) {
if (position < 0 || position >= mObjects.size()) {
return null;
}
return mObjects.get(position);
} | java | @Nullable
public T getItem(final int position) {
if (position < 0 || position >= mObjects.size()) {
return null;
}
return mObjects.get(position);
} | [
"@",
"Nullable",
"public",
"T",
"getItem",
"(",
"final",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"mObjects",
".",
"size",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"mObjects",
".",
"get",
... | Returns the item at the specified position.
@param position index of the item to return
@return the item at the specified position or {@code null} when not found | [
"Returns",
"the",
"item",
"at",
"the",
"specified",
"position",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java#L154-L160 | train |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java | AdvancedRecyclerArrayAdapter.replaceItem | public void replaceItem(@NonNull final T oldObject, @NonNull final T newObject) {
synchronized (mLock) {
final int position = getPosition(oldObject);
if (position == -1) {
// not found, don't replace
return;
}
mObjects.remove(position);
mObjects.add(position, newObject);
if (isItemTheSame(oldObject, newObject)) {
if (isContentTheSame(oldObject, newObject)) {
// visible content hasn't changed, don't notify
return;
}
// item with same stable id has changed
notifyItemChanged(position, newObject);
} else {
// item replaced with another one with a different id
notifyItemRemoved(position);
notifyItemInserted(position);
}
}
} | java | public void replaceItem(@NonNull final T oldObject, @NonNull final T newObject) {
synchronized (mLock) {
final int position = getPosition(oldObject);
if (position == -1) {
// not found, don't replace
return;
}
mObjects.remove(position);
mObjects.add(position, newObject);
if (isItemTheSame(oldObject, newObject)) {
if (isContentTheSame(oldObject, newObject)) {
// visible content hasn't changed, don't notify
return;
}
// item with same stable id has changed
notifyItemChanged(position, newObject);
} else {
// item replaced with another one with a different id
notifyItemRemoved(position);
notifyItemInserted(position);
}
}
} | [
"public",
"void",
"replaceItem",
"(",
"@",
"NonNull",
"final",
"T",
"oldObject",
",",
"@",
"NonNull",
"final",
"T",
"newObject",
")",
"{",
"synchronized",
"(",
"mLock",
")",
"{",
"final",
"int",
"position",
"=",
"getPosition",
"(",
"oldObject",
")",
";",
... | replaces the old with the new item. The new item will not be added when the old one is not
found.
@param oldObject will be removed
@param newObject is added only when hte old item is removed | [
"replaces",
"the",
"old",
"with",
"the",
"new",
"item",
".",
"The",
"new",
"item",
"will",
"not",
"be",
"added",
"when",
"the",
"old",
"one",
"is",
"not",
"found",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/AdvancedRecyclerArrayAdapter.java#L283-L308 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/ViewUtils.java | ViewUtils.hideSystemUI | @TargetApi(VERSION_CODES.KITKAT)
public static void hideSystemUI(Activity activity) {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hideSelf and show.
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hideSelf nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hideSelf status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE
);
} | java | @TargetApi(VERSION_CODES.KITKAT)
public static void hideSystemUI(Activity activity) {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hideSelf and show.
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hideSelf nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hideSelf status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE
);
} | [
"@",
"TargetApi",
"(",
"VERSION_CODES",
".",
"KITKAT",
")",
"public",
"static",
"void",
"hideSystemUI",
"(",
"Activity",
"activity",
")",
"{",
"// Set the IMMERSIVE flag.",
"// Set the content to appear under the system bars so that the content",
"// doesn't resize when the syste... | This intro hides the system bars. | [
"This",
"intro",
"hides",
"the",
"system",
"bars",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/ViewUtils.java#L28-L42 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/ViewUtils.java | ViewUtils.showSystemUI | @TargetApi(VERSION_CODES.KITKAT)
public static void showSystemUI(Activity activity) {
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);
} | java | @TargetApi(VERSION_CODES.KITKAT)
public static void showSystemUI(Activity activity) {
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);
} | [
"@",
"TargetApi",
"(",
"VERSION_CODES",
".",
"KITKAT",
")",
"public",
"static",
"void",
"showSystemUI",
"(",
"Activity",
"activity",
")",
"{",
"View",
"decorView",
"=",
"activity",
".",
"getWindow",
"(",
")",
".",
"getDecorView",
"(",
")",
";",
"decorView",
... | except for the ones that make the content appear under the system bars. | [
"except",
"for",
"the",
"ones",
"that",
"make",
"the",
"content",
"appear",
"under",
"the",
"system",
"bars",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/ViewUtils.java#L46-L54 | train |
mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/internal/AdapterWrapper.java | AdapterWrapper.getView | @Override
public View getView(int position, View convertView,
ViewGroup parent) {
return (wrapped.getView(position, convertView, parent));
} | java | @Override
public View getView(int position, View convertView,
ViewGroup parent) {
return (wrapped.getView(position, convertView, parent));
} | [
"@",
"Override",
"public",
"View",
"getView",
"(",
"int",
"position",
",",
"View",
"convertView",
",",
"ViewGroup",
"parent",
")",
"{",
"return",
"(",
"wrapped",
".",
"getView",
"(",
"position",
",",
"convertView",
",",
"parent",
")",
")",
";",
"}"
] | Get a View that displays the data at the specified
position in the data set.
@param position Position of the item whose data we want
@param convertView View to recycle, if not null
@param parent ViewGroup containing the returned View | [
"Get",
"a",
"View",
"that",
"displays",
"the",
"data",
"at",
"the",
"specified",
"position",
"in",
"the",
"data",
"set",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/internal/AdapterWrapper.java#L141-L145 | train |
mcxiaoke/Android-Next | ui/src/main/java/com/mcxiaoke/next/ui/dialog/v4/ProgressDialogFragment.java | ProgressDialogFragment.onDismiss | @Override
public void onDismiss(DialogInterface dialog) {
if (mOldDialog != null && mOldDialog == dialog) {
// This is the callback from the old progress dialog that was already dismissed before
// the device orientation change, so just ignore it.
return;
}
super.onDismiss(dialog);
} | java | @Override
public void onDismiss(DialogInterface dialog) {
if (mOldDialog != null && mOldDialog == dialog) {
// This is the callback from the old progress dialog that was already dismissed before
// the device orientation change, so just ignore it.
return;
}
super.onDismiss(dialog);
} | [
"@",
"Override",
"public",
"void",
"onDismiss",
"(",
"DialogInterface",
"dialog",
")",
"{",
"if",
"(",
"mOldDialog",
"!=",
"null",
"&&",
"mOldDialog",
"==",
"dialog",
")",
"{",
"// This is the callback from the old progress dialog that was already dismissed before",
"// t... | There is a race condition that is not handled properly by the DialogFragment class.
If we don't check that this onDismiss callback isn't for the old progress dialog from before
the device orientation change, then this will cause the newly created dialog after the
orientation change to be dismissed immediately. | [
"There",
"is",
"a",
"race",
"condition",
"that",
"is",
"not",
"handled",
"properly",
"by",
"the",
"DialogFragment",
"class",
".",
"If",
"we",
"don",
"t",
"check",
"that",
"this",
"onDismiss",
"callback",
"isn",
"t",
"for",
"the",
"old",
"progress",
"dialog... | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/ui/src/main/java/com/mcxiaoke/next/ui/dialog/v4/ProgressDialogFragment.java#L123-L131 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/ReflectionUtils.java | ReflectionUtils.isToStringMethod | public static boolean isToStringMethod(Method method) {
return (method != null && method.getName().equals("readString") && method.getParameterTypes().length == 0);
} | java | public static boolean isToStringMethod(Method method) {
return (method != null && method.getName().equals("readString") && method.getParameterTypes().length == 0);
} | [
"public",
"static",
"boolean",
"isToStringMethod",
"(",
"Method",
"method",
")",
"{",
"return",
"(",
"method",
"!=",
"null",
"&&",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"readString\"",
")",
"&&",
"method",
".",
"getParameterTypes",
"(",
... | Determine whether the given method is a "readString" method.
@see Object#toString() | [
"Determine",
"whether",
"the",
"given",
"method",
"is",
"a",
"readString",
"method",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/ReflectionUtils.java#L411-L413 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/ReflectionUtils.java | ReflectionUtils.getUniqueDeclaredMethods | public static Method[] getUniqueDeclaredMethods(Class<?> leafClass) throws IllegalArgumentException {
final List<Method> methods = new ArrayList<Method>(32);
doWithMethods(leafClass, new MethodCallback() {
@Override
public void doWith(Method method) {
boolean knownSignature = false;
Method methodBeingOverriddenWithCovariantReturnType = null;
for (Method existingMethod : methods) {
if (method.getName().equals(existingMethod.getName()) &&
Arrays.equals(method.getParameterTypes(), existingMethod.getParameterTypes())) {
// Is this a covariant return type situation?
if (existingMethod.getReturnType() != method.getReturnType() &&
existingMethod.getReturnType().isAssignableFrom(method.getReturnType())) {
methodBeingOverriddenWithCovariantReturnType = existingMethod;
} else {
knownSignature = true;
}
break;
}
}
if (methodBeingOverriddenWithCovariantReturnType != null) {
methods.remove(methodBeingOverriddenWithCovariantReturnType);
}
if (!knownSignature) {
methods.add(method);
}
}
});
return methods.toArray(new Method[methods.size()]);
} | java | public static Method[] getUniqueDeclaredMethods(Class<?> leafClass) throws IllegalArgumentException {
final List<Method> methods = new ArrayList<Method>(32);
doWithMethods(leafClass, new MethodCallback() {
@Override
public void doWith(Method method) {
boolean knownSignature = false;
Method methodBeingOverriddenWithCovariantReturnType = null;
for (Method existingMethod : methods) {
if (method.getName().equals(existingMethod.getName()) &&
Arrays.equals(method.getParameterTypes(), existingMethod.getParameterTypes())) {
// Is this a covariant return type situation?
if (existingMethod.getReturnType() != method.getReturnType() &&
existingMethod.getReturnType().isAssignableFrom(method.getReturnType())) {
methodBeingOverriddenWithCovariantReturnType = existingMethod;
} else {
knownSignature = true;
}
break;
}
}
if (methodBeingOverriddenWithCovariantReturnType != null) {
methods.remove(methodBeingOverriddenWithCovariantReturnType);
}
if (!knownSignature) {
methods.add(method);
}
}
});
return methods.toArray(new Method[methods.size()]);
} | [
"public",
"static",
"Method",
"[",
"]",
"getUniqueDeclaredMethods",
"(",
"Class",
"<",
"?",
">",
"leafClass",
")",
"throws",
"IllegalArgumentException",
"{",
"final",
"List",
"<",
"Method",
">",
"methods",
"=",
"new",
"ArrayList",
"<",
"Method",
">",
"(",
"3... | Get the unique set of declared methods on the leaf class and all superclasses. Leaf
class methods are included first and while traversing the superclass hierarchy any methods found
with signatures matching a method already included are filtered out. | [
"Get",
"the",
"unique",
"set",
"of",
"declared",
"methods",
"on",
"the",
"leaf",
"class",
"and",
"all",
"superclasses",
".",
"Leaf",
"class",
"methods",
"are",
"included",
"first",
"and",
"while",
"traversing",
"the",
"superclass",
"hierarchy",
"any",
"methods... | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/ReflectionUtils.java#L547-L576 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java | WeakFastHashMap.put | @Override
public V put(K key, V value) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
V result = temp.put(key, value);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.put(key, value));
}
}
} | java | @Override
public V put(K key, V value) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
V result = temp.put(key, value);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.put(key, value));
}
}
} | [
"@",
"Override",
"public",
"V",
"put",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"if",
"(",
"fast",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"Map",
"<",
"K",
",",
"V",
">",
"temp",
"=",
"cloneMap",
"(",
"map",
")",
";",
"V",
"resu... | Associate the specified value with the specified key in this map.
If the map previously contained a mapping for this key, the old
value is replaced and returned.
@param key the key with which the value is to be associated
@param value the value to be associated with this key
@return the value previously mapped to the key, or null | [
"Associate",
"the",
"specified",
"value",
"with",
"the",
"specified",
"key",
"in",
"this",
"map",
".",
"If",
"the",
"map",
"previously",
"contained",
"a",
"mapping",
"for",
"this",
"key",
"the",
"old",
"value",
"is",
"replaced",
"and",
"returned",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java#L357-L371 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java | WeakFastHashMap.putAll | @Override
public void putAll(Map<? extends K, ? extends V> in) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
temp.putAll(in);
map = temp;
}
} else {
synchronized (map) {
map.putAll(in);
}
}
} | java | @Override
public void putAll(Map<? extends K, ? extends V> in) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
temp.putAll(in);
map = temp;
}
} else {
synchronized (map) {
map.putAll(in);
}
}
} | [
"@",
"Override",
"public",
"void",
"putAll",
"(",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"in",
")",
"{",
"if",
"(",
"fast",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"Map",
"<",
"K",
",",
"V",
">",
"temp",
"=",
... | Copy all of the mappings from the specified map to this one, replacing
any mappings with the same keys.
@param in the map whose mappings are to be copied | [
"Copy",
"all",
"of",
"the",
"mappings",
"from",
"the",
"specified",
"map",
"to",
"this",
"one",
"replacing",
"any",
"mappings",
"with",
"the",
"same",
"keys",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java#L382-L395 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java | WeakFastHashMap.remove | @Override
public V remove(Object key) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
V result = temp.remove(key);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.remove(key));
}
}
} | java | @Override
public V remove(Object key) {
if (fast) {
synchronized (this) {
Map<K, V> temp = cloneMap(map);
V result = temp.remove(key);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.remove(key));
}
}
} | [
"@",
"Override",
"public",
"V",
"remove",
"(",
"Object",
"key",
")",
"{",
"if",
"(",
"fast",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"Map",
"<",
"K",
",",
"V",
">",
"temp",
"=",
"cloneMap",
"(",
"map",
")",
";",
"V",
"result",
"=",
"te... | Remove any mapping for this key, and return any previously
mapped value.
@param key the key whose mapping is to be removed
@return the value removed, or null | [
"Remove",
"any",
"mapping",
"for",
"this",
"key",
"and",
"return",
"any",
"previously",
"mapped",
"value",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/collection/WeakFastHashMap.java#L404-L418 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java | IOUtils.isFileExist | public static boolean isFileExist(String filePath) {
if (StringUtils.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
return (file.exists() && file.isFile());
} | java | public static boolean isFileExist(String filePath) {
if (StringUtils.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
return (file.exists() && file.isFile());
} | [
"public",
"static",
"boolean",
"isFileExist",
"(",
"String",
"filePath",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"filePath",
")",
")",
"{",
"return",
"false",
";",
"}",
"File",
"file",
"=",
"new",
"File",
"(",
"filePath",
")",
";",
"re... | Indicates if this file represents a file on the underlying file system.
@param filePath
@return | [
"Indicates",
"if",
"this",
"file",
"represents",
"a",
"file",
"on",
"the",
"underlying",
"file",
"system",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java#L1436-L1443 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java | IOUtils.isFolderExist | public static boolean isFolderExist(String directoryPath) {
if (StringUtils.isEmpty(directoryPath)) {
return false;
}
File dire = new File(directoryPath);
return (dire.exists() && dire.isDirectory());
} | java | public static boolean isFolderExist(String directoryPath) {
if (StringUtils.isEmpty(directoryPath)) {
return false;
}
File dire = new File(directoryPath);
return (dire.exists() && dire.isDirectory());
} | [
"public",
"static",
"boolean",
"isFolderExist",
"(",
"String",
"directoryPath",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"directoryPath",
")",
")",
"{",
"return",
"false",
";",
"}",
"File",
"dire",
"=",
"new",
"File",
"(",
"directoryPath",
... | Indicates if this file represents a directory on the underlying file system.
@param directoryPath
@return | [
"Indicates",
"if",
"this",
"file",
"represents",
"a",
"directory",
"on",
"the",
"underlying",
"file",
"system",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/IOUtils.java#L1451-L1458 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/utils/AndroidUtils.java | AndroidUtils.addToMediaStore | public static void addToMediaStore(Context context, File file) {
String[] path = new String[]{file.getPath()};
MediaScannerConnection.scanFile(context, path, null, null);
} | java | public static void addToMediaStore(Context context, File file) {
String[] path = new String[]{file.getPath()};
MediaScannerConnection.scanFile(context, path, null, null);
} | [
"public",
"static",
"void",
"addToMediaStore",
"(",
"Context",
"context",
",",
"File",
"file",
")",
"{",
"String",
"[",
"]",
"path",
"=",
"new",
"String",
"[",
"]",
"{",
"file",
".",
"getPath",
"(",
")",
"}",
";",
"MediaScannerConnection",
".",
"scanFile... | another media scan way | [
"another",
"media",
"scan",
"way"
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/utils/AndroidUtils.java#L331-L334 | train |
mcxiaoke/Android-Next | core/src/main/java/com/mcxiaoke/next/io/CountingInputStream.java | CountingInputStream.skip | @Override
public synchronized long skip(final long length) throws IOException {
final long skip = super.skip(length);
this.count += skip;
return skip;
} | java | @Override
public synchronized long skip(final long length) throws IOException {
final long skip = super.skip(length);
this.count += skip;
return skip;
} | [
"@",
"Override",
"public",
"synchronized",
"long",
"skip",
"(",
"final",
"long",
"length",
")",
"throws",
"IOException",
"{",
"final",
"long",
"skip",
"=",
"super",
".",
"skip",
"(",
"length",
")",
";",
"this",
".",
"count",
"+=",
"skip",
";",
"return",
... | Skips the stream over the specified number of bytes, adding the skipped
amount to the count.
@param length the number of bytes to skip
@return the actual number of bytes skipped
@throws java.io.IOException if an I/O error occurs
@see java.io.InputStream#skip(long) | [
"Skips",
"the",
"stream",
"over",
"the",
"specified",
"number",
"of",
"bytes",
"adding",
"the",
"skipped",
"amount",
"to",
"the",
"count",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/core/src/main/java/com/mcxiaoke/next/io/CountingInputStream.java#L58-L63 | train |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemRangeInserted | public final void notifyHeaderItemRangeInserted(int positionStart, int itemCount) {
int newHeaderItemCount = getHeaderItemCount();
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newHeaderItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (newHeaderItemCount - 1) + "].");
}
notifyItemRangeInserted(positionStart, itemCount);
} | java | public final void notifyHeaderItemRangeInserted(int positionStart, int itemCount) {
int newHeaderItemCount = getHeaderItemCount();
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newHeaderItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (newHeaderItemCount - 1) + "].");
}
notifyItemRangeInserted(positionStart, itemCount);
} | [
"public",
"final",
"void",
"notifyHeaderItemRangeInserted",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"int",
"newHeaderItemCount",
"=",
"getHeaderItemCount",
"(",
")",
";",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
... | Notifies that multiple header items are inserted.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"header",
"items",
"are",
"inserted",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L132-L138 | train |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemChanged | public final void notifyHeaderItemChanged(int position) {
if (position < 0 || position >= headerItemCount) {
throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemChanged(position);
} | java | public final void notifyHeaderItemChanged(int position) {
if (position < 0 || position >= headerItemCount) {
throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemChanged(position);
} | [
"public",
"final",
"void",
"notifyHeaderItemChanged",
"(",
"int",
"position",
")",
"{",
"if",
"(",
"position",
"<",
"0",
"||",
"position",
">=",
"headerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given position \"",
"+",
"positio... | Notifies that a header item is changed.
@param position the position. | [
"Notifies",
"that",
"a",
"header",
"item",
"is",
"changed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L145-L150 | train |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemRangeChanged | public final void notifyHeaderItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount >= headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart, itemCount);
} | java | public final void notifyHeaderItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount >= headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart, itemCount);
} | [
"public",
"final",
"void",
"notifyHeaderItemRangeChanged",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">=",
"headerItemCount",
")",
... | Notifies that multiple header items are changed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"header",
"items",
"are",
"changed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L158-L163 | train |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemMoved | public void notifyHeaderItemMoved(int fromPosition, int toPosition) {
if (fromPosition < 0 || toPosition < 0 || fromPosition >= headerItemCount || toPosition >= headerItemCount) {
throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemMoved(fromPosition, toPosition);
} | java | public void notifyHeaderItemMoved(int fromPosition, int toPosition) {
if (fromPosition < 0 || toPosition < 0 || fromPosition >= headerItemCount || toPosition >= headerItemCount) {
throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemMoved(fromPosition, toPosition);
} | [
"public",
"void",
"notifyHeaderItemMoved",
"(",
"int",
"fromPosition",
",",
"int",
"toPosition",
")",
"{",
"if",
"(",
"fromPosition",
"<",
"0",
"||",
"toPosition",
"<",
"0",
"||",
"fromPosition",
">=",
"headerItemCount",
"||",
"toPosition",
">=",
"headerItemCoun... | Notifies that an existing header item is moved to another position.
@param fromPosition the original position.
@param toPosition the new position. | [
"Notifies",
"that",
"an",
"existing",
"header",
"item",
"is",
"moved",
"to",
"another",
"position",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L172-L177 | train |
mcxiaoke/Android-Next | recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java | HeaderFooterRecyclerAdapter.notifyHeaderItemRangeRemoved | public void notifyHeaderItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart, itemCount);
} | java | public void notifyHeaderItemRangeRemoved(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > headerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (headerItemCount - 1) + "].");
}
notifyItemRangeRemoved(positionStart, itemCount);
} | [
"public",
"void",
"notifyHeaderItemRangeRemoved",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"headerItemCount",
")",
"{",
"thr... | Notifies that multiple header items are removed.
@param positionStart the position.
@param itemCount the item count. | [
"Notifies",
"that",
"multiple",
"header",
"items",
"are",
"removed",
"."
] | 1bfdf99d0b81a849aa0fa6697c53ed673151ca39 | https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L197-L202 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.