Commit 9fbe0a119fcd9ce8a36304110c3b61161c3e3999
1 parent
4aa2829e26
Exists in
master
解决拍照无反应问题
Showing
2 changed files
with
9 additions
and
8 deletions
Show diff stats
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/FeedBackActivity.java
... | ... | @@ -53,7 +53,7 @@ public class FeedBackActivity extends AppCompatActivity implements View.OnClickL |
53 | 53 | private static final int REQUEST_CODE_TAKE_PHOTO = 1; |
54 | 54 | private static final int REQUEST_CODE_ALBUM = 2; |
55 | 55 | private static final int REQUEST_CODE_CROUP_PHOTO = 3; |
56 | - SimpleDraweeView mSimpleDraweeView; | |
56 | + private SimpleDraweeView mSimpleDraweeView; | |
57 | 57 | String type = "个人中心"; |
58 | 58 | private File file; |
59 | 59 | private Uri uri; | ... | ... |
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
... | ... | @@ -265,8 +265,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
265 | 265 | |
266 | 266 | |
267 | 267 | private void initData() { |
268 | - //初始化图片 | |
269 | - file = new File(FileUtil.getCachePath(this), "user-header.jpg"); | |
268 | + file = new File(FileUtil.getCachePath(this), "user-avatar.jpg"); | |
270 | 269 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
271 | 270 | uri = Uri.fromFile(file); |
272 | 271 | } else { |
... | ... | @@ -568,6 +567,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
568 | 567 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); |
569 | 568 | startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); |
570 | 569 | } |
570 | + | |
571 | 571 | //选择图库 |
572 | 572 | private void uploadAvatarFromAlbumRequest() { |
573 | 573 | Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); |
... | ... | @@ -595,7 +595,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
595 | 595 | Toast.makeText(this, "没有得到相册图片", Toast.LENGTH_LONG).show(); |
596 | 596 | } |
597 | 597 | } else if (requestCode == REQUEST_CODE_TAKE_PHOTO) { |
598 | - startPhotoZoom(uri); | |
598 | + //startPhotoZoom(uri); | |
599 | + uploadAvatarFromPhoto(); | |
599 | 600 | } else if (requestCode == REQUEST_CODE_CROUP_PHOTO) { |
600 | 601 | uploadAvatarFromPhoto(); |
601 | 602 | } |
... | ... | @@ -626,17 +627,15 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
626 | 627 | //上传头像 |
627 | 628 | |
628 | 629 | try { |
629 | - HttpManager.getInstance().header(this, userID, typeaccount, file.getPath()); | |
630 | + HttpManager.getInstance().header(this, userID, typeaccount, fileSrc); | |
630 | 631 | } catch (UnsupportedEncodingException e) { |
631 | 632 | e.printStackTrace(); |
632 | 633 | } |
633 | 634 | |
634 | - //photo = MultipartBody.Part.createFormData("portrait", fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()), requestBody); | |
635 | - //Fresco设置圆形头像 | |
636 | 635 | GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); |
637 | 636 | GenericDraweeHierarchy hierarchy = builder |
638 | 637 | .setDesiredAspectRatio(1f) |
639 | - .setFailureImage(R.mipmap.blank) | |
638 | + .setFailureImage(R.mipmap.header_default) | |
640 | 639 | //圆形头像 |
641 | 640 | .setRoundingParams(RoundingParams.asCircle()) |
642 | 641 | .build(); |
... | ... | @@ -691,6 +690,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe |
691 | 690 | } |
692 | 691 | } |
693 | 692 | |
693 | + | |
694 | + | |
694 | 695 | private long exitTime = 0; |
695 | 696 | |
696 | 697 | @Override | ... | ... |