예제 #1
0
  protected void setResultAndFinish() {
    ArrayList<String> imageArray = new ArrayList<String>();
    if (shareImageList != null) {
      for (ImageInfo imageInfo : shareImageList) {
        if ("imagePath".equals(imageInfo.paramName) || "imageUrl".equals(imageInfo.paramName)) {
          shareParamMap.put(imageInfo.paramName, imageInfo.srcValue);
        } else if ("viewToShare".equals(imageInfo.paramName)) {
          shareParamMap.put(imageInfo.paramName, imageInfo.bitmap);
        } else if ("imageArray".equals(imageInfo.paramName)) {
          imageArray.add(imageInfo.srcValue);
        }
      }
      shareImageList.clear();
      if (imageArray.size() == 0) {
        shareParamMap.put("imageArray", null);
      } else {
        shareParamMap.put("imageArray", imageArray.toArray(new String[imageArray.size()]));
      }
    }

    HashMap<Platform, HashMap<String, Object>> editRes =
        new HashMap<Platform, HashMap<String, Object>>();

    for (Platform platform : platforms) {

      if ("FacebookMessenger".equals(platform.getName())) {
        HashMap<String, Object> param = new HashMap<String, Object>(shareParamMap);
        if (toFriendList != null && toFriendList.size() > 0) {
          param.put("address", toFriendList.get(toFriendList.size() - 1));
        }
        if (param.get("address") == null) {
          int resId = getStringRes(activity, "select_a_friend");
          if (resId > 0) {
            Toast.makeText(
                    getContext(),
                    activity.getString(resId) + " - " + platform.getName(),
                    Toast.LENGTH_SHORT)
                .show();
          }
          return;
        }
        editRes.put(platform, param);
        continue;
      }
      editRes.put(platform, shareParamMap);
    }

    HashMap<String, Object> res = new HashMap<String, Object>();
    res.put("editRes", editRes);
    setResult(res);
    finish();
  }
예제 #2
0
    private String getName(Platform plat) {
      if (plat == null) {
        return "";
      }

      String name = plat.getName();
      if (name == null) {
        return "";
      }

      int resId = cn.sharesdk.framework.utils.R.getStringRes(getContext(), plat.getName());
      return getContext().getString(resId);
    }
예제 #3
0
    private Bitmap getIcon(Platform plat) {
      if (plat == null) {
        return null;
      }

      String name = plat.getName();
      if (name == null) {
        return null;
      }

      String resName = "logo_" + plat.getName();
      int resId = cn.sharesdk.framework.utils.R.getResId(R.drawable.class, resName);
      return BitmapFactory.decodeResource(getResources(), resId);
    }
예제 #4
0
    private Bitmap getIcon(Platform plat) {
      if (plat == null) {
        return null;
      }

      String name = plat.getName();
      if (name == null) {
        return null;
      }

      String resName = "logo_" + plat.getName();
      int resId = getBitmapRes(getContext(), resName.toLowerCase());
      return BitmapFactory.decodeResource(getResources(), resId);
    }
    public boolean handleMessage(Message msg) {
      LoginActivity activity;
      Platform plat = (Platform) msg.obj;
      String text = null;
      switch (msg.arg1) {
        case 1:
          {
            // 成功
            text = plat.getName() + " 授权成功 ";
            if (plat.getName().equals("SinaWeibo")) sinax = true;
            if (plat.getName().equals("TecentWeibo")) tecentx = true;
            if (plat.getName().equals("Renren")) renrenx = true;
            if (plat.getName().equals("Douban")) doubanx = true;
            Toast.makeText(SubmitActivity.this, text, Toast.LENGTH_SHORT).show();
          }
          break;
        case 2:
          {
            // 失败

            text = plat.getName() + " 授权失败 ";
            Toast.makeText(SubmitActivity.this, text, Toast.LENGTH_SHORT).show();
            return false;
          }
        case 3:
          {
            // 取消
            text = plat.getName() + " 授权取消 ";

            if (plat.getName().equals("SinaWeibo")) {
              sinax = false;
              sinaweiboTextView.setTextColor(getResources().getColor(R.color.unchoose_color));
            }
            if (plat.getName().equals("TecentWeibo")) {
              tecentx = false;
              tencentweiboTextView.setTextColor(getResources().getColor(R.color.unchoose_color));
            }
            if (plat.getName().equals("Renren")) {
              renrenx = false;
              renrenTextView.setTextColor(getResources().getColor(R.color.unchoose_color));
            }
            if (plat.getName().equals("Douban")) {
              doubanx = false;
              doubanTextView.setTextColor(getResources().getColor(R.color.unchoose_color));
            }

            Toast.makeText(SubmitActivity.this, text, Toast.LENGTH_SHORT).show();
            return false;
          }
      }

      return false;
    }
