@SuppressLint("NewApi") private void rebuildCache(){
  if (Log.isLoggable(LogTag.APP,Log.DEBUG)) {
    log("rebuildCache");
  }
  HashSet<Long> newDraftSet=new HashSet<>();
  Cursor cursor=SqliteWrapper.query(mContext,mContext.getContentResolver(),MmsSms.CONTENT_DRAFT_URI,DRAFT_PROJECTION,null,null,null);
  if (cursor != null) {
    try {
      if (cursor.moveToFirst()) {
        for (; !cursor.isAfterLast(); cursor.moveToNext()) {
          long threadId=cursor.getLong(COLUMN_DRAFT_THREAD_ID);
          newDraftSet.add(threadId);
          if (Log.isLoggable(LogTag.APP,Log.DEBUG)) {
            log("rebuildCache: add tid=" + threadId);
          }
        }
      }
    }
  finally {
      cursor.close();
    }
  }
  Set<Long> added;
  Set<Long> removed;
synchronized (mDraftSetLock) {
    HashSet<Long> oldDraftSet=mDraftSet;
    mDraftSet=newDraftSet;
    if (Log.isLoggable(LogTag.APP,Log.VERBOSE)) {
      dump();
    }
synchronized (mChangeListenersLock) {
      if (mChangeListeners.isEmpty()) {
        return;
      }
    }
    added=new HashSet<Long>(newDraftSet);
    added.removeAll(oldDraftSet);
    removed=new HashSet<Long>(oldDraftSet);
    removed.removeAll(newDraftSet);
  }
synchronized (mChangeListenersLock) {
    for (    OnDraftChangedListener l : mChangeListeners) {
      for (      long threadId : added) {
        l.onDraftChanged(threadId,true);
      }
      for (      long threadId : removed) {
        l.onDraftChanged(threadId,false);
      }
    }
  }
}

@ SuppressLint ( "NewApi" ) private void rebuildCache ( ) { if ( Log . isLoggable ( LogTag . APP , Log . DEBUG ) ) { log ( "rebuildCache" ) ; } HashSet < Long > newDraftSet = new HashSet < > ( ) ; Cursor cursor = SqliteWrapper . query ( mContext , mContext . getContentResolver ( ) , MmsSms . CONTENT_DRAFT_URI , DRAFT_PROJECTION , null , null , null ) ; if ( cursor != null ) { try { if ( cursor . moveToFirst ( ) ) { for ( ; ! cursor . isAfterLast ( ) ; cursor . moveToNext ( ) ) { long threadId = cursor . getLong ( COLUMN_DRAFT_THREAD_ID ) ; newDraftSet . add ( threadId ) ; if ( Log . isLoggable ( LogTag . APP , Log . DEBUG ) ) { log ( "rebuildCache: add tid=" + threadId ) ; } } } } finally { cursor . close ( ) ; } } Set < Long > added ; Set < Long > removed ; synchronized ( mDraftSetLock ) { HashSet < Long > oldDraftSet = mDraftSet ; mDraftSet = newDraftSet ; if ( Log . isLoggable ( LogTag . APP , Log . VERBOSE ) ) { dump ( ) ; } synchronized ( mChangeListenersLock ) { if ( mChangeListeners . isEmpty ( ) ) { return ; } } added = new HashSet < Long > ( newDraftSet ) ; added . removeAll ( oldDraftSet ) ; removed = new HashSet < Long > ( oldDraftSet ) ; removed . removeAll ( newDraftSet ) ; } synchronized ( mChangeListenersLock ) { for ( OnDraftChangedListener l : mChangeListeners ) { for ( long threadId : added ) { l . onDraftChanged ( threadId , true ) ; } for ( long threadId : removed ) { l . onDraftChanged ( threadId , false ) ; } } } }
does the actual work of rebuilding the draft cache .
