_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q7800
CleverTapAPI.attachMeta
train
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
{ "resource": "" }
q7801
CleverTapAPI.recordScreen
train
@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
{ "resource": "" }
q7802
CleverTapAPI.clearQueues
train
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
{ "resource": "" }
q7803
CleverTapAPI.updateCursorForDBObject
train
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
{ "resource": "" }
q7804
CleverTapAPI.getARP
train
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
{ "resource": "" }
q7805
CleverTapAPI.getTotalVisits
train
@SuppressWarnings({"unused", "WeakerAccess"}) public int getTotalVisits() { EventDetail ed = getLocalDataStore().getEventDetail(Constants.APP_LAUNCHED_EVENT); if (ed != null) return ed.getCount(); return 0; }
java
{ "resource": "" }
q7806
CleverTapAPI.getTimeElapsed
train
@SuppressWarnings({"unused", "WeakerAccess"}) public int getTimeElapsed() { int currentSession = getCurrentSession(); if (currentSession == 0) return -1; int now = (int) (System.currentTimeMillis() / 1000); return now - currentSession; }
java
{ "resource": "" }
q7807
CleverTapAPI.getUTMDetails
train
@SuppressWarnings({"unused", "WeakerAccess"}) public UTMDetail getUTMDetails() { UTMDetail ud = new UTMDetail(); ud.setSource(source); ud.setMedium(medium); ud.setCampaign(campaign); return ud; }
java
{ "resource": "" }
q7808
CleverTapAPI._handleMultiValues
train
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
{ "resource": "" }
q7809
CleverTapAPI.pushEvent
train
@SuppressWarnings({"unused", "WeakerAccess"}) public void pushEvent(String eventName) { if (eventName == null || eventName.trim().equals("")) return; pushEvent(eventName, null); }
java
{ "resource": "" }
q7810
CleverTapAPI.pushNotificationViewedEvent
train
@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
{ "resource": "" }
q7811
CleverTapAPI.getCount
train
@SuppressWarnings({"unused", "WeakerAccess"}) public int getCount(String event) { EventDetail eventDetail = getLocalDataStore().getEventDetail(event); if (eventDetail != null) return eventDetail.getCount(); return -1; }
java
{ "resource": "" }
q7812
CleverTapAPI.pushDeviceToken
train
private void pushDeviceToken(final String token, final boolean register, final PushType type) { pushDeviceToken(this.context, token, register, type); }
java
{ "resource": "" }
q7813
CleverTapAPI.getNotificationInfo
train
@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
{ "resource": "" }
q7814
CleverTapAPI.pushInstallReferrer
train
@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
{ "resource": "" }
q7815
CleverTapAPI.pushInstallReferrer
train
@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
{ "resource": "" }
q7816
CleverTapAPI.changeCredentials
train
@SuppressWarnings("unused") public static void changeCredentials(String accountID, String token) { changeCredentials(accountID, token, null); }
java
{ "resource": "" }
q7817
CleverTapAPI.changeCredentials
train
@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
{ "resource": "" }
q7818
CleverTapAPI.getInboxMessageCount
train
@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
{ "resource": "" }
q7819
CleverTapAPI.getInboxMessageUnreadCount
train
@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
{ "resource": "" }
q7820
CleverTapAPI.markReadInboxMessage
train
@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
{ "resource": "" }
q7821
GifDecoder.advance
train
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
{ "resource": "" }
q7822
GifDecoder.getDelay
train
int getDelay(int n) { int delay = -1; if ((n >= 0) && (n < header.frameCount)) { delay = header.frames.get(n).delay; } return delay; }
java
{ "resource": "" }
q7823
GifDecoder.setFrameIndex
train
boolean setFrameIndex(int frame) { if(frame < INITIAL_FRAME_POINTER || frame >= getFrameCount()) { return false; } framePointer = frame; return true; }
java
{ "resource": "" }
q7824
GifDecoder.read
train
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
{ "resource": "" }
q7825
GifDecoder.read
train
synchronized int read(byte[] data) { this.header = getHeaderParser().setData(data).parseHeader(); if (data != null) { setData(header, data); } return status; }
java
{ "resource": "" }
q7826
GifDecoder.readChunkIfNeeded
train
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
{ "resource": "" }
q7827
ActivityLifecycleCallback.register
train
@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
{ "resource": "" }
q7828
Validator.cleanObjectKey
train
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
{ "resource": "" }
q7829
Validator.cleanMultiValuePropertyKey
train
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
{ "resource": "" }
q7830
Validator.isRestrictedEventName
train
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
{ "resource": "" }
q7831
Validator._mergeListInternalForKey
train
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
{ "resource": "" }
q7832
DeviceInfo.initDeviceID
train
@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
{ "resource": "" }
q7833
Logger.i
train
static void i(String message){ if (getStaticDebugLevel() >= CleverTapAPI.LogLevel.INFO.intValue()){ Log.i(Constants.CLEVERTAP_LOG_TAG,message); } }
java
{ "resource": "" }
q7834
CTInboxBaseMessageViewHolder.calculateDisplayTimestamp
train
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
{ "resource": "" }
q7835
CTInboxStyleConfig.setTabs
train
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
{ "resource": "" }
q7836
EventHandler.push
train
@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
{ "resource": "" }
q7837
CTInboxMessage.getCarouselImages
train
public ArrayList<String> getCarouselImages(){ ArrayList<String> carouselImages = new ArrayList<>(); for(CTInboxMessageContent ctInboxMessageContent: getInboxMessageContents()){ carouselImages.add(ctInboxMessageContent.getMedia()); } return carouselImages; }
java
{ "resource": "" }
q7838
DBAdapter.storeObject
train
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
{ "resource": "" }
q7839
DBAdapter.storeUserProfile
train
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
{ "resource": "" }
q7840
DBAdapter.removeUserProfile
train
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
{ "resource": "" }
q7841
DBAdapter.removeEvents
train
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
{ "resource": "" }
q7842
DBAdapter.fetchEvents
train
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
{ "resource": "" }
q7843
DBAdapter.storeUninstallTimestamp
train
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
{ "resource": "" }
q7844
DBAdapter.deleteMessageForId
train
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
{ "resource": "" }
q7845
DBAdapter.markReadMessageForId
train
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
{ "resource": "" }
q7846
DBAdapter.getMessages
train
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
{ "resource": "" }
q7847
GifHeaderParser.readContents
train
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
{ "resource": "" }
q7848
GifHeaderParser.readBitmap
train
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
{ "resource": "" }
q7849
GifHeaderParser.readNetscapeExt
train
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
{ "resource": "" }
q7850
GifHeaderParser.readLSD
train
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
{ "resource": "" }
q7851
GifHeaderParser.readColorTable
train
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
{ "resource": "" }
q7852
GifHeaderParser.skip
train
private void skip() { try { int blockSize; do { blockSize = read(); rawData.position(rawData.position() + blockSize); } while (blockSize > 0); } catch (IllegalArgumentException ex) { } }
java
{ "resource": "" }
q7853
GifHeaderParser.read
train
private int read() { int curByte = 0; try { curByte = rawData.get() & 0xFF; } catch (Exception e) { header.status = GifDecoder.STATUS_FORMAT_ERROR; } return curByte; }
java
{ "resource": "" }
q7854
TreeScanner.isToIgnore
train
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
{ "resource": "" }
q7855
Json4SpoonGenerator.getJSONwithOperations
train
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
{ "resource": "" }
q7856
ActionClassifier.getRootActions
train
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
{ "resource": "" }
q7857
AstComparator.compare
train
public Diff compare(File f1, File f2) throws Exception { return this.compare(getCtType(f1), getCtType(f2)); }
java
{ "resource": "" }
q7858
AstComparator.compare
train
public Diff compare(String left, String right) { return compare(getCtType(left), getCtType(right)); }
java
{ "resource": "" }
q7859
AstComparator.compare
train
public Diff compare(CtElement left, CtElement right) { final SpoonGumTreeBuilder scanner = new SpoonGumTreeBuilder(); return new DiffImpl(scanner.getTreeContext(), scanner.getTree(left), scanner.getTree(right)); }
java
{ "resource": "" }
q7860
ArrayAdapterCompat.set
train
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
{ "resource": "" }
q7861
ArrayAdapterCompat.addAll
train
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
{ "resource": "" }
q7862
ArrayAdapterCompat.removeAt
train
public void removeAt(int index) { synchronized (mLock) { if (mOriginalValues != null) { mOriginalValues.remove(index); } else { mObjects.remove(index); } } if (mNotifyOnChange) notifyDataSetChanged(); }
java
{ "resource": "" }
q7863
ArrayAdapterCompat.removeAll
train
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
{ "resource": "" }
q7864
AdvancedRecyclerArrayAdapter.addAll
train
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
{ "resource": "" }
q7865
AdvancedRecyclerArrayAdapter.getItem
train
@Nullable public T getItem(final int position) { if (position < 0 || position >= mObjects.size()) { return null; } return mObjects.get(position); }
java
{ "resource": "" }
q7866
AdvancedRecyclerArrayAdapter.replaceItem
train
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
{ "resource": "" }
q7867
ViewUtils.hideSystemUI
train
@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
{ "resource": "" }
q7868
ViewUtils.showSystemUI
train
@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
{ "resource": "" }
q7869
AdapterWrapper.getView
train
@Override public View getView(int position, View convertView, ViewGroup parent) { return (wrapped.getView(position, convertView, parent)); }
java
{ "resource": "" }
q7870
ProgressDialogFragment.onDismiss
train
@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
{ "resource": "" }
q7871
ReflectionUtils.isToStringMethod
train
public static boolean isToStringMethod(Method method) { return (method != null && method.getName().equals("readString") && method.getParameterTypes().length == 0); }
java
{ "resource": "" }
q7872
ReflectionUtils.getUniqueDeclaredMethods
train
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
{ "resource": "" }
q7873
WeakFastHashMap.put
train
@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
{ "resource": "" }
q7874
WeakFastHashMap.putAll
train
@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
{ "resource": "" }
q7875
WeakFastHashMap.remove
train
@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
{ "resource": "" }
q7876
IOUtils.isFileExist
train
public static boolean isFileExist(String filePath) { if (StringUtils.isEmpty(filePath)) { return false; } File file = new File(filePath); return (file.exists() && file.isFile()); }
java
{ "resource": "" }
q7877
IOUtils.isFolderExist
train
public static boolean isFolderExist(String directoryPath) { if (StringUtils.isEmpty(directoryPath)) { return false; } File dire = new File(directoryPath); return (dire.exists() && dire.isDirectory()); }
java
{ "resource": "" }
q7878
AndroidUtils.addToMediaStore
train
public static void addToMediaStore(Context context, File file) { String[] path = new String[]{file.getPath()}; MediaScannerConnection.scanFile(context, path, null, null); }
java
{ "resource": "" }
q7879
CountingInputStream.skip
train
@Override public synchronized long skip(final long length) throws IOException { final long skip = super.skip(length); this.count += skip; return skip; }
java
{ "resource": "" }
q7880
HeaderFooterRecyclerAdapter.notifyHeaderItemRangeInserted
train
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
{ "resource": "" }
q7881
HeaderFooterRecyclerAdapter.notifyHeaderItemChanged
train
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
{ "resource": "" }
q7882
HeaderFooterRecyclerAdapter.notifyHeaderItemRangeChanged
train
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
{ "resource": "" }
q7883
HeaderFooterRecyclerAdapter.notifyHeaderItemMoved
train
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
{ "resource": "" }
q7884
HeaderFooterRecyclerAdapter.notifyHeaderItemRangeRemoved
train
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
{ "resource": "" }
q7885
HeaderFooterRecyclerAdapter.notifyContentItemInserted
train
public final void notifyContentItemInserted(int position) { int newHeaderItemCount = getHeaderItemCount(); int newContentItemCount = getContentItemCount(); if (position < 0 || position >= newContentItemCount) { throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for content items [0 - " + (newContentItemCount - 1) + "]."); } notifyItemInserted(position + newHeaderItemCount); }
java
{ "resource": "" }
q7886
HeaderFooterRecyclerAdapter.notifyContentItemRangeInserted
train
public final void notifyContentItemRangeInserted(int positionStart, int itemCount) { int newHeaderItemCount = getHeaderItemCount(); int newContentItemCount = getContentItemCount(); if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newContentItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - " + (newContentItemCount - 1) + "]."); } notifyItemRangeInserted(positionStart + newHeaderItemCount, itemCount); }
java
{ "resource": "" }
q7887
HeaderFooterRecyclerAdapter.notifyContentItemChanged
train
public final void notifyContentItemChanged(int position) { if (position < 0 || position >= contentItemCount) { throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "]."); } notifyItemChanged(position + headerItemCount); }
java
{ "resource": "" }
q7888
HeaderFooterRecyclerAdapter.notifyContentItemRangeChanged
train
public final void notifyContentItemRangeChanged(int positionStart, int itemCount) { if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > contentItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "]."); } notifyItemRangeChanged(positionStart + headerItemCount, itemCount); }
java
{ "resource": "" }
q7889
HeaderFooterRecyclerAdapter.notifyContentItemMoved
train
public final void notifyContentItemMoved(int fromPosition, int toPosition) { if (fromPosition < 0 || toPosition < 0 || fromPosition >= contentItemCount || toPosition >= contentItemCount) { throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "]."); } notifyItemMoved(fromPosition + headerItemCount, toPosition + headerItemCount); }
java
{ "resource": "" }
q7890
HeaderFooterRecyclerAdapter.notifyContentItemRemoved
train
public final void notifyContentItemRemoved(int position) { if (position < 0 || position >= contentItemCount) { throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "]."); } notifyItemRemoved(position + headerItemCount); }
java
{ "resource": "" }
q7891
HeaderFooterRecyclerAdapter.notifyContentItemRangeRemoved
train
public final void notifyContentItemRangeRemoved(int positionStart, int itemCount) { if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > contentItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for content items [0 - " + (contentItemCount - 1) + "]."); } notifyItemRangeRemoved(positionStart + headerItemCount, itemCount); }
java
{ "resource": "" }
q7892
HeaderFooterRecyclerAdapter.notifyFooterItemInserted
train
public final void notifyFooterItemInserted(int position) { int newHeaderItemCount = getHeaderItemCount(); int newContentItemCount = getContentItemCount(); int newFooterItemCount = getFooterItemCount(); // if (position < 0 || position >= newFooterItemCount) { // throw new IndexOutOfBoundsException("The given position " + position // + " is not within the position bounds for footer items [0 - " // + (newFooterItemCount - 1) + "]."); // } notifyItemInserted(position + newHeaderItemCount + newContentItemCount); }
java
{ "resource": "" }
q7893
HeaderFooterRecyclerAdapter.notifyFooterItemRangeInserted
train
public final void notifyFooterItemRangeInserted(int positionStart, int itemCount) { int newHeaderItemCount = getHeaderItemCount(); int newContentItemCount = getContentItemCount(); int newFooterItemCount = getFooterItemCount(); if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newFooterItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - " + (newFooterItemCount - 1) + "]."); } notifyItemRangeInserted(positionStart + newHeaderItemCount + newContentItemCount, itemCount); }
java
{ "resource": "" }
q7894
HeaderFooterRecyclerAdapter.notifyFooterItemChanged
train
public final void notifyFooterItemChanged(int position) { if (position < 0 || position >= footerItemCount) { throw new IndexOutOfBoundsException("The given position " + position + " is not within the position bounds for footer items [0 - " + (footerItemCount - 1) + "]."); } notifyItemChanged(position + headerItemCount + contentItemCount); }
java
{ "resource": "" }
q7895
HeaderFooterRecyclerAdapter.notifyFooterItemRangeChanged
train
public final void notifyFooterItemRangeChanged(int positionStart, int itemCount) { if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - " + (footerItemCount - 1) + "]."); } notifyItemRangeChanged(positionStart + headerItemCount + contentItemCount, itemCount); }
java
{ "resource": "" }
q7896
HeaderFooterRecyclerAdapter.notifyFooterItemMoved
train
public final void notifyFooterItemMoved(int fromPosition, int toPosition) { if (fromPosition < 0 || toPosition < 0 || fromPosition >= footerItemCount || toPosition >= footerItemCount) { throw new IndexOutOfBoundsException("The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not within the position bounds for footer items [0 - " + (footerItemCount - 1) + "]."); } notifyItemMoved(fromPosition + headerItemCount + contentItemCount, toPosition + headerItemCount + contentItemCount); }
java
{ "resource": "" }
q7897
HeaderFooterRecyclerAdapter.notifyFooterItemRangeRemoved
train
public final void notifyFooterItemRangeRemoved(int positionStart, int itemCount) { if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - " + (footerItemCount - 1) + "]."); } notifyItemRangeRemoved(positionStart + headerItemCount + contentItemCount, itemCount); }
java
{ "resource": "" }
q7898
AdapterExtend.getView
train
@Override public View getView(int position, View convertView, ViewGroup parent) { if (position == super.getCount() && isEnableRefreshing()) { return (mFooter); } return (super.getView(position, convertView, parent)); }
java
{ "resource": "" }
q7899
StringUtils.addStringToArray
train
public static String[] addStringToArray(String[] array, String str) { if (isEmpty(array)) { return new String[]{str}; } String[] newArr = new String[array.length + 1]; System.arraycopy(array, 0, newArr, 0, array.length); newArr[array.length] = str; return newArr; }
java
{ "resource": "" }