예제 #6
0
    private String getName(Platform plat) {
      if (plat == null) {
        return "";
      }

      String name = plat.getName();
      if (name == null) {
        return "";
      }

      int resId = com.mob.tools.utils.R.getStringRes(getContext(), plat.getName().toLowerCase());
      if (resId > 0) {
        return getContext().getString(resId);
      }
      return null;
    }
예제 #7
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();
    }
  }
  private void initAtUserView() {
    LinearLayout atLayout = (LinearLayout) findViewByResName("atLayout");
    for (Platform platform : platforms) {
      String platformName = platform.getName();
      if (isShowAtUserLayout(platformName)) {
        View view =
            LayoutInflater.from(activity)
                .inflate(getLayoutRes(activity, "skyblue_editpage_at_layout"), null);
        TextView atDescTextView =
            (TextView) view.findViewById(getIdRes(activity, "atDescTextView"));
        TextView atTextView = (TextView) view.findViewById(getIdRes(activity, "atTextView"));

        OnClickListener atBtnClickListener =
            new OnClickListener() {
              public void onClick(View v) {
                FollowListPage subPage = new FollowListPage();
                subPage.setPlatform((Platform) v.getTag());
                subPage.showForResult(activity, null, EditPage.this);
              }
            };
        atTextView.setTag(platform);
        atTextView.setOnClickListener(atBtnClickListener);
        atDescTextView.setTag(platform);
        atDescTextView.setOnClickListener(atBtnClickListener);

        atTextView.setText(getAtUserButtonText(platformName));
        atDescTextView.setText(
            getContext()
                .getString(getStringRes(activity, "list_friends"), getLogoName(platformName)));

        atLayout.addView(view);
      }
    }
  }
예제 #9
0
  private Bitmap getPlatLogo(Platform plat) {
    if (plat == null) {
      return null;
    }

    String name = plat.getName();
    if (name == null) {
      return null;
    }

    String resName = "logo_" + plat.getName();
    int resId = getBitmapRes(activity, resName);
    if (resId > 0) {
      return BitmapFactory.decodeResource(activity.getResources(), resId);
    }
    return null;
  }
예제 #10
0
  public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
    dismissDialog();
    if (action == Platform.ACTION_USER_INFOR) {
      this.res = res;
      Message msg = new Message();
      msg.what = MSG_AUTH_COMPLETE;
      if (platform.getName().equals("QZone")) usericon = res.get("figureurl_qq_2").toString();
      else {
        usericon = platform.getDb().getUserIcon();
        //                usericon=res.get("profile_image_url").toString();//头像链接
      }
      msg.obj = new Object[] {platform.getName(), res};
      String s = platform.getDb().getToken().toString();
      String ss = platform.getDb().getTokenSecret().toString();

      handler.sendMessage(msg);
    }
  }
