Esempio n. 1
0
 private String buildContent(final Extra extra, ShareBean shareBean) {
   StringBuilder sb = new StringBuilder();
   if (extra == Extra.WX_TIMELINE) {
     sb.append(shareBean.getTitle());
     sb.append(shareBean.getContentUrl());
   } else if (extra == Extra.QQ_FRIEND) {
     int urlLen = shareBean.getContentUrl().length();
     if (urlLen < 100) {
       int contentLen = 100 - urlLen;
       CharSequence content =
           (shareBean.getDesc().length() > contentLen)
               ? shareBean.getDesc().subSequence(0, contentLen)
               : shareBean.getDesc();
       sb.append(content);
       sb.append(shareBean.getContentUrl());
     } else {
       sb.append(shareBean.getDesc());
     }
   } else {
     sb.append(shareBean.getDesc());
     sb.append(shareBean.getContentUrl());
   }
   return sb.toString();
 }
Esempio n. 2
0
  public ShareEntity createEntity(Extra extra, ShareBean shareBean) {
    String title = shareBean.getTitle();
    if (extra.belong() == Platform.SINA) {
      final String content =
          StringUtil.subString(shareBean.getDesc(), shareBean.getContentUrl(), 280);

      ShareEntity entity =
          new ShareEntityBuilder()
              .builder()
              .setBitmap(((BitmapDrawable) shareBean.getDrawable()).getBitmap())
              .setTitle(title)
              .setContent(content)
              .create();
      return entity;
    }

    String content = buildContent(extra, shareBean);
    if (extra.belong() != Platform.QQ) {
      ShareEntity entity =
          new ShareEntityBuilder()
              .builder()
              .setBitmap(((BitmapDrawable) shareBean.getDrawable()).getBitmap())
              .setTitle(title)
              .setWebpageUrl(shareBean.getContentUrl())
              .setContent(content)
              .create();
      return entity;
    } else {
      ShareEntity entity =
          new ShareEntityBuilder()
              .builder()
              .setTitle(title)
              .setWebpageUrl(shareBean.getContentUrl())
              .setContent(content)
              .setNetworkImageUrl(shareBean.getImgUrl())
              .create();
      return entity;
    }
  }