public void onCancel(Platform plat, int action) {
   Message msg = new Message();
   msg.arg1 = 3;
   msg.arg2 = action;
   msg.obj = plat;
   UIHandler.sendMessage(msg, this);
 }
 public void onComplete(Platform plat, int action, HashMap<String, Object> res) {
   Message msg = new Message();
   msg.arg1 = 1;
   msg.arg2 = action;
   msg.obj = plat;
   UIHandler.sendMessage(msg, this);
 }
 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);
 }
 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);
 }
    public void onError(Platform plat, int action, Throwable t) {
      t.printStackTrace();

      Message msg = new Message();
      msg.arg1 = 2;
      msg.arg2 = action;
      msg.obj = plat;
      UIHandler.sendMessage(msg, this);
    }
Example #6
0
 public void onComplete(Platform plat, int action, HashMap<String, Object> res) {
   ArrayList<Following> data = parseList(res);
   if (data != null && data.size() > 0) {
     curPage++;
     Message msg = new Message();
     msg.what = 1;
     msg.obj = data;
     UIHandler.sendMessage(msg, this);
   } else {
     UIHandler.sendEmptyMessage(FOLLOW_LIST_EMPTY, this);
   }
 }
  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);
  }
  /** 循环执行分享 */
  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 isWechat =
          "WechatMoments".equals(name) || "Wechat".equals(name) || "WechatFavorite".equals(name);
      if (isWechat && !plat.isValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(getContext(), "wechat_client_inavailable");
        msg.obj = activity.getString(resId);
        UIHandler.sendMessage(msg, this);
        continue;
      }

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

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

      if ("Instagram".equals(name)) {
        Intent test = new Intent(Intent.ACTION_SEND);
        test.setPackage("com.instagram.android");
        test.setType("image/*");
        ResolveInfo ri = activity.getPackageManager().resolveActivity(test, 0);
        if (ri == null) {
          Message msg = new Message();
          msg.what = MSG_TOAST;
          int resId = getStringRes(getContext(), "instagram_client_inavailable");
          msg.obj = activity.getString(resId);
          UIHandler.sendMessage(msg, this);
          continue;
        }
      }

      boolean isYixin = "YixinMoments".equals(name) || "Yixin".equals(name);
      if (isYixin && !plat.isValid()) {
        Message msg = new Message();
        msg.what = MSG_TOAST;
        int resId = getStringRes(getContext(), "yixin_client_inavailable");
        msg.obj = activity.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;
        }
      } else {
        Bitmap viewToShare = (Bitmap) data.get("viewToShare");
        if (viewToShare != null && !viewToShare.isRecycled()) {
          shareType = Platform.SHARE_IMAGE;
          if (data.containsKey("url")) {
            Object url = data.get("url");
            if (url != null && !TextUtils.isEmpty(url.toString())) {
              shareType = Platform.SHARE_WEBPAGE;
            }
          }
        } 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")) {
              Object url = data.get("url");
              if (url != null && !TextUtils.isEmpty(url.toString())) {
                shareType = Platform.SHARE_WEBPAGE;
              }
            }
          }
        }
      }
      data.put("shareType", shareType);

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