private void initUpdateHeade(String imageIO) { IUpdateUI ui = new IUpdateUI() { @Override public void updata(Object allData) { // TODO Auto-generated method stub if (allData == null) { Toast.makeText(getActivity(), "网络不给力", Toast.LENGTH_SHORT).show(); return; } LogAh.e("修改图片::" + allData.toString()); mCodeMessageBean = (CodeMessageBean) allData; if (mCodeMessageBean.getCode().equals("0")) { Toast.makeText(getActivity(), mCodeMessageBean.getMessage(), Toast.LENGTH_SHORT) .show(); } else if (mCodeMessageBean.getCode().equals("1")) { Toast.makeText(getActivity(), mCodeMessageBean.getMessage(), Toast.LENGTH_SHORT) .show(); } } }; GetDataAsyncZGQ asyncZGQ = new GetDataAsyncZGQ( getActivity(), ui, true, RequestBaseMapZGQ.getUpdateImage(mUser.getId(), imageIO)); asyncZGQ.execute(EFaceTypeZGQ.URL_UPDATE_IMAGE); }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // 如果没有登录, 则显示 【登录】按钮, 否则, 显示用户名:xxx if (requestCode == REQUEST_CODE && resultCode == 1) { User user = LoginHelper.getUser(getActivity()); if (user == null) { mBtnLogin.setVisibility(View.VISIBLE); mUsername.setVisibility(View.GONE); } else { mBtnLogin.setVisibility(View.GONE); mUsername.setText(user.getUsername()); mUsername.setVisibility(View.VISIBLE); } } if (resultCode == Activity.RESULT_OK && null != data) { try { mImageHeade.setVisibility(View.GONE); mImageHeadeCircular.setVisibility(View.VISIBLE); // 获得对应图片的路径 Uri selectedImage = data.getData(); String[] filePathColumns = {MediaStore.Images.Media.DATA}; Cursor c = getActivity() .getContentResolver() .query(selectedImage, filePathColumns, null, null, null); c.moveToFirst(); int columnIndex = c.getColumnIndex(filePathColumns[0]); String picturePath = c.getString(columnIndex); c.close(); // 通过路径得到压缩后的bitmap Bitmap bitmap = BitmapUtils.convertToBitmap(picturePath, 200, 200); ArrayList<Bitmap> bitmapList = new ArrayList<Bitmap>(); bitmapList.add(bitmap); // 设置bitmap为头像 mImageHeadeCircular.setImageBitmaps(bitmapList); String imageIOStr = BitmapUtils.sendPhoto(bitmap); initUpdateHeade(imageIOStr); } catch (Exception e) { Toast.makeText(getActivity(), "设置头像出错,是否已经添加读写权限!!", Toast.LENGTH_SHORT).show(); } } }
private void initRefreshUserInfo() { IUpdateUI ui = new IUpdateUI() { @Override public void updata(Object allData) { // TODO Auto-generated method stub if (allData == null) { Toast.makeText(getActivity(), "网络不给力", Toast.LENGTH_SHORT).show(); return; } LogAh.e("刷新用户信息::" + allData.toString()); mUserBean = (RefreshUserInfoBean) allData; LoginHelper.saveLogin( getActivity(), mUserBean.getId(), mUserBean.getUsername(), mUserBean.getImage()); initHeade(mUserBean.getImage()); } }; GetDataAsyncZGQ asyncZGQ = new GetDataAsyncZGQ( getActivity(), ui, true, RequestBaseMapZGQ.getUpdateImage(mUser.getId())); asyncZGQ.execute(EFaceTypeZGQ.URL_REFRESH_USERINFO); }