urbanairship-core/src/main/java/com/urbanairship/analytics/data/EventManager.java
@WorkerThread
    public boolean uploadEvents(UAirship airship) {
        isScheduled = false;
        preferenceDataStore.put(LAST_SEND_KEY, System.currentTimeMillis());

        final int eventCount = eventResolver.getEventCount();

        if (eventCount <= 0) {
            Logger.debug("EventManager - No events to send.");
            return true;
        }

        final int avgSize = eventResolver.getDatabaseSize() / eventCount;

        //pull enough events to fill a batch (roughly)
        int batchEventCount = Math.min(MAX_BATCH_EVENT_COUNT, preferenceDataStore.getInt(MAX_BATCH_SIZE_KEY, EventResponse.MAX_BATCH_SIZE_BYTES) / avgSize);
        Map<String, String> events = eventResolver.getEvents(batchEventCount);

        EventResponse response = apiClient.sendEvents(airship, events.values());

        if (response == null || response.getStatus() != 200) {
            Logger.debug("EventManager - Analytic upload failed.");
            return false;
        }

        Logger.debug("EventManager - Analytic events uploaded.");
        eventResolver.deleteEvents(events.keySet());

        // Update preferences
        preferenceDataStore.put(MAX_TOTAL_DB_SIZE_KEY, response.getMaxTotalSize());
        preferenceDataStore.put(MAX_BATCH_SIZE_KEY, response.getMaxBatchSize());
        preferenceDataStore.put(MIN_BATCH_INTERVAL_KEY, response.getMinBatchInterval());

        // If there are still events left, schedule the next send
        if (eventCount - events.size() > 0) {
            scheduleEventUpload(MULTIPLE_BATCH_DELAY, TimeUnit.MILLISECONDS);
        }

        return true;
    }
/**
     * Uploads events.
     *
     * @param airship The airship instance.
     * @return {@code true} if the events uploaded, otherwise {@code false}.
     */
Uploads events.
@param airship The airship instance.
@return  true if the events uploaded, otherwise  false.
Uploads events . @param airship The airship instance . @return true if the events uploaded otherwise false .
@WorkerThread
    public boolean uploadEvents(UAirship airship) {
        isScheduled = false;
        preferenceDataStore.put(LAST_SEND_KEY, System.currentTimeMillis());
        final int eventCount = eventResolver.getEventCount();
        if (eventCount <= 0) {
            Logger.debug("EventManager - No events to send.");
            return true;
        }
        final int avgSize = eventResolver.getDatabaseSize() / eventCount;
        int batchEventCount = Math.min(MAX_BATCH_EVENT_COUNT, preferenceDataStore.getInt(MAX_BATCH_SIZE_KEY, EventResponse.MAX_BATCH_SIZE_BYTES) / avgSize);
        Map<String, String> events = eventResolver.getEvents(batchEventCount);
        EventResponse response = apiClient.sendEvents(airship, events.values());
        if (response == null || response.getStatus() != 200) {
            Logger.debug("EventManager - Analytic upload failed.");
            return false;
        }
        Logger.debug("EventManager - Analytic events uploaded.");
        eventResolver.deleteEvents(events.keySet());
        preferenceDataStore.put(MAX_TOTAL_DB_SIZE_KEY, response.getMaxTotalSize());
        preferenceDataStore.put(MAX_BATCH_SIZE_KEY, response.getMaxBatchSize());
        preferenceDataStore.put(MIN_BATCH_INTERVAL_KEY, response.getMinBatchInterval());
        if (eventCount - events.size() > 0) {
            scheduleEventUpload(MULTIPLE_BATCH_DELAY, TimeUnit.MILLISECONDS);
        }
        return true;
    }
@ WorkerThread public boolean uploadEvents ( UAirship airship ) { isScheduled = false ; preferenceDataStore . put ( LAST_SEND_KEY , System . currentTimeMillis ( ) ) ; final int eventCount = eventResolver . getEventCount ( ) ; if ( eventCount <= 0 ) { Logger . debug ( "EventManager - No events to send." ) ; return true ; } final int avgSize = eventResolver . getDatabaseSize ( ) / eventCount ; int batchEventCount = Math . min ( MAX_BATCH_EVENT_COUNT , preferenceDataStore . getInt ( MAX_BATCH_SIZE_KEY , EventResponse . MAX_BATCH_SIZE_BYTES ) / avgSize ) ; Map < String , String > events = eventResolver . getEvents ( batchEventCount ) ; EventResponse response = apiClient . sendEvents ( airship , events . values ( ) ) ; if ( response == null || response . getStatus ( ) != 200 ) { Logger . debug ( "EventManager - Analytic upload failed." ) ; return false ; } Logger . debug ( "EventManager - Analytic events uploaded." ) ; eventResolver . deleteEvents ( events . keySet ( ) ) ; preferenceDataStore . put ( MAX_TOTAL_DB_SIZE_KEY , response . getMaxTotalSize ( ) ) ; preferenceDataStore . put ( MAX_BATCH_SIZE_KEY , response . getMaxBatchSize ( ) ) ; preferenceDataStore . put ( MIN_BATCH_INTERVAL_KEY , response . getMinBatchInterval ( ) ) ; if ( eventCount - events . size ( ) > 0 ) { scheduleEventUpload ( MULTIPLE_BATCH_DELAY , TimeUnit . MILLISECONDS ) ; } return true ; }
Uploads events.
Uploads events .
//pull enough events to fill a batch (roughly) // Update preferences // If there are still events left, schedule the next send