protected void showInReplyToTweetDetails() { Tweet tweet = null; if (this.inReplyToSid != null && this.inReplyToUid > 0L) { final View view = findViewById(R.id.tweetReplyToDetails); view.setVisibility(View.VISIBLE); tweet = getDb().getTweetDetails(this.inReplyToUid); if (tweet != null) { LOG.i("inReplyTo:%s", tweet.toFullString()); if (!this.enabledPostToAccounts.isServicesPreSpecified()) { final Meta serviceMeta = tweet.getFirstMetaOfType(MetaType.SERVICE); if (serviceMeta != null) setPostToAccountExclusive(ServiceRef.parseServiceMeta(serviceMeta)); } ((TextView) view.findViewById(R.id.tweetDetailBody)).setText(tweet.getBody()); if (tweet.getAvatarUrl() != null) loadImage( new ImageLoadRequest( tweet.getAvatarUrl(), (ImageView) view.findViewById(R.id.tweetDetailAvatar))); ((TextView) view.findViewById(R.id.tweetDetailName)).setText(tweet.getFullname()); ((TextView) view.findViewById(R.id.tweetDetailDate)) .setText( DateFormat.getDateTimeInstance() .format(new Date(TimeUnit.SECONDS.toMillis(tweet.getTime())))); } } initBody(tweet); this.txtBody.setSelection(this.txtBody.getText().length()); }
@Override public void deleteTweet(final Column column, final Tweet tweet) { this.mDb.beginTransaction(); try { this.mDb.delete( TBL_TW, TBL_TW_COLID + "=? AND " + TBL_TW_SID + "=?", new String[] {String.valueOf(column.getId()), String.valueOf(tweet.getSid())}); this.log.d("Deleted tweet %s from %s column %d.", tweet.getSid(), TBL_TW, column.getId()); this.mDb.setTransactionSuccessful(); } finally { this.mDb.endTransaction(); } notifyTwListenersColumnChanged(column.getId()); }
private void initBody(final Tweet tweet) { final String intialBody = this.intentExtras.getString(ARG_BODY); if (intialBody != null) { this.txtBody.setText(intialBody); } else { StringBuilder s = new StringBuilder(); if (tweet != null && tweet.getUsername() != null) s.append("@").append(tweet.getUsername()); if (this.alsoMentions != null) { for (String mention : this.alsoMentions) { s.append(" @").append(mention); } } if (s.length() > 0) { s.append(" "); this.txtBody.setText(s.toString()); } } }
@Override public Tweet getTweetDetails(final int columnId, final Tweet tweet) { return getTweetDetails(columnId, tweet.getSid()); }
@Override public void storeTweets(final int columnId, final List<Tweet> tweets) { // Clear old data. this.mDb.beginTransaction(); try { final int n = this.mDb.delete( TBL_TW, TBL_TW_COLID + "=? AND " + TBL_TW_ID + " NOT IN (SELECT " + TBL_TW_ID + " FROM " + TBL_TW + " WHERE " + TBL_TW_COLID + "=?" + " ORDER BY " + TBL_TW_TIME + " DESC LIMIT " + C.DATA_TW_MAX_COL_ENTRIES + ")", new String[] {String.valueOf(columnId), String.valueOf(columnId)}); this.log.d("Deleted %d rows from %s column %d.", n, TBL_TW, columnId); this.mDb.setTransactionSuccessful(); } finally { this.mDb.endTransaction(); } this.mDb.beginTransaction(); try { final ContentValues values = new ContentValues(); for (final Tweet tweet : tweets) { values.clear(); values.put(TBL_TW_COLID, columnId); values.put(TBL_TW_SID, tweet.getSid()); values.put(TBL_TW_TIME, tweet.getTime()); values.put(TBL_TW_USERNAME, tweet.getUsername()); values.put(TBL_TW_FULLNAME, tweet.getFullname()); values.put(TBL_TW_BODY, tweet.getBody()); values.put(TBL_TW_AVATAR, tweet.getAvatarUrl()); final long uid = this.mDb.insertWithOnConflict(TBL_TW, null, values, SQLiteDatabase.CONFLICT_REPLACE); final List<Meta> metas = tweet.getMetas(); if (metas != null) { for (final Meta meta : metas) { values.clear(); values.put(TBL_TM_TWID, uid); values.put(TBL_TM_TYPE, meta.getType().getId()); values.put(TBL_TM_DATA, meta.getData()); if (meta.getTitle() != null) values.put(TBL_TM_TITLE, meta.getTitle()); this.mDb.insertWithOnConflict(TBL_TM, null, values, SQLiteDatabase.CONFLICT_REPLACE); } } } this.mDb.setTransactionSuccessful(); } finally { this.mDb.endTransaction(); } notifyTwListenersColumnChanged(columnId); }