app/src/main/java/org/andstatus/app/service/CommandExecutorFollowers.java
/**
     * @return true if we need to interrupt process
     */
@return true if we need to interrupt process
@return true if we need to interrupt process
private boolean updateNewActorsAndTheirLatestActions(List<Actor> actorsNew) {
        DataUpdater dataUpdater = new DataUpdater(execContext);
        long count = 0;
        for (Actor actor : actorsNew) {
            if (actor.hasLatestNote()) continue;
            count++;
            Exception exception = null;
            try {
                broadcastProgress(String.valueOf(count) + ". "
                        + execContext.getContext().getText(R.string.title_command_get_status)
                        + ": " + actor.getUniqueNameWithOrigin(), true);
                dataUpdater.downloadOneNoteBy(actor);
                execContext.getResult().incrementDownloadedCount();
            } catch (Exception e) {
                exception = e;
            }
            long lastActivityId = MyQuery.actorIdToLongColumnValue(ActorTable.ACTOR_ACTIVITY_ID, actor.actorId);
            if (lastActivityId == 0) {
                lastActivityId = MyQuery.conditionToLongColumnValue(execContext.getMyContext().getDatabase(),
                        "getLatestActivity",
                        ActivityTable.TABLE_NAME,
                        ActivityTable._ID,
                        ActivityTable.ACTOR_ID + "=" + actor.actorId
                                + " AND " + ActivityTable.ACTIVITY_TYPE + " IN("
                                + ActivityType.FOLLOW.id + ","
                                + ActivityType.CREATE.id + ","
                                + ActivityType.UPDATE.id + ","
                                + ActivityType.ANNOUNCE.id + ","
                                + ActivityType.LIKE.id + ")"
                                + " ORDER BY " + ActivityTable.UPDATED_DATE + " DESC LIMIT 1");
                if (lastActivityId == 0) {
                    MyLog.v(this, "Failed to find Actor's activity for "
                            + actor.getUniqueNameWithOrigin(), exception);
                } else {
                    long updatedDate = MyQuery.idToLongColumnValue(
                            execContext.getMyContext().getDatabase(),
                            ActivityTable.TABLE_NAME,
                            ActivityTable.UPDATED_DATE,
                            lastActivityId);
                    LatestActorActivities lum = new LatestActorActivities();
                    lum.onNewActorActivity(new ActorActivity(actor.actorId, lastActivityId, updatedDate));
                    lum.save();
                    MyLog.v(this, "Server didn't return Actor's activity for "
                                    + actor.getUniqueNameWithOrigin()
                                    + " found activity " + RelativeTime.
                                    getDifference(myContextHolder.getNow().context(), updatedDate),
                            exception);
                }
            }
            if (logSoftErrorIfStopping()) {
                return true;
            }
        }
        return false;
    }
private boolean updateNewActorsAndTheirLatestActions ( List < Actor > actorsNew ) { DataUpdater dataUpdater = new DataUpdater ( execContext ) ; long count = 0 ; for ( Actor actor : actorsNew ) { if ( actor . hasLatestNote ( ) ) continue ; count ++ ; Exception exception = null ; try { broadcastProgress ( String . valueOf ( count ) + ". " + execContext . getContext ( ) . getText ( R . string . title_command_get_status ) + ": " + actor . getUniqueNameWithOrigin ( ) , true ) ; dataUpdater . downloadOneNoteBy ( actor ) ; execContext . getResult ( ) . incrementDownloadedCount ( ) ; } catch ( Exception e ) { exception = e ; } long lastActivityId = MyQuery . actorIdToLongColumnValue ( ActorTable . ACTOR_ACTIVITY_ID , actor . actorId ) ; if ( lastActivityId == 0 ) { lastActivityId = MyQuery . conditionToLongColumnValue ( execContext . getMyContext ( ) . getDatabase ( ) , "getLatestActivity" , ActivityTable . TABLE_NAME , ActivityTable . _ID , ActivityTable . ACTOR_ID + "=" + actor . actorId + " AND " + ActivityTable . ACTIVITY_TYPE + " IN(" + ActivityType . FOLLOW . id + "," + ActivityType . CREATE . id + "," + ActivityType . UPDATE . id + "," + ActivityType . ANNOUNCE . id + "," + ActivityType . LIKE . id + ")" + " ORDER BY " + ActivityTable . UPDATED_DATE + " DESC LIMIT 1" ) ; if ( lastActivityId == 0 ) { MyLog . v ( this , "Failed to find Actor's activity for " + actor . getUniqueNameWithOrigin ( ) , exception ) ; } else { long updatedDate = MyQuery . idToLongColumnValue ( execContext . getMyContext ( ) . getDatabase ( ) , ActivityTable . TABLE_NAME , ActivityTable . UPDATED_DATE , lastActivityId ) ; LatestActorActivities lum = new LatestActorActivities ( ) ; lum . onNewActorActivity ( new ActorActivity ( actor . actorId , lastActivityId , updatedDate ) ) ; lum . save ( ) ; MyLog . v ( this , "Server didn't return Actor's activity for " + actor . getUniqueNameWithOrigin ( ) + " found activity " + RelativeTime . getDifference ( myContextHolder . getNow ( ) . context ( ) , updatedDate ) , exception ) ; } } if ( logSoftErrorIfStopping ( ) ) { return true ; } } return false ; }
@return true if we need to interrupt process
@return true if we need to interrupt process