예제 #11
0
  /** display platform list */
  @SuppressLint("NewApi")
  public void afterPlatformListGot() {
    int size = platformList == null ? 0 : platformList.length;
    views = new View[size];

    final int dp_24 = dipToPx(getContext(), 24);
    LayoutParams lpItem = new LayoutParams(dp_24, dp_24);
    final int dp_9 = dipToPx(getContext(), 9);
    lpItem.setMargins(0, 0, dp_9, 0);
    FrameLayout.LayoutParams lpMask =
        new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    lpMask.gravity = Gravity.LEFT | Gravity.TOP;
    int selection = 0;
    for (int i = 0; i < size; i++) {
      FrameLayout fl = new FrameLayout(getContext());
      fl.setLayoutParams(lpItem);
      if (i >= size - 1) {
        fl.setLayoutParams(new LayoutParams(dp_24, dp_24));
      }
      llPlat.addView(fl);
      fl.setOnClickListener(this);

      ImageView iv = new ImageView(getContext());
      iv.setScaleType(ScaleType.CENTER_INSIDE);
      iv.setImageBitmap(getPlatLogo(platformList[i]));
      iv.setLayoutParams(
          new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
      fl.addView(iv);

      views[i] = new View(getContext());
      views[i].setBackgroundColor(0xcfffffff);
      views[i].setOnClickListener(this);
      String platformName = platformList[i].getName();
      for (Platform plat : platforms) {
        if (platformName.equals(plat.getName())) {
          views[i].setVisibility(View.INVISIBLE);
          selection = i;
        }
      }
      views[i].setLayoutParams(lpMask);
      fl.addView(views[i]);
    }

    final int postSel = selection;
    UIHandler.sendEmptyMessageDelayed(
        0,
        333,
        new Callback() {
          @SuppressLint("NewApi")
          public boolean handleMessage(Message msg) {
            HorizontalScrollView hsv = (HorizontalScrollView) llPlat.getParent();
            hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
            return false;
          }
        });
  }
 public void onCancel(Platform platform, int action) {
   if (ShareSDKUtils.DEBUG) {
     System.out.println("onCancel");
   }
   HashMap<String, Object> map = new HashMap<String, Object>();
   map.put("platform", ShareSDK.platformNameToId(platform.getName()));
   map.put("action", action);
   map.put("status", 3); // Success = 1, Fail = 2, Cancel = 3
   map.put("reqID", reqID);
   Message msg = new Message();
   msg.obj = new Hashon().fromHashMap(map);
   UIHandler.sendMessage(msg, c2dCallback);
 }
예제 #13
0
파일: FollowList.java 프로젝트: cg8530/LDXY
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   String name = platform.getName();
   if ("FacebookMessenger".equals(name)) {
     if (lastPosition >= 0) {
       Following lastFollwing = adapter.getItem(lastPosition);
       lastFollwing.checked = false;
     }
     lastPosition = position;
   }
   Following following = adapter.getItem(position);
   following.checked = !following.checked;
   adapter.notifyDataSetChanged();
 }
 public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
   if (ShareSDKUtils.DEBUG) {
     System.out.println("onComplete");
     System.out.println(res == null ? "" : res.toString());
   }
   HashMap<String, Object> map = new HashMap<String, Object>();
   map.put("platform", ShareSDK.platformNameToId(platform.getName()));
   map.put("action", action);
   map.put("status", 1); // Success = 1, Fail = 2, Cancel = 3
   if (action == 8 || action == 2) {
     // action = 2, 8, 获取用户列表与用户信息才放入
     map.put("res", res);
   }
   map.put("reqID", reqID);
   Message msg = new Message();
   msg.obj = new Hashon().fromHashMap(map);
   UIHandler.sendMessage(msg, c2dCallback);
 }
예제 #15
0
파일: FollowList.java 프로젝트: cg8530/LDXY
  public void onClick(View v) {
    String name = platform.getName();
    if (v.equals(llTitle.getBtnRight())) {
      ArrayList<String> selected = new ArrayList<String>();
      if ("SinaWeibo".equals(name)) {
        for (int i = 0, size = adapter.getCount(); i < size; i++) {
          if (adapter.getItem(i).checked) {
            selected.add(adapter.getItem(i).screeName);
          }
        }
      } else if ("TencentWeibo".equals(name)) {
        for (int i = 0, size = adapter.getCount(); i < size; i++) {
          if (adapter.getItem(i).checked) {
            selected.add(adapter.getItem(i).uid);
          }
        }
      } else if ("Facebook".equals(name)) {
        for (int i = 0, size = adapter.getCount(); i < size; i++) {
          if (adapter.getItem(i).checked) {
            selected.add("[" + adapter.getItem(i).uid + "]");
          }
        }
      } else if ("Twitter".equals(name)) {
        for (int i = 0, size = adapter.getCount(); i < size; i++) {
          if (adapter.getItem(i).checked) {
            selected.add(adapter.getItem(i).uid);
          }
        }
      } else if ("FacebookMessenger".equals(name)) {
        for (int i = 0, size = adapter.getCount(); i < size; i++) {
          if (adapter.getItem(i).checked) {
            selected.add(adapter.getItem(i).uid);
          }
        }
      }

      HashMap<String, Object> res = new HashMap<String, Object>();
      res.put("selected", selected);
      setResult(res);
    }

    finish();
  }
