Skip to content

Commit ff1c26b

Browse files
committed
解决意见反馈Android7.0机型点击图片崩溃问题
1 parent d065987 commit ff1c26b

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

app/src/main/java/com/rae/cnblogs/AppRoute.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ public static void jumpToImagePreview(Context context, @NonNull ArrayList<String
192192
startActivity(context, intent);
193193
}
194194

195+
196+
/**
197+
* 图片查看
198+
*
199+
* @param imgUrl 图片路径
200+
*/
201+
public static void jumpToImagePreview(Context context, @NonNull String imgUrl) {
202+
ArrayList<String> data = new ArrayList<>();
203+
data.add(imgUrl);
204+
jumpToImagePreview(context, data, 0);
205+
}
206+
195207
/**
196208
* 博主界面
197209
*

app/src/main/java/com/rae/cnblogs/activity/FeedbackActivity.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
import com.avos.avoscloud.feedback.FeedbackThread;
4848
import com.avos.avoscloud.feedback.FeedbackThread.SyncCallback;
4949
import com.avos.avoscloud.feedback.Resources;
50+
import com.rae.cnblogs.AppRoute;
51+
import com.rae.cnblogs.AppUI;
5052
import com.rae.cnblogs.R;
5153
import com.rae.cnblogs.sdk.UserProvider;
5254
import com.rae.cnblogs.sdk.bean.UserInfoBean;
@@ -594,11 +596,14 @@ public View getView(int position, View convertView, ViewGroup parent) {
594596

595597
@Override
596598
public void onClick(View v) {
597-
Intent intent = new Intent();
598-
intent.setAction(Intent.ACTION_VIEW);
599-
intent.setDataAndType(
600-
Uri.fromFile(ImageCache.getCacheFile(comment.getAttachment().getUrl())), "image/*");
601-
startActivity(intent);
599+
// fix bugly #432 #422 #412 #382
600+
File file = ImageCache.getCacheFile(comment.getAttachment().getUrl());
601+
if (!file.exists()) {
602+
AppUI.failed(getContext(), "图片不存在!");
603+
return;
604+
}
605+
606+
AppRoute.jumpToImagePreview(getContext(), file.getPath());
602607
}
603608
};
604609
Bitmap attachmentCache = cache.getImage(comment.getAttachment().getUrl());

app/src/main/java/com/rae/cnblogs/presenter/impl/blog/BlogContentPresenterImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ public ObservableSource<String> apply(UserBlogInfo blogInfo) throws Exception {
8181
.subscribe(new ApiDefaultObserver<String>() {
8282
@Override
8383
protected void onError(String message) {
84+
// fix bugly #374
85+
if (mView == null) return;
8486
mView.onLoadContentFailed(message);
8587
}
8688

8789
@Override
8890
protected void accept(String content) {
91+
if (mView == null) return;
8992
mView.getBlog().setContent(content);
9093
mView.onLoadContentSuccess(content);
9194

0 commit comments

Comments
 (0)