コード例 #1
0
 // 设置数据至bean对象
 private void setDataToBean(LoginBean bean, Platform platform) {
   bean.setToken(platform.getDb().getToken()); // 获取授权token
   bean.setExpiresTime(platform.getDb().getExpiresTime()); // 获取token时间
   bean.setUserId(platform.getDb().getUserId()); // 获取用户在此平台的ID
   bean.setNickName(platform.getDb().get("nickname")); // 获取用户昵称
   bean.setIco(platform.getDb().getUserIcon());
 }
コード例 #2
0
  @SuppressWarnings("unchecked")
  public boolean handleMessage(Message msg) {
    dismissDialog();
    switch (msg.what) {
      case MSG_AUTH_CANCEL:
        {
          // 取消授权
          Toast.makeText(this, R.string.auth_cancel, Toast.LENGTH_SHORT).show();
        }
        break;
      case MSG_AUTH_ERROR:
        {
          // 授权失败
          Toast.makeText(this, R.string.auth_error, Toast.LENGTH_SHORT).show();
        }
        break;
      case MSG_AUTH_COMPLETE:
        {
          // 授权成功
          Toast.makeText(this, R.string.auth_complete, Toast.LENGTH_SHORT).show();
          Object[] objs = (Object[]) msg.obj;
          String platform = (String) objs[0];

          Platform plat = ShareSDK.getPlatform(platform);
          userid = plat.getDb().getUserId();
          username = plat.getDb().getUserName();
          //                edtUsername.setText(usericon);
          presenter.otherSigin(username, userid, usericon, layWx);
        }
        break;
    }
    return false;
  }
コード例 #3
0
 @Override
 public void onCancel(Platform platform, int i) {
   Toast.makeText(
           this, getResources().getString(R.string.authorization_cancle), Toast.LENGTH_SHORT)
       .show();
   String name = platform.getDb().getUserName();
   String userIcon = platform.getDb().getUserIcon();
 }
コード例 #4
0
  @Override
  public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {

    Toast.makeText(
            this, getResources().getString(R.string.authorization_success), Toast.LENGTH_SHORT)
        .show();
    String name = platform.getDb().getUserName();
    String userIcon = platform.getDb().getUserIcon();
  }
コード例 #5
0
ファイル: SignupPage.java プロジェクト: 1181631922/video
  /** 初始化数据 */
  private void initData() {
    String gender = "";
    if (platform != null) {
      gender = platform.getDb().getUserGender();
      if (gender.equals("m")) {
        userInfo.setUserGender(UserInfo.Gender.BOY);
        gender = getContext().getString(R.string.tpl_boy);
      } else {
        userInfo.setUserGender(UserInfo.Gender.GIRL);
        gender = getContext().getString(R.string.tpl_girl);
      }

      userInfo.setUserIcon(platform.getDb().getUserIcon());
      userInfo.setUserName(platform.getDb().getUserName());
      userInfo.setUserNote(platform.getDb().getUserId());
    }

    tvUserName.setText(userInfo.getUserName());
    tvUserGender.setText(gender);
    tvUserNote.setText("USER ID : " + userInfo.getUserNote());
    // 加载头像
    if (!TextUtils.isEmpty(userInfo.getUserIcon())) {
      loadIcon();
    }
    // 初始化照片保存地址
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
      String thumPicture =
          Environment.getExternalStorageDirectory().getAbsolutePath()
              + "/"
              + activity.getPackageName()
              + "/download";
      File pictureParent = new File(thumPicture);
      File pictureFile = new File(pictureParent, PICTURE_NAME);

      if (!pictureParent.exists()) {
        pictureParent.mkdirs();
      }
      try {
        if (!pictureFile.exists()) {
          pictureFile.createNewFile();
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      picturePath = pictureFile.getAbsolutePath();
      Log.e("picturePath ==>>", picturePath);
    } else {
      Log.e("change user icon ==>>", "there is not sdcard!");
    }
  }
コード例 #6
0
ファイル: SignupPage.java プロジェクト: 1181631922/video
  /** 加载头像 */
  public void loadIcon() {
    final String imageUrl = platform.getDb().getUserIcon();
    new Thread(
            new Runnable() {
              @Override
              public void run() {
                try {
                  URL picUrl = new URL(imageUrl);
                  Bitmap userIcon = BitmapFactory.decodeStream(picUrl.openStream());
                  FileOutputStream b = null;
                  try {
                    b = new FileOutputStream(picturePath);
                    userIcon.compress(Bitmap.CompressFormat.JPEG, 100, b); // 把数据写入文件
                  } catch (FileNotFoundException e) {
                    e.printStackTrace();
                  } finally {
                    try {
                      b.flush();
                      b.close();
                    } catch (IOException e) {
                      e.printStackTrace();
                    }
                  }
                  userInfo.setUserIcon(picturePath);

                  Message msg = new Message();
                  msg.what = LOAD_USER_ICON;
                  UIHandler.sendMessage(msg, SignupPage.this);
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            })
        .start();
  }
コード例 #7
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);
    }
  }