/** * 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(); }