Skip to content

Commit

Permalink
解决无法上传图片的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Justwen committed Feb 17, 2024
1 parent 144cc4c commit 8e12449
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gov.anzong.androidnga.gallery;

import android.Manifest;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
Expand All @@ -18,7 +17,6 @@
import androidx.viewpager.widget.ViewPager;

import com.justwen.androidnga.cloud.CloudServerManager;
import com.tbruyelle.rxpermissions2.RxPermissions;

import java.io.File;
import java.util.Arrays;
Expand Down Expand Up @@ -119,18 +117,10 @@ private void initBottomView() {
}

private void saveBitmap(OnSimpleHttpCallBack<SaveImageTask.DownloadResult> callBack, String... urls) {
new RxPermissions(this)
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe(granted -> {
if (granted) { // Always true pre-M
if (mSaveImageTask == null) {
mSaveImageTask = new SaveImageTask();
}
mSaveImageTask.execute(callBack, urls);
} else {
// Oups permission denied
}
});
if (mSaveImageTask == null) {
mSaveImageTask = new SaveImageTask();
}
mSaveImageTask.execute(callBack, urls);
}

private void saveBitmap(String... urls) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package sp.phone.mvp.presenter;

import android.Manifest;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
Expand All @@ -19,11 +18,8 @@

import gov.anzong.androidnga.R;
import gov.anzong.androidnga.base.util.ContextUtils;
import gov.anzong.androidnga.base.util.PermissionUtils;
import gov.anzong.androidnga.base.util.ToastUtils;
import gov.anzong.androidnga.common.util.EmoticonUtils;
import gov.anzong.androidnga.http.OnHttpCallBack;
import gov.anzong.androidnga.rxjava.BaseSubscriber;
import sp.phone.mvp.contract.TopicPostContract;
import sp.phone.mvp.model.TopicPostModel;
import sp.phone.param.PostParam;
Expand Down Expand Up @@ -109,16 +105,7 @@ public void post(String title, String body, boolean isAnony) {

@Override
public void showFilePicker() {
PermissionUtils.request(mBaseView, new BaseSubscriber<Boolean>() {

@Override
public void onNext(Boolean aBoolean) {
if (aBoolean != null && aBoolean) {
mBaseView.showFilePicker();
}

}
}, Manifest.permission.WRITE_EXTERNAL_STORAGE);
mBaseView.showFilePicker();
}

@Override
Expand Down

0 comments on commit 8e12449

Please sign in to comment.