/** * Default constructor. * * @param context {@link Context} * @param cursor {@link Cursor} to read the data * @param sync fetch of information */ private Conversation(final Context context, final Cursor cursor, final boolean sync) { this.threadId = cursor.getInt(INDEX_SIMPLE_ID); this.date = cursor.getLong(INDEX_SIMPLE_DATE); this.body = cursor.getString(INDEX_SIMPLE_BODY); this.read = cursor.getInt(INDEX_SIMPLE_READ); this.count = cursor.getInt(INDEX_SIMPLE_COUNT); this.contact = new Contact(cursor.getInt(INDEX_SIMPLE_NID)); AsyncHelper.fillConversation(context, this, sync); this.lastUpdate = System.currentTimeMillis(); }
/** * Update data. * * @param context {@link Context} * @param cursor {@link Cursor} to read from. * @param sync fetch of information */ private void update(final Context context, final Cursor cursor, final boolean sync) { Log.d(TAG, "update(" + this.threadId + "," + sync + ")"); long d = cursor.getLong(INDEX_SIMPLE_DATE); if (d != this.date) { this.id = cursor.getInt(INDEX_SIMPLE_ID); this.date = d; this.body = cursor.getString(INDEX_SIMPLE_BODY); } this.count = cursor.getInt(INDEX_SIMPLE_COUNT); this.read = cursor.getInt(INDEX_SIMPLE_READ); final int nid = cursor.getInt(INDEX_SIMPLE_NID); if (nid != this.contact.getRecipientId()) { this.contact = new Contact(nid); } if (this.lastUpdate < validCache) { AsyncHelper.fillConversation(context, this, sync); this.lastUpdate = System.currentTimeMillis(); } }
/** {@inheritDoc} */ @Override public void onStop() { super.onStop(); AsyncHelper.setAdapter(null); }
/** {@inheritDoc} */ @Override public void onStart() { super.onStart(); AsyncHelper.setAdapter(this.adapter); }