/** 用第三方的头像更新 */ @Background void bindThirdPhoto(String bindType, String bindValue, String imgUrl) { ImgAttachDTO headImg = null; if (!StringUtils.isBlank(imgUrl)) { byte[] fileBytes = new SimpleDownloader().download(imgUrl); if (fileBytes != null && fileBytes.length > 0) { headImg = new ImgAttachDTO(); headImg.setFileBytes(fileBytes); headImg.setFileExtension("png"); headImg.setUserId(getUserId()); } } userService .bindThirdPortrait(bindType, bindValue, headImg) .identify(kREQ_ID_bindThirdPortrait = RequestChannel.getChannelUniqueID(), this); }
/** 用第三方修改头像 */ @Background void modifyUserPhotoInThird(String url) { if (!TextUtils.isEmpty(url)) { byte[] bytes = new SimpleDownloader().download(url); if (bytes != null && bytes.length > 0) { modifiedUserPhoto = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); ImgAttachDTO imgAttachDTO = new ImgAttachDTO(); imgAttachDTO.setFileExtension("png"); imgAttachDTO.setUserId(ZcdhApplication.getInstance().getZcdh_uid()); imgAttachDTO.setFileBytes(bytes); userService .updateImgInUserHomePage(imgAttachDTO) .identify(kREQ_ID_updateImgInUserHomePage = RequestChannel.getChannelUniqueID(), this); } } }
/** 修改头像 */ @Background void modifyUserPhoto(String fileName) { Log.i(TAG, "modifyUserPhoto:" + fileName); File imgFile = new File(fileName); ImgAttachDTO imgAttachDTO = new ImgAttachDTO(); try { imgAttachDTO.setFileBytes(FileIoUtil.read(imgFile)); } catch (IOException e) { e.printStackTrace(); } imgAttachDTO.setFileExtension("jpg"); imgAttachDTO.setFileName(fileName); imgAttachDTO.setFileSize(imgFile.length()); imgAttachDTO.setUserId(ZcdhApplication.getInstance().getZcdh_uid()); userService .updateImgInUserHomePage(imgAttachDTO) .identify(kREQ_ID_updateImgInUserHomePage = RequestChannel.getChannelUniqueID(), this); }