Exemplo n.º 1
0
  public void onClick(View v) {
    Platform plat = (Platform) v.getTag();
    if (plat != null) {
      if (silent) {
        HashMap<Platform, HashMap<String, Object>> shareData =
            new HashMap<Platform, HashMap<String, Object>>();
        shareData.put(plat, reqData);
        parent.share(shareData);
        return;
      }

      String name = plat.getName();
      parent.setPlatform(name);
      // EditPage不支持微信平台、Google+、QQ分享、信息和邮件,总是执行直接分享
      if ("Wechat".equals(name)
          || "WechatMoments".equals(name)
          || "ShortMessage".equals(name)
          || "Email".equals(name)
          || "GooglePlus".equals(name)
          || "QQ".equals(name)) {
        HashMap<Platform, HashMap<String, Object>> shareData =
            new HashMap<Platform, HashMap<String, Object>>();
        shareData.put(plat, reqData);
        parent.share(shareData);
        return;
      }

      // 跳转SharePage分享
      EditPage page = new EditPage();
      page.setShareData(reqData);
      page.setParent(parent);
      page.show(parent.getContext(), null);
      parent.finish();
    }
  }
  public void onCreate() {
    // 显示方式是由platform和silent两个字段控制的
    // 如果platform设置了,则无须显示九宫格,否则都会显示;
    // 如果silent为true,表示不进入编辑页面,否则会进入。
    // 本类只判断platform,因为九宫格显示以后,事件交给PlatformGridView控制
    // 当platform和silent都为true,则直接进入分享;
    // 当platform设置了,但是silent为false,则判断是否是“使用客户端分享”的平台,
    // 若为“使用客户端分享”的平台,则直接分享,否则进入编辑页面
    HashMap<String, Object> copy = new HashMap<String, Object>();
    copy.putAll(reqMap);
    if (copy.containsKey("platform")) {
      String name = String.valueOf(copy.get("platform"));
      if (silent) {
        HashMap<Platform, HashMap<String, Object>> shareData =
            new HashMap<Platform, HashMap<String, Object>>();
        shareData.put(ShareSDK.getPlatform(name), copy);
        share(shareData);
      } else if (ShareCore.isUseClientToShare(name)) {
        HashMap<Platform, HashMap<String, Object>> shareData =
            new HashMap<Platform, HashMap<String, Object>>();
        shareData.put(ShareSDK.getPlatform(name), copy);
        share(shareData);
      } else {
        Platform pp = ShareSDK.getPlatform(name);
        if (pp instanceof CustomPlatform) {
          HashMap<Platform, HashMap<String, Object>> shareData =
              new HashMap<Platform, HashMap<String, Object>>();
          shareData.put(ShareSDK.getPlatform(name), copy);
          share(shareData);
        } else {
          EditPage page = new EditPage();
          page.setBackGround(bgView);
          bgView = null;
          page.setShareData(copy);
          if (dialogMode) {
            page.setDialogMode();
          }
          page.showForResult(
              activity,
              null,
              new FakeActivity() {
                public void onResult(HashMap<String, Object> data) {
                  if (data != null && data.containsKey("editRes")) {
                    @SuppressWarnings("unchecked")
                    HashMap<Platform, HashMap<String, Object>> editRes =
                        (HashMap<Platform, HashMap<String, Object>>) data.get("editRes");
                    share(editRes);
                  }
                }
              });
        }
      }
      finish();
      return;
    }

    finishing = false;
    canceled = false;
    initPageView();
    initAnim();
    activity.setContentView(flPage);

    // 设置宫格列表数据
    grid.setData(copy, silent);
    grid.setHiddenPlatforms(hiddenPlatforms);
    grid.setCustomerLogos(customers);
    grid.setParent(this);
    btnCancel.setOnClickListener(this);

    // 显示列表
    flPage.clearAnimation();
    flPage.startAnimation(animShow);

    // 打开分享菜单的统计
    ShareSDK.logDemoEvent(1, null);
  }