Esempio n. 1
0
 private void authorize(Platform plat) {
   showDialog("正在调起授权");
   if (plat == null) {
     //          popupOthers();
     return;
   }
   /** 清除之前的账户 */
   if (plat.isValid()) {
     plat.removeAccount();
   }
   // 判断指定平台是否已经完成授权
   //        if (plat.isAuthValid()) {
   //        String userId = plat.getDb().getUserId();
   //            if (userId != null) {
   //                handler.sendEmptyMessage(MSG_USERID_FOUND);
   ////                login(plat.getName(), userId, null);
   //                return;
   //            }
   //        }
   plat.setPlatformActionListener(this);
   // true不使用SSO授权,false使用SSO授权
   plat.SSOSetting(false);
   // 获取用户资料
   plat.showUser(null);
 }
Esempio n. 2
0
 //    点击事件的实现
 public void loginOperate(View view) {
   if (view != null) {
     int id = view.getId();
     switch (id) {
         //                回退按键退出当前的Activity
       case R.id.login_back:
         finish();
         break;
         //                登录按键
       case R.id.login_button:
         break;
         //                忘记密码处理
       case R.id.login_forgetpwd:
         break;
         //                注册新用户
       case R.id.login_new_user_register:
         break;
         //                第三方微信登录
       case R.id.login_wechat:
         Platform wechat = ShareSDK.getPlatform(this, Wechat.NAME);
         wechat.SSOSetting(false);
         wechat.setPlatformActionListener(this);
         wechat.authorize();
         break;
         //                第三方qq登录
       case R.id.login_qq:
         Platform qq = ShareSDK.getPlatform(this, QQ.NAME);
         qq.setPlatformActionListener(this);
         qq.authorize();
         break;
         //                第三方新浪登录
       case R.id.login_sina:
         Platform sina = ShareSDK.getPlatform(this, SinaWeibo.NAME);
         sina.setPlatformActionListener(this);
         sina.authorize();
         break;
     }
   }
 }
