示例#1
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;
     }
   }
 }
    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;
      }
    }
示例#3
0
    @Override
    public void onClick(View v) {
      ShareSDK.initSDK(LoginActivity.this);
      Platform weibo = null;
      switch (v.getId()) {
        case R.id.iv_weixin:
          weibo = ShareSDK.getPlatform(Wechat.NAME);
          break;
        case R.id.iv_qq:
          weibo = ShareSDK.getPlatform(LoginActivity.this, QQ.NAME);
          break;
        case R.id.iv_weibo:
          weibo = ShareSDK.getPlatform(SinaWeibo.NAME);

          break;
        case R.id.iv_kongjian:
          weibo = ShareSDK.getPlatform(QZone.NAME);
          break;
      }
      weibo.setPlatformActionListener(
          new PlatformActionListener() {
            @Override
            public void onComplete(Platform platform, int action, HashMap<String, Object> res) {
              LogUtil.e("授权成功" + res.toString());
              String id, name, description, profile_image_url;
              //                    id=res.get("id").toString();//ID
              name = res.get("nickname").toString(); // 用户名
              //                    description=res.get("description").toString();//描述
              //                    profile_image_url=res.get("profile_image_url").toString();//头像链接
              //                    String str="ID: "+id+";\n"+
              //                            "用户名: "+name+";\n"+
              //                            "描述:"+description+";\n"+
              //                            "用户头像地址:"+profile_image_url;
              LogUtil.e("用户资料: " + name);
              // 通过打印res数据看看有哪些数据是你想要的
              if (action == Platform.ACTION_USER_INFOR) {
                PlatformDb platDB = platform.getDb(); // 获取数平台数据DB
                // 通过DB获取各种数据
                String token = platDB.getToken();
                platDB.getUserGender();
                platDB.getUserIcon();
                String userId = platDB.getUserId();
                platDB.getUserName();
                LogUtil.e("userId=" + userId + "##token=" + token);
              }
              Intent intent = getIntent();
              intent.putExtra("name", name);
              setResult(3, intent);
              finish();
            }

            @Override
            public void onError(Platform platform, int i, Throwable throwable) {
              LogUtil.e("授权失败" + throwable);
            }

            @Override
            public void onCancel(Platform platform, int i) {
              LogUtil.e("授权取消");
            }
          });
      weibo.authorize();
      // 移除授权
      //                    weibo.removeAccount(true);

      weibo.showUser(null); // 执行登录,登录后在回调里面获取用户资料
      // weibo.showUser(“3189087725”);//获取账号为“3189087725”的资料
    }