Exemplo n.º 1
0
  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());
  }
Exemplo n.º 2
0
  @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);
  }