Ejemplo n.º 1
0
  private void drawPlaybackButton(MessageItem msgItem) {
    switch (msgItem.mAttachmentType) {
      case WorkingMessage.SLIDESHOW:
      case WorkingMessage.AUDIO:
      case WorkingMessage.VIDEO:
        // Show the 'Play' button and bind message info on it.
        mSlideShowButton.setTag(msgItem);
        // Set call-back for the 'Play' button.
        mSlideShowButton.setOnClickListener(this);
        mSlideShowButton.setVisibility(View.VISIBLE);
        setLongClickable(true);

        // When we show the mSlideShowButton, this list item's onItemClickListener doesn't
        // get called. (It gets set in ComposeMessageActivity:
        // mMsgListView.setOnItemClickListener) Here we explicitly set the item's
        // onClickListener. It allows the item to respond to embedded html links and at the
        // same time, allows the slide show play button to work.
        setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                onMessageListItemClick();
              }
            });
        break;
      default:
        mSlideShowButton.setVisibility(View.GONE);
        break;
    }
  }
Ejemplo n.º 2
0
  private void bindCommonMessage() {
    if (mDownloadButton != null) {
      mDownloadButton.setVisibility(View.GONE);
      mDownloadingLabel.setVisibility(View.GONE);
    }
    // Since the message text should be concatenated with the sender's
    // address(or name), I have to display it here instead of
    // displaying it by the Presenter.
    mBodyTextView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());

    boolean isSelf = Sms.isOutgoingFolder(mMessageItem.mBoxId);
    String addr = isSelf ? null : mMessageItem.mAddress;
    updateAvatarView(addr, isSelf);

    // Get and/or lazily set the formatted message from/on the
    // MessageItem.  Because the MessageItem instances come from a
    // cache (currently of size ~50), the hit rate on avoiding the
    // expensive formatMessage() call is very high.
    CharSequence formattedMessage = mMessageItem.getCachedFormattedMessage();
    if (formattedMessage == null) {
      formattedMessage =
          formatMessage(
              mMessageItem,
              mMessageItem.mContact,
              mMessageItem.mBody,
              mMessageItem.mSubject,
              mMessageItem.mHighlight,
              mMessageItem.mTextContentType);
      mMessageItem.setCachedFormattedMessage(formattedMessage);
    }
    mBodyTextView.setText(formattedMessage);

    // Debugging code to put the URI of the image attachment in the body of the list item.
    if (DEBUG) {
      String debugText = null;
      if (mMessageItem.mSlideshow == null) {
        debugText = "NULL slideshow";
      } else {
        SlideModel slide = ((SlideshowModel) mMessageItem.mSlideshow).get(0);
        if (slide == null) {
          debugText = "NULL first slide";
        } else if (!slide.hasImage()) {
          debugText = "Not an image";
        } else {
          debugText = slide.getImage().getUri().toString();
        }
      }
      mBodyTextView.setText(mPosition + ": " + debugText);
    }

    // If we're in the process of sending a message (i.e. pending), then we show a "SENDING..."
    // string in place of the timestamp.
    mDateView.setText(
        mMessageItem.isSending()
            ? mContext.getResources().getString(R.string.sending_message)
            : mMessageItem.mTimestamp);

    if (mMessageItem.isSms()) {
      showMmsView(false);
      mMessageItem.setOnPduLoaded(null);
    } else {
      if (DEBUG) {
        Log.v(
            TAG,
            "bindCommonMessage for item: "
                + mPosition
                + " "
                + mMessageItem.toString()
                + " mMessageItem.mAttachmentType: "
                + mMessageItem.mAttachmentType);
      }
      if (mMessageItem.mAttachmentType != WorkingMessage.TEXT) {
        setImage(null, null);
        setOnClickListener(mMessageItem);
        drawPlaybackButton(mMessageItem);
      } else {
        showMmsView(false);
      }
      if (mMessageItem.mSlideshow == null) {
        mMessageItem.setOnPduLoaded(
            new MessageItem.PduLoadedCallback() {
              public void onPduLoaded(MessageItem messageItem) {
                if (DEBUG) {
                  Log.v(
                      TAG,
                      "PduLoadedCallback in MessageListItem for item: "
                          + mPosition
                          + " "
                          + (mMessageItem == null ? "NULL" : mMessageItem.toString())
                          + " passed in item: "
                          + (messageItem == null ? "NULL" : messageItem.toString()));
                }
                if (messageItem != null
                    && mMessageItem != null
                    && messageItem.getMessageId() == mMessageItem.getMessageId()) {
                  mMessageItem.setCachedFormattedMessage(null);
                  bindCommonMessage();
                }
              }
            });
      } else {
        if (mPresenter == null) {
          mPresenter =
              PresenterFactory.getPresenter(
                  "MmsThumbnailPresenter", mContext, this, mMessageItem.mSlideshow);
        } else {
          mPresenter.setModel(mMessageItem.mSlideshow);
          mPresenter.setView(this);
        }
        if (mImageLoadedCallback == null) {
          mImageLoadedCallback = new ImageLoadedCallback(this);
        } else {
          mImageLoadedCallback.reset(this);
        }
        mPresenter.present(mImageLoadedCallback);
      }
    }
    drawRightStatusIndicator(mMessageItem);

    requestLayout();
  }