Esempio n. 3
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);
    }
  }
  /** 循环执行分享 */
  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);
    }
  }
    public void onClick(View v) {

      switch (v.getId()) {
        case R.id.submit_getPositionImage:
          {
            String string = positionTextView.getText().toString();
            if (string != "" && !string.equals(R.string.getposition)) InitLocation();
            positionTextView.setText(R.string.getposition);

            mLocationClient.start();
          }

          break;
        case R.id.submit_IsLock:
          {
            // Log.i("IsLock", "IsLock");
            if (isPublicTextView.getText().toString().equals(getString(R.string.public_friend))) {
              isPublicTextView.setText((getString(R.string.private_friend)));
              isPublicImage.setImageResource(R.drawable.submit_unpublicimage);

              isPublicTextView.setTextColor(getResources().getColor(R.color.lock_color));

            } else if (isPublicTextView
                .getText()
                .toString()
                .equals(getString(R.string.private_friend))) {
              isPublicTextView.setText(getString(R.string.public_friend));
              isPublicImage.setImageResource(R.drawable.submit_publicimage);
              isPublicTextView.setTextColor(getResources().getColor(R.color.unlock_color));
            }
          }
          break;
        case R.id.submit_IsCompany:
          {
            // Log.i("IsLock", "IsLock");
            if (isCompanyTextView.getText().toString().equals("无")) {
              isCompanyTextView.setText("企业");

            } else if (isCompanyTextView.getText().toString().equals("企业")) {
              isCompanyTextView.setText("高校");

            } else if (isCompanyTextView.getText().toString().equals("高校")) {
              isCompanyTextView.setText("无");
            }
          }

          break;
        case R.id.submit_add_classification:
          {
            showPopwindow(CLASSFICATION_POP);
            // classificationTextView.setText("游戏");
          }

          break;
        case R.id.submit_choose_group:
          {
            showPopwindow(ChooseGroup_POP);
          }

          break;
        case R.id.submit_sinaweibo:
          {
            Platform sina = ShareSDK.getPlatform(SubmitActivity.this, SinaWeibo.NAME);
            sina.setPlatformActionListener(this); // 设置分享事件回调
            if (sina.isValid()
                && sinaweiboTextView.getCurrentTextColor()
                    == getResources().getColor(R.color.choose_color)) {
              sina.removeAccount();
            } else if (sina.isValid()
                && sinaweiboTextView.getCurrentTextColor()
                    == getResources().getColor(R.color.unchoose_color)) {
              showToastMessage("已授权成功~~~~");
              sinax = true;
            } else {
              showToastMessage("请授权~~~~");
              sina.SSOSetting(true);
              sina.authorize();
              // 执行图文分享
            }
            if (sinaweiboTextView.getCurrentTextColor()
                == getResources().getColor(R.color.unchoose_color)) {
              sinaweiboTextView.setTextColor(getResources().getColor(R.color.choose_color));
            } else {
              sinaweiboTextView.setTextColor(getResources().getColor(R.color.unchoose_color));
            }
          }

          break;
        case R.id.submit_tencentweibo:
          {
            Platform tencentwb = ShareSDK.getPlatform(SubmitActivity.this, TencentWeibo.NAME);
            tencentwb.setPlatformActionListener(this); // 设置分享事件回调
            if (tencentwb.isValid()
                && tencentweiboTextView.getCurrentTextColor()
                    == getResources().getColor(R.color.choose_color)) {
              tencentwb.removeAccount();
            } else if (tencentwb.isValid()
                && tencentweiboTextView.getCurrentTextColor()
                    == getResources().getColor(R.color.unchoose_color)) {
              showToastMessage("已授权成功~~~~");
              tecentx = true;
            } else {
              showToastMessage("请授权~~~~");
              tencentwb.SSOSetting(true);
              tencentwb.authorize();
              // 执行图文分享
            }
            if (tencentweiboTextView.getCurrentTextColor()
                == getResources().getColor(R.color.unchoose_color)) {
              tencentweiboTextView.setTextColor(getResources().getColor(R.color.choose_color));
            } else {
              tencentweiboTextView.setTextColor(getResources().getColor(R.color.unchoose_color));
            }
          }

          break;
        case R.id.submit_renren:
          {
            Platform renren = ShareSDK.getPlatform(SubmitActivity.this, Renren.NAME);
            renren.setPlatformActionListener(this); // 设置分享事件回调
            if (renren.isValid()
                && renrenTextView.getCurrentTextColor()
                    == getResources().getColor(R.color.choose_color)) {
              renren.removeAccount();
            } else if (renren.isValid()
                && renrenTextView.getCurrentTextColor()
                    == getResources().getColor(R.color.unchoose_color)) {
              showToastMessage("已授权成功~~~~");
              renrenx = true;
            } else {
              showToastMessage("请授权~~~~");
              renren.SSOSetting(true);
              renren.authorize();
              // 执行图文分享
            }
            if (renrenTextView.getCurrentTextColor()
                == getResources().getColor(R.color.unchoose_color)) {
              renrenTextView.setTextColor(getResources().getColor(R.color.choose_color));
            } else {
              renrenTextView.setTextColor(getResources().getColor(R.color.unchoose_color));
            }
          }

          break;

        case R.id.submit_douban:
          {
            Platform douban = ShareSDK.getPlatform(SubmitActivity.this, Douban.NAME);
            douban.setPlatformActionListener(this); // 设置分享事件回调
            if (douban.isValid()
                && doubanTextView.getCurrentTextColor()
                    == getResources().getColor(R.color.choose_color)) {
              douban.removeAccount();
            } else if (douban.isValid()
                && doubanTextView.getCurrentTextColor()
                    == getResources().getColor(R.color.unchoose_color)) {
              showToastMessage("已授权成功~~~~");
              doubanx = true;
            } else {
              showToastMessage("请授权~~~~");
              douban.SSOSetting(true);
              douban.authorize();
              // 执行图文分享
            }
            if (doubanTextView.getCurrentTextColor()
                == getResources().getColor(R.color.unchoose_color)) {
              doubanTextView.setTextColor(getResources().getColor(R.color.choose_color));
            } else {
              doubanTextView.setTextColor(getResources().getColor(R.color.unchoose_color));
            }
          }

          break;
          // 点击发送
        case R.id.submit_send_textView:
          {
            Log.d("gy", "click");
            if (classificationTextView
                .getText()
                .toString()
                .equals(getString(R.string.submit_classificationOriginalString))) {
              showToastMessage("请选择视频分类");
            } else if (positionTextView
                .getText()
                .toString()
                .equals(getString(R.string.getposition))) {
              showToastMessage("正在获取位置信息,稍等片刻。。");
            } else {
              if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                File file = new File(path);
                filenameString = file.getName();
                File image = new File(imagePath);
                imagenameString = image.getName();
                if (file.exists()) {
                  uploadbar.setMax((int) file.length());
                  uploadbar.setVisibility(View.VISIBLE);
                  uploadImage(image);
                  uploadFile(file);
                } else {
                  handler.sendMessage(handler.obtainMessage(5, getString(R.string.notexsit)));
                }
              } else {

                handler.sendMessage(handler.obtainMessage(5, getString(R.string.sdcarderror)));
              }
            }
          }

          break;
        case R.id.submit_cancel_textView:
          {
            finish();
          }

          break;
        default:
          break;
      }
    }