예제 #16
0
    public PlatformAdapter(PlatformGridView platformGridView) {
      this.platformGridView = platformGridView;
      logos = new ArrayList<Object>();
      Platform[] platforms = platformGridView.platformList;
      HashMap<String, String> hiddenPlatforms = platformGridView.hiddenPlatforms;
      if (platforms != null) {
        if (hiddenPlatforms != null && hiddenPlatforms.size() > 0) {
          ArrayList<Platform> ps = new ArrayList<Platform>();
          for (Platform p : platforms) {
            if (hiddenPlatforms.containsKey(p.getName())) {
              continue;
            }
            ps.add(p);
          }

          platforms = new Platform[ps.size()];
          for (int i = 0; i < platforms.length; i++) {
            platforms[i] = ps.get(i);
          }
        }

        logos.addAll(Arrays.asList(platforms));
      }
      ArrayList<CustomerLogo> customers = platformGridView.customers;
      if (customers != null) {
        logos.addAll(customers);
      }
      this.callback = platformGridView;
      girds = null;

      if (logos != null) {
        int size = logos.size();
        int PAGE_SIZE = platformGridView.PAGE_SIZE;
        int pageCount = size / PAGE_SIZE;
        if (size % PAGE_SIZE > 0) {
          pageCount++;
        }
        girds = new GridView[pageCount];
      }
    }
예제 #17
0
 /** 判断是否直接分享 */
 public static boolean isDirectShare(Platform platform) {
   return platform instanceof CustomPlatform || isUseClientToShare(platform.getName());
 }
예제 #18
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);
    }
  }
예제 #19
0
파일: FollowList.java 프로젝트: cg8530/LDXY
    public View getView(int position, View convertView, ViewGroup parent) {
      FollowListItem item = null;
      boolean simpleMode = "FacebookMessenger".equals(platform.getName());
      if (convertView == null) {
        LinearLayout llItem = new LinearLayout(parent.getContext());
        item = new FollowListItem();
        llItem.setTag(item);
        convertView = llItem;

        int dp_52 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 52);
        int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 10);
        int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 5);

        if (!simpleMode) {
          item.aivIcon = new AsyncImageView(getContext());
          LinearLayout.LayoutParams lpIcon = new LinearLayout.LayoutParams(dp_52, dp_52);
          lpIcon.gravity = Gravity.CENTER_VERTICAL;
          lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
          item.aivIcon.setLayoutParams(lpIcon);
          llItem.addView(item.aivIcon);
        }

        LinearLayout llText = new LinearLayout(parent.getContext());
        llText.setPadding(0, dp_10, dp_10, dp_10);
        llText.setOrientation(LinearLayout.VERTICAL);
        LinearLayout.LayoutParams lpText =
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lpText.gravity = Gravity.CENTER_VERTICAL;
        lpText.weight = 1;
        llText.setLayoutParams(lpText);
        llItem.addView(llText);

        item.tvName = new TextView(parent.getContext());
        item.tvName.setTextColor(0xff000000);
        item.tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        item.tvName.setSingleLine();
        if (simpleMode) {
          item.tvName.setPadding(dp_10, 0, 0, 0);
        }
        llText.addView(item.tvName);

        if (!simpleMode) {
          item.tvSign = new TextView(parent.getContext());
          item.tvSign.setTextColor(0x7f000000);
          item.tvSign.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
          item.tvSign.setSingleLine();
          llText.addView(item.tvSign);
        }

        item.ivCheck = new ImageView(parent.getContext());
        item.ivCheck.setPadding(0, 0, dp_10, 0);
        LinearLayout.LayoutParams lpCheck =
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lpCheck.gravity = Gravity.CENTER_VERTICAL;
        item.ivCheck.setLayoutParams(lpCheck);
        llItem.addView(item.ivCheck);
      } else {
        item = (FollowListItem) convertView.getTag();
      }

      Following following = getItem(position);
      item.tvName.setText(following.screeName);
      if (!simpleMode) {
        item.tvSign.setText(following.description);
      }
      item.ivCheck.setImageBitmap(following.checked ? bmChd : bmUnch);
      if (!simpleMode) {
        if (isFling()) {
          Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
          if (bm != null && !bm.isRecycled()) {
            item.aivIcon.setImageBitmap(bm);
          } else {
            item.aivIcon.execute(null, AsyncImageView.DEFAULT_TRANSPARENT);
          }
        } else {
          item.aivIcon.execute(following.icon);
        }
      }

      if (position == getCount() - 1) {
        next();
      }
      return convertView;
    }
