/**
   * Default Constructor.
   *
   * @param c {@link ConversationListActivity}
   */
  public ConversationAdapter(final Activity c) {
    super(c, R.layout.conversationlist_item, null, true);
    activity = c;

    SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(activity);
    useGridLayout = PreferencesActivity.getGridlayoutEnabled(activity);
    if (useGridLayout) {
      super.setViewResource(R.layout.conversation_square);
    }
    final ContentResolver cr = c.getContentResolver();
    queryHandler = new BackgroundQueryHandler(cr);
    SpamDB spam = new SpamDB(c);
    spam.open();
    blacklist = spam.getAllEntries();
    spam.close();

    defaultContactAvatar = c.getResources().getDrawable(R.drawable.ic_contact_picture);

    convertNCR = PreferencesActivity.decodeDecimalNCR(c);
    showEmoticons = PreferencesActivity.showEmoticons(c);
    textSize = PreferencesActivity.getTextsize(c);
    textColor = PreferencesActivity.getTextcolor(c);

    Cursor cursor = null;
    try {
      cursor = cr.query(Conversation.URI_SIMPLE, Conversation.PROJECTION_SIMPLE, null, null, null);
    } catch (SQLiteException e) {
      Log.e(TAG, "error getting conversations", e);
    }
    /* {@link Cursor} to the original Content to listen for changes. */
    Cursor origCursor = cursor;

    if (origCursor != null) {
      origCursor.registerContentObserver(
          new ContentObserver(new Handler()) {
            @Override
            public void onChange(final boolean selfChange) {
              super.onChange(selfChange);
              if (!selfChange) {
                Log.d(TAG, "call startMsgListQuery();");
                ConversationAdapter.this.startMsgListQuery();
                Log.d(TAG, "invalidate cache");
                Conversation.invalidate();
              }
            }
          });
    }
    // startMsgListQuery();
  }
  @Override
  protected void onResume() {
    super.onResume();
    LogHelper.info("BookView", "onResume");
    // this allows references to bookQuery on a resume to remain valid.
    // would have thought a managed query would do this automatically
    book.refresh(getContentResolver());

    // update the disk usage, which may have changed...
    if (sectionsCursor != null) {
      // trigger the "current playing" to be updated...
      sectionsAdapter.notifyDataSetChanged();

      calculateAndDisplayBookDurationAndSize();
    }
    if (mBoundService != null) {
      setProgressUpdater();
    }
    updatePlayButtonLabel();
    updateDeleteButton((Button) findViewById(R.id.delete));
    updateDownloadButton((Button) findViewById(R.id.download));
    updateAddToLibraryButtonText((Button) findViewById(R.id.addToLibrary));
  }
 @Override
 public void notifyDataSetChanged() {
   reinit(null);
   super.notifyDataSetChanged();
 }
 @Override
 public void notifyDataSetInvalidated() {
   reinit(null);
   super.notifyDataSetInvalidated();
 }
 @Override
 public void changeCursor(Cursor cursor) {
   reinit(cursor);
   super.changeCursor(cursor);
 }