示例#1
0
 public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
   Message msg = new Message();
   msg.what = MSG_ACTION_CCALLBACK;
   msg.arg1 = 1;
   msg.arg2 = action;
   msg.obj = platform;
   UIHandler.sendMessage(msg, this);
 }
示例#2
0
 public void onCancel(Platform platform, int action) {
   Message msg = new Message();
   msg.what = MSG_ACTION_CCALLBACK;
   msg.arg1 = 3;
   msg.arg2 = action;
   msg.obj = platform;
   UIHandler.sendMessage(msg, this);
 }
示例#3
0
 public void onCancel(Platform platform, int action) {
   Message msg = new Message();
   msg.what = MSG_ACTION_CCALLBACK;
   msg.arg1 = 3;
   msg.arg2 = action;
   msg.obj = platform;
   try {
     UIHandler.sendMessage(msg, this);
   } catch (NullPointerException e) {
     // TODO: handle exception
   }
 }
示例#4
0
 public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
   Message msg = new Message();
   msg.what = MSG_ACTION_CCALLBACK;
   msg.arg1 = 1;
   msg.arg2 = action;
   msg.obj = platform;
   try {
     UIHandler.sendMessage(msg, this);
   } catch (NullPointerException e) {
     // TODO: handle exception
   }
 }
示例#5
0
  public void onError(Platform platform, int action, Throwable t) {
    t.printStackTrace();

    Message msg = new Message();
    msg.what = MSG_ACTION_CCALLBACK;
    msg.arg1 = 2;
    msg.arg2 = action;
    msg.obj = t;
    UIHandler.sendMessage(msg, this);

    // 分享失败的统计
    ShareSDK.logDemoEvent(4, platform);
  }
示例#6
0
  public void onError(Platform platform, int action, Throwable t) {
    t.printStackTrace();

    Message msg = new Message();
    msg.what = MSG_ACTION_CCALLBACK;
    msg.arg1 = 2;
    msg.arg2 = action;
    msg.obj = t;
    try {
      UIHandler.sendMessage(msg, this);
    } catch (NullPointerException e) {
      // TODO: handle exception
    }

    // 分享失败的统计
    ShareSDK.logDemoEvent(4, platform);
  }
示例#7
0
  /** 循环执行分享 */
  public void share(HashMap<Platform, HashMap<String, Object>> shareData) {
    boolean started = false;
    for (Entry<Platform, HashMap<String, Object>> ent : shareData.entrySet()) {
      Platform plat = ent.getKey();
      plat.SSOSetting(disableSSO);
      String name = plat.getName();

      //			boolean isGooglePlus = "GooglePlus".equals(name);
      //			if (isGooglePlus && !plat.isValid()) {
      //				Message msg = new Message();
      //				msg.what = MSG_TOAST;
      //				int resId = getStringRes(context, "google_plus_client_inavailable");
      //				msg.obj = context.getString(resId);
      //				UIHandler.sendMessage(msg, this);
      //				continue;
      //			}

      boolean isKakaoTalk = "KakaoTalk".equals(name);
      if (isKakaoTalk && !plat.isClientValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(context, "kakaotalk_client_inavailable");
        msg.obj = context.getString(resId);
        UIHandler.sendMessage(msg, this);
        continue;
      }

      boolean isKakaoStory = "KakaoStory".equals(name);
      if (isKakaoStory && !plat.isClientValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(context, "kakaostory_client_inavailable");
        msg.obj = context.getString(resId);
        UIHandler.sendMessage(msg, this);
        continue;
      }

      boolean isLine = "Line".equals(name);
      if (isLine && !plat.isClientValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(context, "line_client_inavailable");
        msg.obj = context.getString(resId);
        UIHandler.sendMessage(msg, this);
        continue;
      }

      boolean isWhatsApp = "WhatsApp".equals(name);
      if (isWhatsApp && !plat.isClientValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(context, "whatsapp_client_inavailable");
        msg.obj = context.getString(resId);
        UIHandler.sendMessage(msg, this);
        continue;
      }

      boolean isPinterest = "Pinterest".equals(name);
      if (isPinterest && !plat.isClientValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(context, "pinterest_client_inavailable");
        msg.obj = context.getString(resId);
        UIHandler.sendMessage(msg, this);
        continue;
      }

      if ("Instagram".equals(name) && !plat.isClientValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(context, "instagram_client_inavailable");
        msg.obj = context.getString(resId);
        UIHandler.sendMessage(msg, this);
        continue;
      }

      boolean isLaiwang = "Laiwang".equals(name);
      boolean isLaiwangMoments = "LaiwangMoments".equals(name);
      if (isLaiwang || isLaiwangMoments) {
        if (!plat.isClientValid()) {
          Message msg = new Message();
          msg.what = MSG_TOAST;
          int resId = getStringRes(context, "laiwang_client_inavailable");
          msg.obj = context.getString(resId);
          UIHandler.sendMessage(msg, this);
          continue;
        }
      }

      boolean isYixin = "YixinMoments".equals(name) || "Yixin".equals(name);
      if (isYixin && !plat.isClientValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(context, "yixin_client_inavailable");
        msg.obj = context.getString(resId);
        UIHandler.sendMessage(msg, this);
        continue;
      }

      HashMap<String, Object> data = ent.getValue();
      int shareType = Platform.SHARE_TEXT;
      String imagePath = String.valueOf(data.get("imagePath"));
      if (imagePath != null && (new File(imagePath)).exists()) {
        shareType = Platform.SHARE_IMAGE;
        if (imagePath.endsWith(".gif")) {
          shareType = Platform.SHARE_EMOJI;
        } else if (data.containsKey("url") && !TextUtils.isEmpty(data.get("url").toString())) {
          shareType = Platform.SHARE_WEBPAGE;
          if (data.containsKey("musicUrl") && !TextUtils.isEmpty(data.get("musicUrl").toString())) {
            shareType = Platform.SHARE_MUSIC;
          }
        }
      } else {
        Bitmap viewToShare = (Bitmap) data.get("viewToShare");
        if (viewToShare != null && !viewToShare.isRecycled()) {
          shareType = Platform.SHARE_IMAGE;
          if (data.containsKey("url") && !TextUtils.isEmpty(data.get("url").toString())) {
            shareType = Platform.SHARE_WEBPAGE;
            if (data.containsKey("musicUrl")
                && !TextUtils.isEmpty(data.get("musicUrl").toString())) {
              shareType = Platform.SHARE_MUSIC;
            }
          }
        } else {
          Object imageUrl = data.get("imageUrl");
          if (imageUrl != null && !TextUtils.isEmpty(String.valueOf(imageUrl))) {
            shareType = Platform.SHARE_IMAGE;
            if (String.valueOf(imageUrl).endsWith(".gif")) {
              shareType = Platform.SHARE_EMOJI;
            } else if (data.containsKey("url") && !TextUtils.isEmpty(data.get("url").toString())) {
              shareType = Platform.SHARE_WEBPAGE;
              if (data.containsKey("musicUrl")
                  && !TextUtils.isEmpty(data.get("musicUrl").toString())) {
                shareType = Platform.SHARE_MUSIC;
              }
            }
          }
        }
      }
      data.put("shareType", shareType);

      if (!started) {
        started = true;
        if (this == callback) {
          int resId = getStringRes(context, "sharing");
          if (resId > 0) {
            showNotification(context.getString(resId));
          }
        }
      }
      plat.setPlatformActionListener(callback);
      ShareCore shareCore = new ShareCore();
      shareCore.setShareContentCustomizeCallback(customizeCallback);
      shareCore.share(plat, data);
    }
  }