zoukankan      html  css  js  c++  java
  • 团队冲刺第二阶段10

    今天做了最后分享的功能,组员之间整合了代码,测试各部分的功能实现。

      public void shareNote (Note note) {
    
        String titleText = note.getTitle();
    
        String contentText = titleText
            + System.getProperty("line.separator")
            + note.getContent();
    
        Intent shareIntent = new Intent();
        // Prepare sharing intent with only text
        if (note.getAttachmentsList().isEmpty()) {
          shareIntent.setAction(Intent.ACTION_SEND);
          shareIntent.setType("text/plain");
    
          // Intent with single image attachment
        } else if (note.getAttachmentsList().size() == 1) {
          shareIntent.setAction(Intent.ACTION_SEND);
          Attachment attachment = note.getAttachmentsList().get(0);
          shareIntent.setType(attachment.getMime_type());
          shareIntent.putExtra(Intent.EXTRA_STREAM, FileProviderHelper.getShareableUri(attachment));
    
          // Intent with multiple images
        } else if (note.getAttachmentsList().size() > 1) {
          shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
          ArrayList<Uri> uris = new ArrayList<>();
          // A check to decide the mime type of attachments to share is done here
          HashMap<String, Boolean> mimeTypes = new HashMap<>();
          for (Attachment attachment : note.getAttachmentsList()) {
            uris.add(FileProviderHelper.getShareableUri(attachment));
            mimeTypes.put(attachment.getMime_type(), true);
          }
          // If many mime types are present a general type is assigned to intent
          if (mimeTypes.size() > 1) {
            shareIntent.setType("*/*");
          } else {
            shareIntent.setType((String) mimeTypes.keySet().toArray()[0]);
          }
    
          shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        }
        shareIntent.putExtra(Intent.EXTRA_SUBJECT, titleText);
        shareIntent.putExtra(Intent.EXTRA_TEXT, contentText);
    
        startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.share_message_chooser)));
      }

  • 相关阅读:
    使用密码记录工具keepass来保存密码
    ADO.NET Entity Framework CodeFirst 如何输出日志(EF 5.0)
    Mono 3.2 测试NPinyin 中文转换拼音代码
    Reactive Extensions(Rx) 学习
    Reactive Extensions介绍
    Mono 3.2 上跑NUnit测试
    RazorEngine 3.3 在Mono 3.2上正常运行
    标准数据源访问库
    .Net 跨平台可移植类库正在进行
    Windows安装和使用zookeeper
  • 原文地址:https://www.cnblogs.com/xjmm/p/13085539.html
Copyright © 2011-2022 走看看