idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
27,500
private void initialize ( Handler callbackHandler ) { int processors = Runtime . getRuntime ( ) . availableProcessors ( ) ; mDownloadDispatchers = new DownloadDispatcher [ processors ] ; mDelivery = new CallBackDelivery ( callbackHandler ) ; }
Perform construction .
27,501
private void initialize ( Handler callbackHandler , int threadPoolSize ) { mDownloadDispatchers = new DownloadDispatcher [ threadPoolSize ] ; mDelivery = new CallBackDelivery ( callbackHandler ) ; }
Perform construction with custom thread pool size .
27,502
private void stop ( ) { for ( int i = 0 ; i < mDownloadDispatchers . length ; i ++ ) { if ( mDownloadDispatchers [ i ] != null ) { mDownloadDispatchers [ i ] . quit ( ) ; } } }
Stops download dispatchers .
27,503
@ SuppressWarnings ( "unchecked" ) public Map < String , Field > getValueAsMap ( ) { return ( Map < String , Field > ) type . convert ( getValue ( ) , Type . MAP ) ; }
Returns the Map value of the field .
27,504
@ SuppressWarnings ( "unchecked" ) public List < Field > getValueAsList ( ) { return ( List < Field > ) type . convert ( getValue ( ) , Type . LIST ) ; }
Returns the List value of the field .
27,505
@ SuppressWarnings ( "unchecked" ) public LinkedHashMap < String , Field > getValueAsListMap ( ) { return ( LinkedHashMap < String , Field > ) type . convert ( getValue ( ) , Type . LIST_MAP ) ; }
Returns the ordered Map value of the field .
27,506
public Set < String > getAttributeNames ( ) { if ( attributes == null ) { return Collections . emptySet ( ) ; } else { return Collections . unmodifiableSet ( attributes . keySet ( ) ) ; } }
Returns the list of user defined attribute names .
27,507
public Map < String , String > getAttributes ( ) { if ( attributes == null ) { return null ; } else { return Collections . unmodifiableMap ( attributes ) ; } }
Get all field attributes in an unmodifiable Map or null if no attributes have been added
27,508
public static Object formatL ( final String template , final Object ... args ) { return new Object ( ) { public String toString ( ) { return format ( template , args ) ; } } ; }
format with lazy - eval
27,509
public List < ConfigIssue > init ( Service . Context context ) { this . context = context ; return init ( ) ; }
Initializes the service .
27,510
public Object put ( List < Map . Entry > batch ) throws InterruptedException { if ( initializeClusterSource ( ) ) { return clusterSource . put ( batch ) ; } return null ; }
Writes batch of data to the source
27,511
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 ) ; } }
Evaluates an EL .
27,512
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 "" ; } }
Returns the text for the JSONObject of Link provided The JSONObject of Link provided should be of the type copy
27,513
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 ; } }
Returns the text for the JSONObject of Link provided The JSONObject of Link provided should be of the type url
27,514
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 ; } }
Returns the text color for the JSONObject of Link provided
27,515
static void onActivityCreated ( Activity activity ) { 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 ; 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 ) { } 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 ) { } } } catch ( Throwable t ) { } 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 ) { } } break ; } } }
static lifecycle callbacks
27,516
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 ) { } 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 ; } } }
other static handlers
27,517
public static CleverTapAPI getInstance ( Context context ) throws CleverTapMetaDataNotFoundException , CleverTapPermissionsNotSatisfied { sdkVersion = BuildConfig . SDK_VERSION_STRING ; return getDefaultInstance ( context ) ; }
Returns an instance of the CleverTap SDK .
27,518
@ SuppressWarnings ( "WeakerAccess" ) public static CleverTapAPI getDefaultInstance ( Context context ) { 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 ) ; }
Returns the default shared instance of the CleverTap SDK .
27,519
private void destroySession ( ) { currentSessionId = 0 ; setAppLaunchPushed ( false ) ; getConfigLogger ( ) . verbose ( getAccountId ( ) , "Session destroyed; Session ID is now 0" ) ; clearSource ( ) ; clearMedium ( ) ; clearCampaign ( ) ; clearWzrkParams ( ) ; }
Destroys the current session
27,520
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 ; }
request token from FCM
27,521
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 ; }
request token from GCM
27,522
@ 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 ( ) ; } }
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 .
27,523
@ 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 ) ; }
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 .
27,524
@ SuppressWarnings ( "unused" ) public String getDevicePushToken ( final PushType type ) { switch ( type ) { case GCM : return getCachedGCMToken ( ) ; case FCM : return getCachedFCMToken ( ) ; default : return null ; } }
Returns the device push token or null
27,525
private void attachMeta ( final JSONObject o , final Context context ) { try { o . put ( "mc" , Utils . getMemoryConsumption ( ) ) ; } catch ( Throwable t ) { } try { o . put ( "nt" , Utils . getCurrentNetworkType ( context ) ) ; } catch ( Throwable t ) { } }
Attaches meta info about the current state of the device to an event . Typically this meta is added only to the ping event .
27,526
@ 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 ) ; }
Record a Screen View event
27,527
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 ) ; } }
Only call async
27,528
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 ; }
helper extracts the cursor data from the db object
27,529
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 ; } }
The ARP is additional request parameters which must be sent once received after any HTTP call . This is sort of a proxy for cookies .
27,530
@ SuppressWarnings ( { "unused" , "WeakerAccess" } ) public int getTotalVisits ( ) { EventDetail ed = getLocalDataStore ( ) . getEventDetail ( Constants . APP_LAUNCHED_EVENT ) ; if ( ed != null ) return ed . getCount ( ) ; return 0 ; }
Returns the total number of times the app has been launched
27,531
@ SuppressWarnings ( { "unused" , "WeakerAccess" } ) public int getTimeElapsed ( ) { int currentSession = getCurrentSession ( ) ; if ( currentSession == 0 ) return - 1 ; int now = ( int ) ( System . currentTimeMillis ( ) / 1000 ) ; return now - currentSession ; }
Returns the time elapsed by the user on the app
27,532
@ SuppressWarnings ( { "unused" , "WeakerAccess" } ) public UTMDetail getUTMDetails ( ) { UTMDetail ud = new UTMDetail ( ) ; ud . setSource ( source ) ; ud . setMedium ( medium ) ; ud . setCampaign ( campaign ) ; return ud ; }
Returns a UTMDetail object which consists of UTM parameters like source medium & campaign
27,533
private void _handleMultiValues ( ArrayList < String > values , String key , String command ) { if ( key == null ) return ; if ( values == null || values . isEmpty ( ) ) { _generateEmptyMultiValueError ( key ) ; return ; } ValidationResult vr ; vr = validator . cleanMultiValuePropertyKey ( key ) ; if ( vr . getErrorCode ( ) != 0 ) { pushValidationResult ( vr ) ; } Object _key = vr . getObject ( ) ; String cleanKey = ( _key != null ) ? vr . getObject ( ) . toString ( ) : null ; 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 multi - value handlers and helpers
27,534
@ SuppressWarnings ( { "unused" , "WeakerAccess" } ) public void pushEvent ( String eventName ) { if ( eventName == null || eventName . trim ( ) . equals ( "" ) ) return ; pushEvent ( eventName , null ) ; }
Pushes a basic event .
27,535
@ 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 ; } 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 ) { } queueEvent ( context , event , Constants . RAISED_EVENT ) ; }
Pushes the Notification Viewed event to CleverTap .
27,536
@ SuppressWarnings ( { "unused" , "WeakerAccess" } ) public int getCount ( String event ) { EventDetail eventDetail = getLocalDataStore ( ) . getEventDetail ( event ) ; if ( eventDetail != null ) return eventDetail . getCount ( ) ; return - 1 ; }
Returns the total count of the specified event
27,537
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
27,538
@ 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 ) ; }
Checks whether this notification is from CleverTap .
27,539
@ SuppressWarnings ( { "unused" , "WeakerAccess" } ) public void pushInstallReferrer ( Intent intent ) { try { final Bundle extras = intent . getExtras ( ) ; 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 ) { 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 ) { } }
This method is used to push install referrer via Intent
27,540
@ SuppressWarnings ( { "unused" , "WeakerAccess" } ) public synchronized void pushInstallReferrer ( String source , String medium , String campaign ) { if ( source == null && medium == null && campaign == null ) return ; try { 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 ) ; } }
This method is used to push install referrer via UTM source medium & campaign parameters
27,541
@ 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
27,542
@ 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 ) ; }
This method is used to change the credentials of CleverTap account Id token and region programmatically
27,543
@ 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 ; } } }
Returns the count of all inbox messages for the user
27,544
@ 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 ; } } }
Returns the count of total number of unread inbox messages for the user
27,545
@ SuppressWarnings ( { "unused" , "WeakerAccess" } ) public void markReadInboxMessage ( final CTInboxMessage message ) { postAsyncSafely ( "markReadInboxMessage" , new Runnable ( ) { 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" ) ; } } } } ) ; }
marks the message as read
27,546
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 ; }
Move the animation frame counter forward .
27,547
int getDelay ( int n ) { int delay = - 1 ; if ( ( n >= 0 ) && ( n < header . frameCount ) ) { delay = header . frames . get ( n ) . delay ; } return delay ; }
Gets display duration for specified frame .
27,548
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
27,549
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 ; }
Reads GIF image from stream .
27,550
synchronized int read ( byte [ ] data ) { this . header = getHeaderParser ( ) . setData ( data ) . parseHeader ( ) ; if ( data != null ) { setData ( header , data ) ; } return status ; }
Reads GIF image from byte array .
27,551
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 ) ; }
Reads the next chunk for the intermediate work buffer .
27,552
@ 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 ( ) { public void onActivityCreated ( Activity activity , Bundle bundle ) { CleverTapAPI . onActivityCreated ( activity ) ; } public void onActivityStarted ( Activity activity ) { } public void onActivityResumed ( Activity activity ) { CleverTapAPI . onActivityResumed ( activity ) ; } public void onActivityPaused ( Activity activity ) { CleverTapAPI . onActivityPaused ( ) ; } public void onActivityStopped ( Activity activity ) { } public void onActivitySaveInstanceState ( Activity activity , Bundle bundle ) { } public void onActivityDestroyed ( Activity activity ) { } } ) ; Logger . i ( "Activity Lifecycle Callback successfully registered" ) ; }
Enables lifecycle callbacks for Android devices
27,553
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 ; }
Cleans the object key .
27,554
ValidationResult cleanMultiValuePropertyKey ( String name ) { ValidationResult vr = cleanObjectKey ( name ) ; name = ( String ) vr . getObject ( ) ; try { RestrictedMultiValueFields rf = RestrictedMultiValueFields . valueOf ( name ) ; 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 ) { } return vr ; }
Cleans a multi - value property key .
27,555
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 ) ) { 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 ; }
Checks whether the specified event name is restricted . If it is then create a pending error and abort .
27,556
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 ) { } } 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 ) { } } } 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 ; }
scans right to left until max to maintain latest max values for the multi - value property specified by key .
27,557
@ SuppressWarnings ( { "WeakerAccess" } ) protected void initDeviceID ( ) { getDeviceCachedInfo ( ) ; generateProvisionalGUID ( ) ; cacheGoogleAdID ( ) ; String deviceID = getDeviceID ( ) ; if ( deviceID == null || deviceID . trim ( ) . length ( ) <= 2 ) { generateDeviceID ( ) ; } }
don t run on main thread
27,558
static void i ( String message ) { if ( getStaticDebugLevel ( ) >= CleverTapAPI . LogLevel . INFO . intValue ( ) ) { Log . i ( Constants . CLEVERTAP_LOG_TAG , message ) ; } }
Logs to Info if the debug level is greater than or equal to 1 .
27,559
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 ) ) ; } }
Logic for timestamp
27,560
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" ) ; } }
Sets the name of the optional two tabs . The contents of the tabs are filtered based on the name of the tab .
27,561
@ SuppressWarnings ( "deprecation" ) public void push ( String eventName , HashMap < String , Object > chargeDetails , ArrayList < HashMap < String , Object > > items ) throws InvalidEventNameException { 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 ) ; } }
Push an event which describes a purchase made .
27,562
public ArrayList < String > getCarouselImages ( ) { ArrayList < String > carouselImages = new ArrayList < > ( ) ; for ( CTInboxMessageContent ctInboxMessageContent : getInboxMessageContents ( ) ) { carouselImages . add ( ctInboxMessageContent . getMedia ( ) ) ; } return carouselImages ; }
Returns an ArrayList of String URLs of the Carousel Images
27,563
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 ; 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 ; }
Adds a JSON string to the DB .
27,564
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 ; }
Adds a JSON string representing to the DB .
27,565
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 ( ) ; } }
remove the user profile with id from the db .
27,566
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 ( ) ; } }
Removes all events from table
27,567
synchronized JSONObject fetchEvents ( Table table , final int limit ) { final String tName = table . getName ( ) ; Cursor cursor = null ; String lastId = null ; final JSONArray events = new JSONArray ( ) ; 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 ) { } } } 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 ) { } } return null ; }
Returns a JSONObject keyed with the lastId retrieved and a value of a JSONArray of the retrieved JSONObject events
27,568
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 ( ) ; } }
Adds a String timestamp representing uninstall flag to the DB .
27,569
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 ( ) ; } }
Deletes the inbox message for given messageId
27,570
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 ( ) ; } }
Marks inbox message as read for given messageId
27,571
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 ( ) ; } }
Retrieves list of inbox messages based on given userId
27,572
private void readContents ( int maxFrames ) { boolean done = false ; while ( ! ( done || err ( ) || header . frameCount > maxFrames ) ) { int code = read ( ) ; switch ( code ) { case 0x2C : if ( header . currentFrame == null ) { header . currentFrame = new GifFrame ( ) ; } readBitmap ( ) ; break ; case 0x21 : code = read ( ) ; switch ( code ) { case 0xf9 : header . currentFrame = new GifFrame ( ) ; readGraphicControlExt ( ) ; break ; case 0xff : readBlock ( ) ; String app = "" ; for ( int i = 0 ; i < 11 ; i ++ ) { app += ( char ) block [ i ] ; } if ( app . equals ( "NETSCAPE2.0" ) ) { readNetscapeExt ( ) ; } else { skip ( ) ; } break ; case 0xfe : skip ( ) ; break ; case 0x01 : skip ( ) ; break ; default : skip ( ) ; } break ; case 0x3b : done = true ; break ; case 0x00 : default : header . status = GifDecoder . STATUS_FORMAT_ERROR ; } } }
Main file parser . Reads GIF content blocks . Stops after reading maxFrames
27,573
private void readBitmap ( ) { header . currentFrame . ix = readShort ( ) ; header . currentFrame . iy = readShort ( ) ; header . currentFrame . iw = readShort ( ) ; header . currentFrame . ih = readShort ( ) ; int packed = read ( ) ; boolean lctFlag = ( packed & 0x80 ) != 0 ; int lctSize = ( int ) Math . pow ( 2 , ( packed & 0x07 ) + 1 ) ; header . currentFrame . interlace = ( packed & 0x40 ) != 0 ; if ( lctFlag ) { header . currentFrame . lct = readColorTable ( lctSize ) ; } else { header . currentFrame . lct = null ; } header . currentFrame . bufferFrameStart = rawData . position ( ) ; skipImageData ( ) ; if ( err ( ) ) { return ; } header . frameCount ++ ; header . frames . add ( header . currentFrame ) ; }
Reads next frame image .
27,574
private void readNetscapeExt ( ) { do { readBlock ( ) ; if ( block [ 0 ] == 1 ) { 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 ( ) ) ; }
Reads Netscape extension to obtain iteration count .
27,575
private void readLSD ( ) { header . width = readShort ( ) ; header . height = readShort ( ) ; int packed = read ( ) ; header . gctFlag = ( packed & 0x80 ) != 0 ; header . gctSize = 2 << ( packed & 7 ) ; header . bgIndex = read ( ) ; header . pixelAspect = read ( ) ; }
Reads Logical Screen Descriptor .
27,576
private int [ ] readColorTable ( int ncolors ) { int nbytes = 3 * ncolors ; int [ ] tab = null ; byte [ ] c = new byte [ nbytes ] ; try { rawData . get ( c ) ; 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 ) { Logger . d ( TAG , "Format Error Reading Color Table" , e ) ; header . status = GifDecoder . STATUS_FORMAT_ERROR ; } return tab ; }
Reads color table as 256 RGB integer values .
27,577
private void skip ( ) { try { int blockSize ; do { blockSize = read ( ) ; rawData . position ( rawData . position ( ) + blockSize ) ; } while ( blockSize > 0 ) ; } catch ( IllegalArgumentException ex ) { } }
Skips variable length blocks up to and including next zero length block .
27,578
private int read ( ) { int curByte = 0 ; try { curByte = rawData . get ( ) & 0xFF ; } catch ( Exception e ) { header . status = GifDecoder . STATUS_FORMAT_ERROR ; } return curByte ; }
Reads a single byte from the input stream .
27,579
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 ; }
Ignore some element from the AST
27,580
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 ) ; }
Decorates a node with the affected operator if any .
27,581
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 ; }
This method retrieves ONLY the ROOT actions
27,582
public Diff compare ( File f1 , File f2 ) throws Exception { return this . compare ( getCtType ( f1 ) , getCtType ( f2 ) ) ; }
compares two java files
27,583
public Diff compare ( String left , String right ) { return compare ( getCtType ( left ) , getCtType ( right ) ) ; }
compares two snippet
27,584
public Diff compare ( CtElement left , CtElement right ) { final SpoonGumTreeBuilder scanner = new SpoonGumTreeBuilder ( ) ; return new DiffImpl ( scanner . getTreeContext ( ) , scanner . getTree ( left ) , scanner . getTree ( right ) ) ; }
compares two AST nodes
27,585
public void set ( int index , T object ) { synchronized ( mLock ) { if ( mOriginalValues != null ) { mOriginalValues . set ( index , object ) ; } else { mObjects . set ( index , object ) ; } } if ( mNotifyOnChange ) notifyDataSetChanged ( ) ; }
set the specified object at index
27,586
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 ( ) ; }
Inserts the specified objects at the specified index in the array .
27,587
public void removeAt ( int index ) { synchronized ( mLock ) { if ( mOriginalValues != null ) { mOriginalValues . remove ( index ) ; } else { mObjects . remove ( index ) ; } } if ( mNotifyOnChange ) notifyDataSetChanged ( ) ; }
Removes the specified object in index from the array .
27,588
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 ; }
Removes the specified objects .
27,589
public void addAll ( 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 ) ; } }
Adds the specified list of objects at the end of the array .
27,590
public T getItem ( final int position ) { if ( position < 0 || position >= mObjects . size ( ) ) { return null ; } return mObjects . get ( position ) ; }
Returns the item at the specified position .
27,591
public void replaceItem ( final T oldObject , final T newObject ) { synchronized ( mLock ) { final int position = getPosition ( oldObject ) ; if ( position == - 1 ) { return ; } mObjects . remove ( position ) ; mObjects . add ( position , newObject ) ; if ( isItemTheSame ( oldObject , newObject ) ) { if ( isContentTheSame ( oldObject , newObject ) ) { return ; } notifyItemChanged ( position , newObject ) ; } else { notifyItemRemoved ( position ) ; notifyItemInserted ( position ) ; } } }
replaces the old with the new item . The new item will not be added when the old one is not found .
27,592
@ TargetApi ( VERSION_CODES . KITKAT ) public static void hideSystemUI ( 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 | View . SYSTEM_UI_FLAG_HIDE_NAVIGATION | View . SYSTEM_UI_FLAG_FULLSCREEN | View . SYSTEM_UI_FLAG_IMMERSIVE ) ; }
This intro hides the system bars .
27,593
@ 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 ) ; }
except for the ones that make the content appear under the system bars .
27,594
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 .
27,595
public void onDismiss ( DialogInterface dialog ) { if ( mOldDialog != null && mOldDialog == dialog ) { return ; } super . onDismiss ( dialog ) ; }
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 .
27,596
public static boolean isToStringMethod ( Method method ) { return ( method != null && method . getName ( ) . equals ( "readString" ) && method . getParameterTypes ( ) . length == 0 ) ; }
Determine whether the given method is a readString method .
27,597
public static Method [ ] getUniqueDeclaredMethods ( Class < ? > leafClass ) throws IllegalArgumentException { final List < Method > methods = new ArrayList < Method > ( 32 ) ; doWithMethods ( leafClass , new MethodCallback ( ) { 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 ( ) ) ) { 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 ( ) ] ) ; }
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 .
27,598
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 ) ) ; } } }
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 .
27,599
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 ) ; } } }
Copy all of the mappings from the specified map to this one replacing any mappings with the same keys .