Skip to content

Commit

Permalink
bugfix 拍照后预览闪退
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcy committed Nov 11, 2020
1 parent 757a8b9 commit 9affacd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ protected void initView()

observeOnDataChange = Observable.just(url+"").subscribeOn(Schedulers.io())
.map(url -> {
File sourceFile = Glide.with(PhotoPreviewActivity.this).asFile().load(url).submit().get();

if(sourceFile == null || !sourceFile.exists()){
return "";
if(Utils.isHttpHead(url)){
File sourceFile = Glide.with(PhotoPreviewActivity.this).asFile().load(url).submit().get();
if(sourceFile == null || !sourceFile.exists()){
return "";
}
return sourceFile.getAbsolutePath();
}else {
return url;
}
return sourceFile.getAbsolutePath();
}).observeOn(AndroidSchedulers.mainThread()).subscribe(path -> {
File resource = new File(path);
imageViewPreview.setImage(ImageSource.uri(Uri.fromFile(resource)));
Expand Down

0 comments on commit 9affacd

Please sign in to comment.