예제 #20
0
파일: FollowList.java 프로젝트: cg8530/LDXY
    private ArrayList<Following> parseList(HashMap<String, Object> res) {
      if (res == null || res.size() <= 0) {
        return null;
      }

      ArrayList<Following> data = new ArrayList<Following>();
      if ("SinaWeibo".equals(platform.getName())) {
        // users[id, name, description]
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> users =
            (ArrayList<HashMap<String, Object>>) res.get("users");
        for (HashMap<String, Object> user : users) {
          String uid = String.valueOf(user.get("id"));
          if (!map.containsKey(uid)) {
            Following following = new Following();
            following.uid = uid;
            following.screeName = String.valueOf(user.get("name"));
            following.description = String.valueOf(user.get("description"));
            following.icon = String.valueOf(user.get("profile_image_url"));
            map.put(following.uid, following);
            data.add(following);
          }
        }
        hasNext = (Integer) res.get("total_number") > map.size();
      } else if ("TencentWeibo".equals(platform.getName())) {
        hasNext = ((Integer) res.get("hasnext") == 0);
        // info[nick, name, tweet[text]]
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> infos =
            (ArrayList<HashMap<String, Object>>) res.get("info");
        for (HashMap<String, Object> info : infos) {
          String uid = String.valueOf(info.get("name"));
          if (!map.containsKey(uid)) {
            Following following = new Following();
            following.screeName = String.valueOf(info.get("nick"));
            following.uid = uid;
            @SuppressWarnings("unchecked")
            ArrayList<HashMap<String, Object>> tweets =
                (ArrayList<HashMap<String, Object>>) info.get("tweet");
            for (int i = 0; i < tweets.size(); ) {
              HashMap<String, Object> tweet = tweets.get(i);
              following.description = String.valueOf(tweet.get("text"));
              break;
            }
            following.icon = String.valueOf(info.get("head")) + "/100";
            map.put(following.uid, following);
            data.add(following);
          }
        }
      } else if ("Facebook".equals(platform.getName())) {
        // data[id, name]
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> datas =
            (ArrayList<HashMap<String, Object>>) res.get("data");
        for (HashMap<String, Object> d : datas) {
          String uid = String.valueOf(d.get("id"));
          if (!map.containsKey(uid)) {
            Following following = new Following();
            following.uid = uid;
            following.screeName = String.valueOf(d.get("name"));
            @SuppressWarnings("unchecked")
            HashMap<String, Object> picture = (HashMap<String, Object>) d.get("picture");
            if (picture != null) {
              @SuppressWarnings("unchecked")
              HashMap<String, Object> pData = (HashMap<String, Object>) picture.get("data");
              if (d != null) {
                following.icon = String.valueOf(pData.get("url"));
              }
            }
            map.put(following.uid, following);
            data.add(following);
          }
        }
        @SuppressWarnings("unchecked")
        HashMap<String, Object> paging = (HashMap<String, Object>) res.get("paging");
        hasNext = paging.containsKey("next");
      } else if ("Twitter".equals(platform.getName())) {
        // users[screen_name, name, description]
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> users =
            (ArrayList<HashMap<String, Object>>) res.get("users");
        for (HashMap<String, Object> user : users) {
          String uid = String.valueOf(user.get("screen_name"));
          if (!map.containsKey(uid)) {
            Following following = new Following();
            following.uid = uid;
            following.screeName = String.valueOf(user.get("name"));
            following.description = String.valueOf(user.get("description"));
            following.icon = String.valueOf(user.get("profile_image_url"));
            map.put(following.uid, following);
            data.add(following);
          }
        }
      } else if ("FacebookMessenger".equals(platform.getName())) {
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> users =
            (ArrayList<HashMap<String, Object>>) res.get("users");
        for (HashMap<String, Object> user : users) {
          String userAddr = String.valueOf(user.get("jid"));
          if (!map.containsKey(userAddr)) {
            Following following = new Following();
            following.uid = userAddr;
            following.screeName = String.valueOf(user.get("name"));
            map.put(following.uid, following);
            data.add(following);
          }
        }
        hasNext = false;
      }
      return data;
    }
  /** 循环执行分享 */
  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);
    }
  }