feat : 去掉 项目内 相册,图片选择,拍照 有关的 第三方库跟代码
This commit is contained in:
@@ -92,18 +92,18 @@
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
|
||||
<!-- 照片选择 -->
|
||||
<activity
|
||||
android:name="com.netease.nim.uikit.common.media.picker.activity.PickImageActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<!-- <activity-->
|
||||
<!-- android:name="com.netease.nim.uikit.common.media.picker.activity.PickImageActivity"-->
|
||||
<!-- android:screenOrientation="portrait"-->
|
||||
<!-- android:theme="@style/AppTheme.NoActionBar" />-->
|
||||
<activity
|
||||
android:name="com.netease.nim.uikit.common.media.picker.activity.CropImageActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name="com.netease.nim.uikit.common.media.picker.activity.PickerAlbumActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<!-- <activity-->
|
||||
<!-- android:name="com.netease.nim.uikit.common.media.picker.activity.PickerAlbumActivity"-->
|
||||
<!-- android:screenOrientation="portrait"-->
|
||||
<!-- android:theme="@style/AppTheme.NoActionBar" />-->
|
||||
<activity
|
||||
android:name="com.netease.nim.uikit.common.media.picker.activity.PickerAlbumPreviewActivity"
|
||||
android:screenOrientation="portrait"
|
||||
@@ -114,21 +114,23 @@
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize"
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<activity
|
||||
android:name="com.netease.nim.uikit.common.media.picker.activity.PreviewImageFromCameraActivity"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:label="@string/input_panel_take"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="com.netease.nim.uikit.common.media.picker.activity.PreviewImageFromCameraActivity"-->
|
||||
<!-- android:configChanges="keyboardHidden|orientation"-->
|
||||
<!-- android:label="@string/input_panel_take"-->
|
||||
<!-- android:screenOrientation="portrait"-->
|
||||
<!-- android:theme="@style/AppTheme.NoActionBar"-->
|
||||
<!-- android:windowSoftInputMode="stateHidden|adjustResize" />-->
|
||||
|
||||
<!-- 视频 -->
|
||||
<activity
|
||||
android:name="com.netease.nim.uikit.business.session.activity.CaptureVideoActivity"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize"
|
||||
android:theme="@style/AppTheme.NoActionBar"/>
|
||||
<!-- <activity-->
|
||||
<!-- android:name="com.netease.nim.uikit.business.session.activity.CaptureVideoActivity"-->
|
||||
<!-- android:configChanges="keyboardHidden|orientation"-->
|
||||
<!-- android:screenOrientation="portrait"-->
|
||||
<!-- android:windowSoftInputMode="stateHidden|adjustResize"-->
|
||||
<!-- android:theme="@style/AppTheme.NoActionBar"/>-->
|
||||
|
||||
<activity
|
||||
android:name="com.netease.nim.uikit.business.session.activity.WatchVideoActivity"
|
||||
|
@@ -1,179 +0,0 @@
|
||||
package com.netease.nim.uikit.business.session.actions;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||
import com.netease.nim.uikit.business.session.constant.RequestCode;
|
||||
import com.netease.nim.uikit.business.session.helper.SendImageHelper;
|
||||
import com.netease.nim.uikit.common.media.picker.PickImageHelper;
|
||||
import com.netease.nim.uikit.common.media.picker.activity.PickImageActivity;
|
||||
import com.netease.nim.uikit.common.media.picker.activity.PreviewImageFromCameraActivity;
|
||||
import com.netease.nim.uikit.common.util.file.AttachmentStore;
|
||||
import com.netease.nim.uikit.common.util.media.ImageUtil;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageType;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageUtil;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by zhoujianghua on 2015/7/31.
|
||||
*/
|
||||
public abstract class PickImageAction extends BaseAction {
|
||||
|
||||
private static final int PICK_IMAGE_COUNT = 9;
|
||||
private static final int PORTRAIT_IMAGE_WIDTH = 720;
|
||||
|
||||
public static final String MIME_JPEG = "image/jpeg";
|
||||
public static final String JPG = ".jpg";
|
||||
|
||||
private boolean multiSelect;
|
||||
private boolean crop = false;
|
||||
|
||||
protected abstract void onPicked(File file);
|
||||
|
||||
protected PickImageAction(int iconResId, int titleId, boolean multiSelect) {
|
||||
super(iconResId, titleId);
|
||||
this.multiSelect = multiSelect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
int requestCode = makeRequestCode(RequestCode.PICK_IMAGE);
|
||||
showSelector(getTitleId(), requestCode, multiSelect, tempFile());
|
||||
}
|
||||
|
||||
private String tempFile() {
|
||||
String filename = StringUtil.get32UUID() + JPG;
|
||||
return StorageUtil.getWritePath(filename, StorageType.TYPE_TEMP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开图片选择器
|
||||
*/
|
||||
private void showSelector(int titleId, final int requestCode, final boolean multiSelect, final String outPath) {
|
||||
PickImageHelper.PickImageOption option = new PickImageHelper.PickImageOption();
|
||||
option.titleResId = titleId;
|
||||
option.multiSelect = multiSelect;
|
||||
option.multiSelectMaxCount = PICK_IMAGE_COUNT;
|
||||
option.crop = crop;
|
||||
option.cropOutputImageWidth = PORTRAIT_IMAGE_WIDTH;
|
||||
option.cropOutputImageHeight = PORTRAIT_IMAGE_WIDTH;
|
||||
option.outputPath = outPath;
|
||||
|
||||
PickImageHelper.pickImage(getActivity(), requestCode, option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case RequestCode.PICK_IMAGE:
|
||||
onPickImageActivityResult(requestCode, data);
|
||||
break;
|
||||
case RequestCode.PREVIEW_IMAGE_FROM_CAMERA:
|
||||
onPreviewImageActivityResult(requestCode, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片选取回调
|
||||
*/
|
||||
private void onPickImageActivityResult(int requestCode, Intent data) {
|
||||
if (data == null) {
|
||||
SingleToastUtil.showToastShort(R.string.picker_image_error);
|
||||
return;
|
||||
}
|
||||
boolean local = data.getBooleanExtra(Extras.EXTRA_FROM_LOCAL, false);
|
||||
if (local) {
|
||||
// 本地相册
|
||||
sendImageAfterSelfImagePicker(data);
|
||||
} else {
|
||||
// 拍照
|
||||
Intent intent = new Intent();
|
||||
if (!handleImagePath(intent, data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
intent.setClass(getActivity(), PreviewImageFromCameraActivity.class);
|
||||
getActivity().startActivityForResult(intent, makeRequestCode(RequestCode.PREVIEW_IMAGE_FROM_CAMERA));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可以获取图片
|
||||
*/
|
||||
private boolean handleImagePath(Intent intent, Intent data) {
|
||||
String photoPath = data.getStringExtra(Extras.EXTRA_FILE_PATH);
|
||||
if (TextUtils.isEmpty(photoPath)) {
|
||||
SingleToastUtil.showToastShort(R.string.picker_image_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
File imageFile = new File(photoPath);
|
||||
intent.putExtra("OrigImageFilePath", photoPath);
|
||||
File scaledImageFile = ImageUtil.getScaledImageFileWithMD5(imageFile, MIME_JPEG);
|
||||
|
||||
boolean local = data.getExtras().getBoolean(Extras.EXTRA_FROM_LOCAL, true);
|
||||
if (!local) {
|
||||
// 删除拍照生成的临时文件
|
||||
AttachmentStore.delete(photoPath);
|
||||
}
|
||||
|
||||
if (scaledImageFile == null) {
|
||||
// Toast.makeText(getActivity(), R.string.picker_image_error, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.picker_image_error);
|
||||
return false;
|
||||
} else {
|
||||
ImageUtil.makeThumbnail(getActivity(), scaledImageFile);
|
||||
}
|
||||
intent.putExtra("ImageFilePath", scaledImageFile.getAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从预览界面点击发送图片
|
||||
*/
|
||||
private void sendImageAfterPreviewPhotoActivityResult(Intent data) {
|
||||
SendImageHelper.sendImageAfterPreviewPhotoActivityResult(data, new SendImageHelper.Callback() {
|
||||
|
||||
@Override
|
||||
public void sendImage(File file, boolean isOrig) {
|
||||
onPicked(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送图片
|
||||
*/
|
||||
private void sendImageAfterSelfImagePicker(final Intent data) {
|
||||
SendImageHelper.sendImageAfterSelfImagePicker(getActivity(), data, new SendImageHelper.Callback() {
|
||||
|
||||
@Override
|
||||
public void sendImage(File file, boolean isOrig) {
|
||||
onPicked(file);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 拍摄回调
|
||||
*/
|
||||
private void onPreviewImageActivityResult(int requestCode, Intent data) {
|
||||
if (data.getBooleanExtra(PreviewImageFromCameraActivity.RESULT_SEND, false)) {
|
||||
sendImageAfterPreviewPhotoActivityResult(data);
|
||||
} else if (data.getBooleanExtra(PreviewImageFromCameraActivity.RESULT_RETAKE, false)) {
|
||||
String filename = StringUtil.get32UUID() + JPG;
|
||||
String path = StorageUtil.getWritePath(filename, StorageType.TYPE_TEMP);
|
||||
|
||||
if (requestCode == RequestCode.PREVIEW_IMAGE_FROM_CAMERA) {
|
||||
PickImageActivity.start(getActivity(), makeRequestCode(RequestCode.PICK_IMAGE), PickImageActivity.FROM_CAMERA, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,749 +0,0 @@
|
||||
package com.netease.nim.uikit.business.session.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Point;
|
||||
import android.hardware.Camera;
|
||||
import android.media.CamcorderProfile;
|
||||
import android.media.MediaRecorder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.common.activity.UI;
|
||||
import com.netease.nim.uikit.common.ui.dialog.EasyAlertDialog;
|
||||
import com.netease.nim.uikit.common.ui.dialog.EasyAlertDialogHelper;
|
||||
import com.netease.nim.uikit.common.util.file.AttachmentStore;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.TimeUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 视频录制界面
|
||||
* <p/>
|
||||
* Created by huangjun on 2015/4/11.
|
||||
*/
|
||||
public class CaptureVideoActivity extends UI implements SurfaceHolder.Callback {
|
||||
|
||||
private static final String TAG = "video";
|
||||
|
||||
private static final String EXTRA_DATA_FILE_NAME = "EXTRA_DATA_FILE_NAME";
|
||||
|
||||
private static final int VIDEO_TIMES = 180;
|
||||
|
||||
private static final int VIDEO_WIDTH = 320;
|
||||
|
||||
private static final int VIDEO_HEIGHT = 240;
|
||||
|
||||
// context
|
||||
|
||||
public Handler handler = new Handler();
|
||||
|
||||
// media
|
||||
|
||||
private MediaRecorder mediaRecorder;// 录制视频的类
|
||||
|
||||
private Camera camera;
|
||||
|
||||
// view
|
||||
|
||||
private SurfaceView surfaceview;
|
||||
|
||||
private SurfaceHolder surfaceHolder;
|
||||
|
||||
private ImageView recordBtn;
|
||||
|
||||
private ImageView recordingState;
|
||||
|
||||
private TextView recordingTimeTextView;
|
||||
|
||||
private ImageView switchCamera; // 切换摄像头
|
||||
|
||||
// state
|
||||
|
||||
private int cameraId = 0;
|
||||
|
||||
private String filename;
|
||||
|
||||
private boolean previewing = false;
|
||||
|
||||
private boolean multiCamera = false;
|
||||
|
||||
private boolean recording = false;
|
||||
|
||||
private long start, end; // 录制时间控制
|
||||
|
||||
private long duration = 0;
|
||||
|
||||
private boolean destroyed = false;
|
||||
|
||||
private int mAngle = 0;
|
||||
|
||||
private LinkedList<Point> backCameraSize = new LinkedList<>();
|
||||
|
||||
private LinkedList<Point> frontCameraSize = new LinkedList<>();
|
||||
|
||||
public static void start(Activity activity, String videoFilePath, int captureCode) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(activity, CaptureVideoActivity.class);
|
||||
intent.putExtra(EXTRA_DATA_FILE_NAME, videoFilePath);
|
||||
activity.startActivityForResult(intent, captureCode);
|
||||
}
|
||||
|
||||
// 录制时间计数
|
||||
private Runnable runnable = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
end = new Date().getTime();
|
||||
duration = (end - start);
|
||||
int invs = (int) (duration / 1000);
|
||||
|
||||
recordingTimeTextView.setText(TimeUtil.secToTime(invs));
|
||||
|
||||
// 录制过程中红点闪烁效果
|
||||
if (invs % 2 == 0) {
|
||||
recordingState.setBackgroundResource(R.drawable.nim_record_start);
|
||||
} else {
|
||||
recordingState.setBackgroundResource(R.drawable.nim_record_video);
|
||||
}
|
||||
if (invs >= VIDEO_TIMES) {
|
||||
stopRecorder();
|
||||
sendVideo();
|
||||
} else {
|
||||
handler.postDelayed(this, 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFormat(PixelFormat.TRANSLUCENT); // 使得窗口支持透明度
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.nim_capture_video_activity);
|
||||
setTitle(R.string.video_record);
|
||||
|
||||
parseIntent();
|
||||
findViews();
|
||||
initActionBar();
|
||||
|
||||
setViewsListener();
|
||||
updateRecordUI();
|
||||
|
||||
getVideoPreviewSize();
|
||||
|
||||
surfaceview = (SurfaceView) this.findViewById(R.id.videoView);
|
||||
SurfaceHolder holder = surfaceview.getHolder();
|
||||
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
||||
holder.addCallback(this);
|
||||
|
||||
resizeSurfaceView();
|
||||
}
|
||||
|
||||
private void parseIntent() {
|
||||
filename = getIntent().getExtras().getString(EXTRA_DATA_FILE_NAME);
|
||||
}
|
||||
|
||||
private void findViews() {
|
||||
recordingTimeTextView = (TextView) findViewById(R.id.record_times);
|
||||
recordingState = (ImageView) findViewById(R.id.recording_id);
|
||||
|
||||
recordBtn = (ImageView) findViewById(R.id.record_btn);
|
||||
switchCamera = (ImageView) findViewById(R.id.switch_cameras);
|
||||
}
|
||||
|
||||
private void initActionBar() {
|
||||
checkMultiCamera();
|
||||
}
|
||||
|
||||
private void setViewsListener() {
|
||||
recordBtn.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (recording) {
|
||||
stopRecorder();
|
||||
sendVideo();
|
||||
} else {
|
||||
startRecorder();
|
||||
}
|
||||
}
|
||||
});
|
||||
switchCamera.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchCamera();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@TargetApi(9)
|
||||
private void switchCamera() {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
cameraId = (cameraId + 1) % Camera.getNumberOfCameras();
|
||||
}
|
||||
resizeSurfaceView();
|
||||
shutdownCamera();
|
||||
initCamera();
|
||||
startPreview();
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
if (recording) {
|
||||
stopRecorder();
|
||||
sendVideo();
|
||||
} else {
|
||||
shutdownCamera();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
shutdownCamera();
|
||||
|
||||
destroyed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (recording) {
|
||||
stopRecorder();
|
||||
}
|
||||
|
||||
shutdownCamera();
|
||||
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void getVideoPreviewSize(boolean isFront) {
|
||||
CamcorderProfile profile;
|
||||
int cameraId = 0;
|
||||
|
||||
if (super.isCompatible(9)) {
|
||||
if (isFront) {
|
||||
cameraId = Camera.CameraInfo.CAMERA_FACING_FRONT;
|
||||
} else {
|
||||
cameraId = Camera.CameraInfo.CAMERA_FACING_BACK;
|
||||
}
|
||||
}
|
||||
|
||||
if (super.isCompatible(11)) {
|
||||
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_480P)) {
|
||||
profile = CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_480P);
|
||||
if (profile != null) {
|
||||
Point point = new Point();
|
||||
point.x = profile.videoFrameWidth;
|
||||
point.y = profile.videoFrameHeight;
|
||||
if (isFront) {
|
||||
frontCameraSize.addLast(point);
|
||||
} else {
|
||||
backCameraSize.addLast(point);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LogUtil.e(TAG, (isFront ? "Back Camera" : "Front Camera") + " no QUALITY_480P");
|
||||
}
|
||||
|
||||
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_CIF)) {
|
||||
profile = CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_CIF);
|
||||
if (profile != null) {
|
||||
Point point = new Point();
|
||||
point.x = profile.videoFrameWidth;
|
||||
point.y = profile.videoFrameHeight;
|
||||
if (isFront) {
|
||||
frontCameraSize.addLast(point);
|
||||
} else {
|
||||
backCameraSize.addLast(point);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LogUtil.e(TAG, (isFront ? "Back Camera" : "Front Camera") + " no QUALITY_CIF");
|
||||
}
|
||||
|
||||
if (super.isCompatible(15)) {
|
||||
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_QVGA)) {
|
||||
profile = CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_QVGA);
|
||||
if (profile != null) {
|
||||
Point point = new Point();
|
||||
point.x = profile.videoFrameWidth;
|
||||
point.y = profile.videoFrameHeight;
|
||||
if (isFront) {
|
||||
frontCameraSize.addLast(point);
|
||||
} else {
|
||||
backCameraSize.addLast(point);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LogUtil.e(TAG, (isFront ? "Back Camera" : "Front Camera") + " no QUALITY_QVGA");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (super.isCompatible(9)) {
|
||||
profile = CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_LOW);
|
||||
if (profile == null) {
|
||||
Point point = new Point();
|
||||
point.x = 320;
|
||||
point.y = 240;
|
||||
if (isFront) {
|
||||
frontCameraSize.addLast(point);
|
||||
} else {
|
||||
backCameraSize.addLast(point);
|
||||
}
|
||||
LogUtil.e(TAG, (isFront ? "Back Camera" : "Front Camera") + " no QUALITY_LOW");
|
||||
} else {
|
||||
Point point = new Point();
|
||||
point.x = profile.videoFrameWidth;
|
||||
point.y = profile.videoFrameHeight;
|
||||
if (isFront) {
|
||||
frontCameraSize.addLast(point);
|
||||
} else {
|
||||
backCameraSize.addLast(point);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!isFront) {
|
||||
profile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
|
||||
if (profile == null) {
|
||||
Point point = new Point();
|
||||
point.x = 320;
|
||||
point.y = 240;
|
||||
backCameraSize.addLast(point);
|
||||
} else {
|
||||
Point point = new Point();
|
||||
point.x = profile.videoFrameWidth;
|
||||
point.y = profile.videoFrameHeight;
|
||||
backCameraSize.addLast(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void getVideoPreviewSize() {
|
||||
backCameraSize.clear();
|
||||
frontCameraSize.clear();
|
||||
getVideoPreviewSize(false);
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
if (Camera.getNumberOfCameras() >= 2) {
|
||||
getVideoPreviewSize(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Point currentUsePoint = null;
|
||||
|
||||
private void resizeSurfaceView() {
|
||||
Point point;
|
||||
if (cameraId == 0) {
|
||||
point = backCameraSize.getFirst();
|
||||
} else {
|
||||
point = frontCameraSize.getFirst();
|
||||
}
|
||||
if (currentUsePoint != null && point.equals(currentUsePoint)) {
|
||||
return;
|
||||
} else {
|
||||
currentUsePoint = point;
|
||||
int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
|
||||
int surfaceHeight = screenWidth * point.x / point.y;
|
||||
if (surfaceview != null) {
|
||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) surfaceview.getLayoutParams();
|
||||
lp.width = screenWidth;
|
||||
lp.height = surfaceHeight;
|
||||
lp.addRule(13);
|
||||
surfaceview.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void setCamcorderProfile() {
|
||||
CamcorderProfile profile;
|
||||
|
||||
profile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
|
||||
|
||||
if (profile != null) {
|
||||
if (currentUsePoint != null) {
|
||||
profile.videoFrameWidth = currentUsePoint.x;
|
||||
profile.videoFrameHeight = currentUsePoint.y;
|
||||
}
|
||||
|
||||
profile.fileFormat = MediaRecorder.OutputFormat.MPEG_4;
|
||||
|
||||
if (Build.MODEL.equalsIgnoreCase("MB525") || Build.MODEL.equalsIgnoreCase("C8812") || Build.MODEL.equalsIgnoreCase("C8650")) {
|
||||
profile.videoCodec = MediaRecorder.VideoEncoder.H263;
|
||||
} else {
|
||||
profile.videoCodec = MediaRecorder.VideoEncoder.H264;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 14) {
|
||||
profile.audioCodec = MediaRecorder.AudioEncoder.AAC;
|
||||
} else {
|
||||
if (Build.DISPLAY != null && Build.DISPLAY.indexOf("MIUI") >= 0) {
|
||||
profile.audioCodec = MediaRecorder.AudioEncoder.AAC;
|
||||
} else {
|
||||
profile.audioCodec = MediaRecorder.AudioEncoder.AMR_NB;
|
||||
}
|
||||
}
|
||||
mediaRecorder.setProfile(profile);
|
||||
} else {
|
||||
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
|
||||
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
|
||||
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
|
||||
mediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void setVideoOrientation() {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
Camera.CameraInfo info = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(cameraId, info);
|
||||
mediaRecorder.setOrientationHint(info.orientation);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRecordUI() {
|
||||
if (recording) {
|
||||
recordBtn.setBackgroundResource(R.drawable.nim_video_capture_stop_btn);
|
||||
} else {
|
||||
recordBtn.setBackgroundResource(R.drawable.nim_video_capture_start_btn);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean startRecorderInternal() throws Exception {
|
||||
shutdownCamera();
|
||||
if (!initCamera())
|
||||
return false;
|
||||
|
||||
switchCamera.setVisibility(View.GONE);
|
||||
mediaRecorder = new MediaRecorder();
|
||||
|
||||
camera.unlock();
|
||||
mediaRecorder.setCamera(camera);
|
||||
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
|
||||
|
||||
setCamcorderProfile();
|
||||
|
||||
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
|
||||
mediaRecorder.setMaxDuration(1000 * VIDEO_TIMES);
|
||||
mediaRecorder.setOutputFile(filename);
|
||||
setVideoOrientation();
|
||||
|
||||
mediaRecorder.prepare();
|
||||
mediaRecorder.start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void startRecorder() {
|
||||
try {
|
||||
startRecorderInternal();
|
||||
} catch (Exception e) {
|
||||
LogUtil.e(TAG, "start MediaRecord failed: " + e);
|
||||
// Toast.makeText(this, R.string.start_camera_to_record_failed, Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToastShort(R.string.start_camera_to_record_failed);
|
||||
mediaRecorder.release();
|
||||
mediaRecorder = null;
|
||||
camera.release();
|
||||
camera = null;
|
||||
return;
|
||||
|
||||
}
|
||||
recording = true;
|
||||
start = new Date().getTime();
|
||||
handler.postDelayed(runnable, 1000);
|
||||
|
||||
recordingTimeTextView.setText("00:00");
|
||||
|
||||
updateRecordUI();
|
||||
}
|
||||
|
||||
private void stopRecorder() {
|
||||
if (mediaRecorder != null) {
|
||||
try {
|
||||
mediaRecorder.stop();
|
||||
} catch (Exception e) {
|
||||
LogUtil.w(TAG, getString(R.string.stop_fail_maybe_stopped));
|
||||
}
|
||||
mediaRecorder.release();
|
||||
mediaRecorder = null;
|
||||
}
|
||||
if (camera != null) {
|
||||
camera.release();
|
||||
camera = null;
|
||||
}
|
||||
|
||||
handler.removeCallbacks(runnable);
|
||||
recordingState.setBackgroundResource(R.drawable.nim_record_start);
|
||||
recording = false;
|
||||
updateRecordUI();
|
||||
}
|
||||
|
||||
private void sendVideo() {
|
||||
File convertedFile = new File(filename);
|
||||
String message = "";
|
||||
if (convertedFile.exists()) {
|
||||
int b = (int) convertedFile.length();
|
||||
int kb = b / 1024;
|
||||
float mb = kb / 1024f;
|
||||
message += mb > 1 ? getString(R.string.capture_video_size_in_mb, mb) : getString(
|
||||
R.string.capture_video_size_in_kb, kb);
|
||||
message += getString(R.string.is_send_video);
|
||||
if (mb <= 1 && kb < 10) {
|
||||
tooShortAlert();
|
||||
return;
|
||||
}
|
||||
}
|
||||
EasyAlertDialogHelper.OnDialogActionListener listener = new EasyAlertDialogHelper.OnDialogActionListener() {
|
||||
|
||||
@Override
|
||||
public void doCancelAction() {
|
||||
cancelRecord();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doOkAction() {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("duration", duration);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
final EasyAlertDialog dialog = EasyAlertDialogHelper.createOkCancelDiolag(this, null, message, true, listener);
|
||||
|
||||
if (!isFinishing() && !destroyed) {
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频录制太短
|
||||
*/
|
||||
private void tooShortAlert() {
|
||||
EasyAlertDialogHelper.showOneButtonDiolag(this, null, getString(R.string.video_record_short), getString(R.string.iknow), true, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
cancelRecord();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消重录
|
||||
*/
|
||||
private void cancelRecord() {
|
||||
AttachmentStore.delete(filename);
|
||||
recordingTimeTextView.setText("00:00");
|
||||
shutdownCamera();
|
||||
initCamera();
|
||||
startPreview();
|
||||
checkMultiCamera();
|
||||
}
|
||||
|
||||
/**
|
||||
* *************************************************** Camera Start ***************************************************
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public void checkMultiCamera() {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
if (Camera.getNumberOfCameras() > 1) {
|
||||
multiCamera = true;
|
||||
switchCamera.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
switchCamera.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
switchCamera.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private boolean initCamera() {
|
||||
try {
|
||||
if (multiCamera) {
|
||||
camera = Camera.open(cameraId);
|
||||
} else {
|
||||
camera = Camera.open();
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
LogUtil.e(TAG, "init camera failed: " + e);
|
||||
// Toast.makeText(this, R.string.connect_vedio_device_fail, Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToastShort(R.string.connect_vedio_device_fail);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (camera != null) {
|
||||
setCameraParameters();
|
||||
}
|
||||
|
||||
return camera != null;
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void setCameraParameters() {
|
||||
Camera.Parameters params = camera.getParameters();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 15) {
|
||||
if (params.isVideoStabilizationSupported()) {
|
||||
params.setVideoStabilization(true);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> focusMode = params.getSupportedFocusModes();
|
||||
if (focusMode.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
|
||||
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
|
||||
}
|
||||
|
||||
if (params != null) {
|
||||
mAngle = setCameraDisplayOrientation(this, cameraId, camera);
|
||||
Log.i(TAG, "camera angle = " + mAngle);
|
||||
}
|
||||
|
||||
params.setPreviewSize(currentUsePoint.x, currentUsePoint.y);
|
||||
|
||||
try {
|
||||
camera.setParameters(params);
|
||||
} catch (RuntimeException e) {
|
||||
LogUtil.e(TAG, "setParameters failed", e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void shutdownCamera() {
|
||||
if (camera != null) {
|
||||
if (previewing) {
|
||||
camera.stopPreview();
|
||||
}
|
||||
camera.release();
|
||||
camera = null;
|
||||
previewing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* **************************** SurfaceHolder.Callback Start *******************************
|
||||
*/
|
||||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
surfaceHolder = holder;
|
||||
}
|
||||
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
surfaceHolder = holder;
|
||||
|
||||
shutdownCamera();
|
||||
if (!initCamera())
|
||||
return;
|
||||
startPreview();
|
||||
}
|
||||
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
surfaceHolder = null;
|
||||
mediaRecorder = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ************************ SurfaceHolder.Callback Start ********************************
|
||||
*/
|
||||
|
||||
private void startPreview() {
|
||||
try {
|
||||
camera.setPreviewDisplay(surfaceHolder);
|
||||
camera.startPreview();
|
||||
previewing = true;
|
||||
} catch (Exception e) {
|
||||
// Toast.makeText(this, R.string.connect_vedio_device_fail, Toast.LENGTH_SHORT).show();
|
||||
SingleToastUtil.showToastShort(R.string.connect_vedio_device_fail);
|
||||
shutdownCamera();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ********************************* camera util ************************************
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public int setCameraDisplayOrientation(Context context, int cameraId, Camera camera) {
|
||||
int orientation = 90;
|
||||
boolean front = (cameraId == 1);
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
Camera.CameraInfo info = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(cameraId, info);
|
||||
orientation = info.orientation;
|
||||
front = (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT);
|
||||
}
|
||||
|
||||
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
int activityOrientation = roundRotation(rotation);
|
||||
int result;
|
||||
if (front) {
|
||||
result = (orientation + activityOrientation) % 360;
|
||||
result = (360 - result) % 360; // compensate the mirror
|
||||
} else { // back-facing
|
||||
result = (orientation - activityOrientation + 360) % 360;
|
||||
//遇到过一个小米1s后置摄像头旋转180°,但是不确定是不是所有小米1s都是这样的. 先做一个适配,以后有问题再说.
|
||||
if ("Xiaomi_MI-ONE Plus".equalsIgnoreCase(Build.MANUFACTURER + "_" + Build.MODEL)) {
|
||||
result = 90;
|
||||
}
|
||||
}
|
||||
camera.setDisplayOrientation(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int roundRotation(int rotation) {
|
||||
switch (rotation) {
|
||||
case Surface.ROTATION_0:
|
||||
return 0;
|
||||
case Surface.ROTATION_90:
|
||||
return 90;
|
||||
case Surface.ROTATION_180:
|
||||
return 180;
|
||||
case Surface.ROTATION_270:
|
||||
return 270;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@@ -15,12 +15,15 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.chwl.library.common.util.AlbumUtils;
|
||||
import com.chwl.library.common.util.ExecutorCenter;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.api.wrapper.NimToolBarOptions;
|
||||
import com.netease.nim.uikit.common.activity.ToolBarOptions;
|
||||
@@ -42,11 +45,6 @@ import com.netease.nimlib.sdk.msg.constant.AttachStatusEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.chwl.library.common.util.AlbumUtils;
|
||||
import com.chwl.library.common.util.ExecutorCenter;
|
||||
import com.chwl.library.easyphoto.utils.permission.PermissionUtil;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -528,21 +526,21 @@ public class WatchMessagePictureActivity extends UI {
|
||||
|
||||
// 图片长按
|
||||
protected void showWatchPictureAction() {
|
||||
if (alertDialog.isShowing()) {
|
||||
alertDialog.dismiss();
|
||||
return;
|
||||
}
|
||||
alertDialog.clearData();
|
||||
String title;
|
||||
if (!TextUtils.isEmpty(((ImageAttachment) message.getAttachment()).getPath())) {
|
||||
title = getString(R.string.save_to_device);
|
||||
alertDialog.addItem(title, () -> {
|
||||
if (PermissionUtil.checkAndRequestPermissionsInActivity(WatchMessagePictureActivity.this, getNeedPermissions())) {
|
||||
savePicture();
|
||||
}
|
||||
});
|
||||
}
|
||||
alertDialog.show();
|
||||
// if (alertDialog.isShowing()) {
|
||||
// alertDialog.dismiss();
|
||||
// return;
|
||||
// }
|
||||
// alertDialog.clearData();
|
||||
// String title;
|
||||
// if (!TextUtils.isEmpty(((ImageAttachment) message.getAttachment()).getPath())) {
|
||||
// title = getString(R.string.save_to_device);
|
||||
// alertDialog.addItem(title, () -> {
|
||||
// if (PermissionUtil.checkAndRequestPermissionsInActivity(WatchMessagePictureActivity.this, getNeedPermissions())) {
|
||||
// savePicture();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// alertDialog.show();
|
||||
}
|
||||
|
||||
// 保存图片
|
||||
@@ -567,28 +565,6 @@ public class WatchMessagePictureActivity extends UI {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
PermissionUtil.onPermissionResult(this, permissions, grantResults,
|
||||
new PermissionUtil.PermissionCallBack() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
savePicture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShouldShow() {
|
||||
SingleToastUtil.showToastShort(R.string.give_application_storage_permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed() {
|
||||
SingleToastUtil.showToastShort(R.string.give_application_storage_permission);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected String[] getNeedPermissions() {
|
||||
return new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
@@ -8,8 +8,9 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.business.session.activity.CaptureVideoActivity;
|
||||
import com.netease.nim.uikit.common.ui.dialog.CustomAlertDialog;
|
||||
import com.netease.nim.uikit.common.util.C;
|
||||
import com.netease.nim.uikit.common.util.file.AttachmentStore;
|
||||
@@ -18,8 +19,6 @@ import com.netease.nim.uikit.common.util.storage.StorageType;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageUtil;
|
||||
import com.netease.nim.uikit.common.util.string.MD5;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -53,12 +52,12 @@ public class VideoMessageHelper {
|
||||
this.captureRequestCode = capture;
|
||||
CustomAlertDialog dialog = new CustomAlertDialog(activity);
|
||||
dialog.setTitle(activity.getString(R.string.input_panel_video));
|
||||
dialog.addItem(ResUtil.getString(R.string.session_helper_videomessagehelper_01), new CustomAlertDialog.onSeparateItemClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
chooseVideoFromCamera();
|
||||
}
|
||||
});
|
||||
// dialog.addItem(ResUtil.getString(R.string.session_helper_videomessagehelper_01), new CustomAlertDialog.onSeparateItemClickListener() {
|
||||
// @Override
|
||||
// public void onClick() {
|
||||
// chooseVideoFromCamera();
|
||||
// }
|
||||
// });
|
||||
dialog.addItem(ResUtil.getString(R.string.session_helper_videomessagehelper_02), new CustomAlertDialog.onSeparateItemClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
@@ -73,19 +72,19 @@ public class VideoMessageHelper {
|
||||
/**
|
||||
* 拍摄视频
|
||||
*/
|
||||
protected void chooseVideoFromCamera() {
|
||||
if (!StorageUtil.hasEnoughSpaceForWrite(activity,
|
||||
StorageType.TYPE_VIDEO, true)) {
|
||||
return;
|
||||
}
|
||||
videoFilePath = StorageUtil.getWritePath(
|
||||
activity, StringUtil.get36UUID()
|
||||
+ C.FileSuffix.MP4, StorageType.TYPE_TEMP);
|
||||
videoFile = new File(videoFilePath);
|
||||
|
||||
// 启动视频录制
|
||||
CaptureVideoActivity.start(activity, videoFilePath, captureRequestCode);
|
||||
}
|
||||
// protected void chooseVideoFromCamera() {
|
||||
// if (!StorageUtil.hasEnoughSpaceForWrite(activity,
|
||||
// StorageType.TYPE_VIDEO, true)) {
|
||||
// return;
|
||||
// }
|
||||
// videoFilePath = StorageUtil.getWritePath(
|
||||
// activity, StringUtil.get36UUID()
|
||||
// + C.FileSuffix.MP4, StorageType.TYPE_TEMP);
|
||||
// videoFile = new File(videoFilePath);
|
||||
//
|
||||
// // 启动视频录制
|
||||
// CaptureVideoActivity.start(activity, videoFilePath, captureRequestCode);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 从本地相册中选择视频
|
||||
|
@@ -12,6 +12,8 @@ import android.view.View;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.api.model.SimpleCallback;
|
||||
@@ -21,7 +23,6 @@ import com.netease.nim.uikit.api.model.user.UserInfoObserver;
|
||||
import com.netease.nim.uikit.api.wrapper.NimToolBarOptions;
|
||||
import com.netease.nim.uikit.business.contact.core.item.ContactIdFilter;
|
||||
import com.netease.nim.uikit.business.contact.selector.activity.ContactSelectActivity;
|
||||
import com.netease.nim.uikit.business.session.actions.PickImageAction;
|
||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||
import com.netease.nim.uikit.business.team.adapter.TeamMemberAdapter;
|
||||
import com.netease.nim.uikit.business.team.adapter.TeamMemberAdapter.TeamMemberItem;
|
||||
@@ -34,7 +35,6 @@ import com.netease.nim.uikit.common.activity.ToolBarOptions;
|
||||
import com.netease.nim.uikit.common.activity.UI;
|
||||
import com.netease.nim.uikit.common.adapter.TAdapterDelegate;
|
||||
import com.netease.nim.uikit.common.adapter.TViewHolder;
|
||||
import com.netease.nim.uikit.common.media.picker.PickImageHelper;
|
||||
import com.netease.nim.uikit.common.ui.dialog.DialogMaker;
|
||||
import com.netease.nim.uikit.common.ui.dialog.MenuDialog;
|
||||
import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
|
||||
@@ -56,8 +56,6 @@ import com.netease.nimlib.sdk.team.constant.TeamUpdateModeEnum;
|
||||
import com.netease.nimlib.sdk.team.constant.VerifyTypeEnum;
|
||||
import com.netease.nimlib.sdk.team.model.Team;
|
||||
import com.netease.nimlib.sdk.team.model.TeamMember;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -353,14 +351,14 @@ public class AdvancedTeamInfoActivity extends UI implements
|
||||
* 打开图片选择器
|
||||
*/
|
||||
private void showSelector(int titleId, final int requestCode) {
|
||||
PickImageHelper.PickImageOption option = new PickImageHelper.PickImageOption();
|
||||
option.titleResId = titleId;
|
||||
option.multiSelect = false;
|
||||
option.crop = true;
|
||||
option.cropOutputImageWidth = 720;
|
||||
option.cropOutputImageHeight = 720;
|
||||
|
||||
PickImageHelper.pickImage(AdvancedTeamInfoActivity.this, requestCode, option);
|
||||
// PickImageHelper.PickImageOption option = new PickImageHelper.PickImageOption();
|
||||
// option.titleResId = titleId;
|
||||
// option.multiSelect = false;
|
||||
// option.crop = true;
|
||||
// option.cropOutputImageWidth = 720;
|
||||
// option.cropOutputImageHeight = 720;
|
||||
//
|
||||
// PickImageHelper.pickImage(AdvancedTeamInfoActivity.this, requestCode, option);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1440,7 +1438,7 @@ public class AdvancedTeamInfoActivity extends UI implements
|
||||
|
||||
LogUtil.i(TAG, "start upload icon, local file path=" + file.getAbsolutePath());
|
||||
new Handler().postDelayed(outimeTask, ICON_TIME_OUT);
|
||||
uploadFuture = NIMClient.getService(NosService.class).upload(file, PickImageAction.MIME_JPEG);
|
||||
uploadFuture = NIMClient.getService(NosService.class).upload(file, "image/jpeg");
|
||||
uploadFuture.setCallback(new RequestCallbackWrapper<String>() {
|
||||
@Override
|
||||
public void onResult(int code, String url, Throwable exception) {
|
||||
|
@@ -1,107 +0,0 @@
|
||||
package com.netease.nim.uikit.common.media.picker;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.business.session.module.input.NimImageActionEvent;
|
||||
import com.netease.nim.uikit.common.media.picker.activity.PickImageActivity;
|
||||
import com.netease.nim.uikit.common.ui.dialog.CustomAlertDialog;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageType;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageUtil;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* Created by huangjun on 2015/9/22.
|
||||
*/
|
||||
public class PickImageHelper {
|
||||
|
||||
public static class PickImageOption {
|
||||
/**
|
||||
* 图片选择器标题
|
||||
*/
|
||||
public int titleResId = R.string.choose;
|
||||
|
||||
/**
|
||||
* 是否多选
|
||||
*/
|
||||
public boolean multiSelect = true;
|
||||
|
||||
/**
|
||||
* 最多选多少张图(多选时有效)
|
||||
*/
|
||||
public int multiSelectMaxCount = 9;
|
||||
|
||||
/**
|
||||
* 是否进行图片裁剪(图片选择模式:false / 图片裁剪模式:true)
|
||||
*/
|
||||
public boolean crop = false;
|
||||
|
||||
/**
|
||||
* 图片裁剪的宽度(裁剪模式时有效)
|
||||
*/
|
||||
public int cropOutputImageWidth = 720;
|
||||
|
||||
/**
|
||||
* 图片裁剪的高度(裁剪模式时有效)
|
||||
*/
|
||||
public int cropOutputImageHeight = 720;
|
||||
|
||||
/**
|
||||
* 图片选择保存路径
|
||||
*/
|
||||
public String outputPath = StorageUtil.getWritePath(StringUtil.get32UUID() + ".jpg", StorageType.TYPE_TEMP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开图片选择器
|
||||
*/
|
||||
public static void pickImage(final Context context, final int requestCode, final PickImageOption option) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomAlertDialog dialog = new CustomAlertDialog(context);
|
||||
dialog.setTitle(option.titleResId);
|
||||
|
||||
// dialog.addItem(context.getString(R.string.input_panel_take), new CustomAlertDialog.onSeparateItemClickListener() {
|
||||
// @Override
|
||||
// public void onClick() {
|
||||
// NimImageActionEvent event = new NimImageActionEvent();
|
||||
// event.setSuccess(o -> {
|
||||
// int from = PickImageActivity.FROM_CAMERA;
|
||||
// if (!option.crop) {
|
||||
// PickImageActivity.start((Activity) context, requestCode, from, option.outputPath, option.multiSelect, 1,
|
||||
// true, false, 0, 0);
|
||||
// } else {
|
||||
// PickImageActivity.start((Activity) context, requestCode, from, option.outputPath, false, 1,
|
||||
// false, true, option.cropOutputImageWidth, option.cropOutputImageHeight);
|
||||
// }
|
||||
// });
|
||||
// EventBus.getDefault().post(event);
|
||||
// }
|
||||
// });
|
||||
|
||||
dialog.addItem(context.getString(R.string.choose_from_photo_album), new CustomAlertDialog.onSeparateItemClickListener() {
|
||||
@Override
|
||||
public void onClick() {
|
||||
NimImageActionEvent event = new NimImageActionEvent();
|
||||
event.setSuccess(o -> {
|
||||
int from = PickImageActivity.FROM_LOCAL;
|
||||
if (!option.crop) {
|
||||
PickImageActivity.start((Activity) context, requestCode, from, option.outputPath, option.multiSelect,
|
||||
option.multiSelectMaxCount, true, false, 0, 0);
|
||||
} else {
|
||||
PickImageActivity.start((Activity) context, requestCode, from, option.outputPath, false, 1,
|
||||
false, true, option.cropOutputImageWidth, option.cropOutputImageHeight);
|
||||
}
|
||||
});
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
}
|
@@ -1,305 +0,0 @@
|
||||
package com.netease.nim.uikit.common.media.picker.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.MediaStore.Images;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.api.wrapper.NimToolBarOptions;
|
||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||
import com.netease.nim.uikit.common.activity.ToolBarOptions;
|
||||
import com.netease.nim.uikit.common.activity.UI;
|
||||
import com.netease.nim.uikit.common.media.picker.model.GenericFileProvider;
|
||||
import com.netease.nim.uikit.common.media.picker.model.PhotoInfo;
|
||||
import com.netease.nim.uikit.common.media.picker.model.PickerContract;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class PickImageActivity extends UI {
|
||||
|
||||
private static final String KEY_STATE = "state";
|
||||
|
||||
public static final int FROM_LOCAL = 1;
|
||||
|
||||
public static final int FROM_CAMERA = 2;
|
||||
|
||||
private static final int REQUEST_CODE_CROP = 3;
|
||||
|
||||
private static final int REQUEST_CODE_LOCAL = FROM_LOCAL;
|
||||
|
||||
private static final int REQUEST_CODE_CAMERA = FROM_CAMERA;
|
||||
|
||||
private boolean inited = false;
|
||||
|
||||
public static void start(Activity activity, int requestCode, int from, String outPath) {
|
||||
Intent intent = new Intent(activity, PickImageActivity.class);
|
||||
intent.putExtra(Extras.EXTRA_FROM, from);
|
||||
intent.putExtra(Extras.EXTRA_FILE_PATH, outPath);
|
||||
activity.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
public static void start(Activity activity, int requestCode, int from,
|
||||
String outPath, boolean mutiSelectMode, int multiSelectLimitSize,
|
||||
boolean isSupportOrig, boolean crop, int outputX, int outputY) {
|
||||
Intent intent = new Intent(activity, PickImageActivity.class);
|
||||
intent.putExtra(Extras.EXTRA_FROM, from);
|
||||
intent.putExtra(Extras.EXTRA_FILE_PATH, outPath);
|
||||
intent.putExtra(Extras.EXTRA_MUTI_SELECT_MODE, mutiSelectMode);
|
||||
intent.putExtra(Extras.EXTRA_MUTI_SELECT_SIZE_LIMIT, multiSelectLimitSize);
|
||||
intent.putExtra(Extras.EXTRA_SUPPORT_ORIGINAL, isSupportOrig);
|
||||
intent.putExtra(Extras.EXTRA_NEED_CROP, crop);
|
||||
intent.putExtra(Extras.EXTRA_OUTPUTX, outputX);
|
||||
intent.putExtra(Extras.EXTRA_OUTPUTY, outputY);
|
||||
activity.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.nim_pick_image_activity);
|
||||
ToolBarOptions options = new NimToolBarOptions();
|
||||
setToolBar(R.id.toolbar, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (!inited) {
|
||||
processIntent();
|
||||
inited = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(KEY_STATE, inited);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
inited = savedInstanceState.getBoolean(KEY_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
private void processIntent() {
|
||||
int from = getIntent().getIntExtra(Extras.EXTRA_FROM, FROM_LOCAL);
|
||||
if (from == FROM_LOCAL) {
|
||||
pickFromLocal();
|
||||
} else {
|
||||
pickFromCamera();
|
||||
}
|
||||
}
|
||||
|
||||
private void pickFromLocal() {
|
||||
Intent intent = pickIntent();
|
||||
if (intent == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
startActivityForResult(intent, REQUEST_CODE_LOCAL);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
// Toast.makeText(this, R.string.gallery_invalid, Toast.LENGTH_LONG)
|
||||
// .show();
|
||||
SingleToastUtil.showToastShort(R.string.gallery_invalid);
|
||||
finish();
|
||||
} catch (Exception e) {
|
||||
// Toast.makeText(this, R.string.sdcard_not_enough_head_error,
|
||||
// Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.sdcard_not_enough_head_error);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void pickFromCamera() {
|
||||
try {
|
||||
String outPath = getIntent().getStringExtra(Extras.EXTRA_FILE_PATH);
|
||||
if (TextUtils.isEmpty(outPath)) {
|
||||
// Toast.makeText(this, R.string.sdcard_not_enough_error, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.sdcard_not_enough_error);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
File outputFile = new File(outPath);
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
if (Build.VERSION.SDK_INT > 23) {
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, GenericFileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".generic.file.provider", outputFile));
|
||||
} else {
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outputFile));
|
||||
}
|
||||
startActivityForResult(intent, REQUEST_CODE_CAMERA);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
finish();
|
||||
} catch (Exception e) {
|
||||
// Toast.makeText(this, R.string.sdcard_not_enough_head_error, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.sdcard_not_enough_head_error);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private Intent pickIntent() {
|
||||
Intent intent = getIntent();
|
||||
boolean mutiSelect = intent.getBooleanExtra(Extras.EXTRA_MUTI_SELECT_MODE, false);
|
||||
int mutiSelectLimitSize = intent.getIntExtra(Extras.EXTRA_MUTI_SELECT_SIZE_LIMIT, 9);
|
||||
boolean isSupportOrg = intent.getBooleanExtra(Extras.EXTRA_SUPPORT_ORIGINAL, false);
|
||||
return makeLaunchIntent(this, mutiSelect, mutiSelectLimitSize, isSupportOrg);
|
||||
}
|
||||
|
||||
private Intent makeLaunchIntent(Context context, boolean mutiSelectMode,
|
||||
int mutiSelectLimitSize, boolean isSupportOrig) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(context, PickerAlbumActivity.class);
|
||||
intent.putExtra(Extras.EXTRA_MUTI_SELECT_MODE, mutiSelectMode);
|
||||
intent.putExtra(Extras.EXTRA_MUTI_SELECT_SIZE_LIMIT,
|
||||
mutiSelectLimitSize);
|
||||
intent.putExtra(Extras.EXTRA_SUPPORT_ORIGINAL, isSupportOrig);
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
private String pathFromResult(Intent data) {
|
||||
String outPath = getIntent().getStringExtra(Extras.EXTRA_FILE_PATH);
|
||||
if (data == null || data.getData() == null) {
|
||||
return outPath;
|
||||
}
|
||||
|
||||
Uri uri = data.getData();
|
||||
Cursor cursor = getContentResolver()
|
||||
.query(uri, new String[]{MediaStore.Images.Media.DATA}, null, null, null);
|
||||
if (cursor == null) {
|
||||
// miui 2.3 有可能为null
|
||||
return uri.getPath();
|
||||
} else {
|
||||
if (uri.toString().contains("content://com.android.providers.media.documents/document/image")) { // htc 某些手机
|
||||
// 获取图片地址
|
||||
String _id = null;
|
||||
String uridecode = uri.decode(uri.toString());
|
||||
int id_index = uridecode.lastIndexOf(":");
|
||||
_id = uridecode.substring(id_index + 1);
|
||||
Cursor mcursor = getContentResolver().query(Images.Media.EXTERNAL_CONTENT_URI, null, " _id = " + _id,
|
||||
null, null);
|
||||
mcursor.moveToFirst();
|
||||
int column_index = mcursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
outPath = mcursor.getString(column_index);
|
||||
if (!mcursor.isClosed()) {
|
||||
mcursor.close();
|
||||
}
|
||||
if (!cursor.isClosed()) {
|
||||
cursor.close();
|
||||
}
|
||||
return outPath;
|
||||
|
||||
} else {
|
||||
cursor.moveToFirst();
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
outPath = cursor.getString(column_index);
|
||||
if (!cursor.isClosed()) {
|
||||
cursor.close();
|
||||
}
|
||||
return outPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onPickedLocal(Intent data, int code) {
|
||||
boolean mutiSelect = getIntent().getBooleanExtra(Extras.EXTRA_MUTI_SELECT_MODE, false);
|
||||
try {
|
||||
List<PhotoInfo> photos = PickerContract.getPhotos(data);
|
||||
if (photos != null && photos.size() >= 1) {
|
||||
PhotoInfo select = photos.get(0);
|
||||
String photoPath = select.getAbsolutePath();
|
||||
boolean crop = getIntent().getBooleanExtra(Extras.EXTRA_NEED_CROP, false);
|
||||
if (crop) {
|
||||
crop(photoPath);
|
||||
} else {
|
||||
if (data != null) {
|
||||
Intent result = new Intent(data);
|
||||
result.putExtra(Extras.EXTRA_FROM_LOCAL, true);
|
||||
setResult(RESULT_OK, result);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.picker_image_error);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void onPickedCamera(Intent data, int code) {
|
||||
try {
|
||||
String photoPath = pathFromResult(data);
|
||||
boolean crop = getIntent().getBooleanExtra(Extras.EXTRA_NEED_CROP, false);
|
||||
if (crop) {
|
||||
crop(photoPath);
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(photoPath)) {
|
||||
Intent result = new Intent();
|
||||
result.putExtra(Extras.EXTRA_FROM_LOCAL, code == REQUEST_CODE_LOCAL);
|
||||
result.putExtra(Extras.EXTRA_FILE_PATH, photoPath);
|
||||
setResult(RESULT_OK, result);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.picker_image_error);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void crop(String src) {
|
||||
Intent intent = getIntent();
|
||||
int outputX = intent.getIntExtra(Extras.EXTRA_OUTPUTX, 0);
|
||||
int outputY = intent.getIntExtra(Extras.EXTRA_OUTPUTY, 0);
|
||||
String outPath = intent.getStringExtra(Extras.EXTRA_FILE_PATH);
|
||||
CropImageActivity.startForFile(this, src, outputX, outputY, outPath, REQUEST_CODE_CROP);
|
||||
}
|
||||
|
||||
private void onCropped() {
|
||||
String outPath = getIntent().getStringExtra(Extras.EXTRA_FILE_PATH);
|
||||
Intent result = new Intent();
|
||||
result.putExtra(Extras.EXTRA_FILE_PATH, outPath);
|
||||
setResult(RESULT_OK, result);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode != RESULT_OK) {
|
||||
setResult(resultCode);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (requestCode) {
|
||||
case REQUEST_CODE_LOCAL:
|
||||
onPickedLocal(data, requestCode);
|
||||
break;
|
||||
case REQUEST_CODE_CAMERA:
|
||||
onPickedCamera(data, requestCode);
|
||||
break;
|
||||
case REQUEST_CODE_CROP:
|
||||
onCropped();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,317 +0,0 @@
|
||||
package com.netease.nim.uikit.common.media.picker.activity;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.api.wrapper.NimToolBarOptions;
|
||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||
import com.netease.nim.uikit.business.session.constant.RequestCode;
|
||||
import com.netease.nim.uikit.common.activity.ToolBarOptions;
|
||||
import com.netease.nim.uikit.common.activity.UI;
|
||||
import com.netease.nim.uikit.common.media.picker.event.NotifyUpdatePhotoListEvent;
|
||||
import com.netease.nim.uikit.common.media.picker.fragment.PickerAlbumFragment;
|
||||
import com.netease.nim.uikit.common.media.picker.fragment.PickerAlbumFragment.OnAlbumItemClickListener;
|
||||
import com.netease.nim.uikit.common.media.picker.fragment.PickerImageFragment;
|
||||
import com.netease.nim.uikit.common.media.picker.loader.PickerImageLoader;
|
||||
import com.netease.nim.uikit.common.media.picker.model.AlbumInfo;
|
||||
import com.netease.nim.uikit.common.media.picker.model.PhotoInfo;
|
||||
import com.netease.nim.uikit.common.media.picker.model.PickerContract;
|
||||
import com.netease.nim.uikit.common.media.picker.util.PhotoListCache;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Inner image picker, no longer use third-part application
|
||||
*/
|
||||
public class PickerAlbumActivity extends UI implements OnAlbumItemClickListener,
|
||||
PickerImageFragment.OnPhotoSelectClickListener, OnClickListener {
|
||||
|
||||
private FrameLayout pickerAlbumLayout;
|
||||
|
||||
private FrameLayout pickerPhotosLayout;
|
||||
|
||||
private PickerAlbumFragment photoFolderFragment;
|
||||
|
||||
private PickerImageFragment photoFragment;
|
||||
|
||||
private RelativeLayout pickerBottomBar;
|
||||
|
||||
private TextView pickerPreview;
|
||||
|
||||
private TextView pickerSend;
|
||||
|
||||
private List<PhotoInfo> hasSelectList = new ArrayList<PhotoInfo>();
|
||||
|
||||
private boolean isMutiMode;
|
||||
|
||||
private boolean isSupportOriginal;
|
||||
|
||||
private boolean isSendOriginalImage;
|
||||
|
||||
private int mutiSelectLimitSize;
|
||||
|
||||
private boolean isAlbumPage;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.nim_picker_album_activity);
|
||||
|
||||
PhotoListCache.get().onCreate();
|
||||
|
||||
ToolBarOptions options = new NimToolBarOptions();
|
||||
setToolBar(R.id.toolbar, options);
|
||||
|
||||
proceedExtra();
|
||||
initActionBar();
|
||||
initUI();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
private void proceedExtra() {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
isMutiMode = intent.getBooleanExtra(Extras.EXTRA_MUTI_SELECT_MODE, false);
|
||||
mutiSelectLimitSize = intent.getIntExtra(Extras.EXTRA_MUTI_SELECT_SIZE_LIMIT, 9);
|
||||
isSupportOriginal = intent.getBooleanExtra(Extras.EXTRA_SUPPORT_ORIGINAL, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void initActionBar() {
|
||||
setTitle(R.string.picker_image_folder);
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
// bottom bar
|
||||
pickerBottomBar = (RelativeLayout) findViewById(R.id.picker_bottombar);
|
||||
if (isMutiMode) {
|
||||
pickerBottomBar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
pickerBottomBar.setVisibility(View.GONE);
|
||||
}
|
||||
pickerPreview = (TextView) findViewById(R.id.picker_bottombar_preview);
|
||||
pickerPreview.setOnClickListener(this);
|
||||
pickerSend = (TextView) findViewById(R.id.picker_bottombar_select);
|
||||
pickerSend.setOnClickListener(this);
|
||||
|
||||
// fragment
|
||||
pickerAlbumLayout = (FrameLayout) findViewById(R.id.picker_album_fragment);
|
||||
pickerPhotosLayout = (FrameLayout) findViewById(R.id.picker_photos_fragment);
|
||||
photoFolderFragment = new PickerAlbumFragment();
|
||||
switchContent(photoFolderFragment);
|
||||
|
||||
isAlbumPage = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnAlbumItemClick(AlbumInfo info) {
|
||||
// check photo list if has already be choose
|
||||
List<PhotoInfo> photoList = info.getList();
|
||||
if (photoList == null) {
|
||||
return;
|
||||
}
|
||||
for (PhotoInfo photo : photoList) {
|
||||
if (checkSelectPhoto(photo)) {
|
||||
photo.setChoose(true);
|
||||
} else {
|
||||
photo.setChoose(false);
|
||||
}
|
||||
}
|
||||
|
||||
//保存图片列表信息,用于PickerImageFragment的读取
|
||||
PhotoListCache.get().setList(photoList);
|
||||
// switch to photo fragment
|
||||
pickerAlbumLayout.setVisibility(View.GONE);
|
||||
pickerPhotosLayout.setVisibility(View.VISIBLE);
|
||||
if (photoFragment == null) {
|
||||
photoFragment = new PickerImageFragment();
|
||||
photoFragment.setArguments(makeDataBundle(photoList, isMutiMode, mutiSelectLimitSize));
|
||||
switchContent(photoFragment);
|
||||
} else {
|
||||
int hasSelectSize = hasSelectList.size();
|
||||
photoFragment.resetFragment(photoList, hasSelectSize);
|
||||
}
|
||||
// update title
|
||||
setTitle(info.getAlbumName());
|
||||
isAlbumPage = false;
|
||||
}
|
||||
|
||||
public Bundle makeDataBundle(List<PhotoInfo> photos, boolean mutiMode, int mutiSelectLimitSize) {
|
||||
Bundle bundle = new Bundle();
|
||||
//当用户图片非常多的时候,这个数据量大,不放在此处传递
|
||||
//bundle.putSerializable(Extras.EXTRA_PHOTO_LISTS, new ArrayList<PhotoInfo>(photos));
|
||||
bundle.putBoolean(Extras.EXTRA_MUTI_SELECT_MODE, mutiMode);
|
||||
bundle.putInt(Extras.EXTRA_MUTI_SELECT_SIZE_LIMIT, mutiSelectLimitSize);
|
||||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPhotoSingleClick(List<PhotoInfo> photos, int position) {
|
||||
if (isMutiMode) {
|
||||
PickerAlbumPreviewActivity.start(this, photos, position, isSupportOriginal,
|
||||
isSendOriginalImage, hasSelectList, mutiSelectLimitSize);
|
||||
} else {
|
||||
if (photos != null) {
|
||||
PhotoInfo photo = photos.get(position);
|
||||
List<PhotoInfo> selectList = new ArrayList<PhotoInfo>();
|
||||
selectList.add(photo);
|
||||
|
||||
setResult(RESULT_OK, PickerContract.makeDataIntent(selectList, false));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPhotoSelectClick(PhotoInfo selectPhoto) {
|
||||
if (selectPhoto == null)
|
||||
return;
|
||||
// check
|
||||
boolean isChoose = selectPhoto.isChoose();
|
||||
if (isChoose) {
|
||||
boolean isSelect = checkSelectPhoto(selectPhoto);
|
||||
if (!isSelect) {
|
||||
addSelectPhoto(selectPhoto);
|
||||
}
|
||||
} else {
|
||||
removeSelectPhoto(selectPhoto);
|
||||
}
|
||||
// update bottom bar
|
||||
updateSelectBtnStatus();
|
||||
}
|
||||
|
||||
private boolean checkSelectPhoto(PhotoInfo photo) {
|
||||
boolean isSelect = false;
|
||||
for (int i = 0; i < hasSelectList.size(); i++) {
|
||||
PhotoInfo select = hasSelectList.get(i);
|
||||
if (select.getImageId() == photo.getImageId()) {
|
||||
isSelect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
private void removeSelectPhoto(PhotoInfo photo) {
|
||||
Iterator<PhotoInfo> lIterator = hasSelectList.iterator();
|
||||
while (lIterator.hasNext()) {
|
||||
PhotoInfo select = lIterator.next();
|
||||
if (select.getImageId() == photo.getImageId()) {
|
||||
lIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addSelectPhoto(PhotoInfo photo) {
|
||||
hasSelectList.add(photo);
|
||||
}
|
||||
|
||||
private void resetSelectPhotos(List<PhotoInfo> photos) {
|
||||
if (hasSelectList != null) {
|
||||
hasSelectList.clear();
|
||||
} else {
|
||||
hasSelectList = new ArrayList<PhotoInfo>();
|
||||
}
|
||||
hasSelectList.addAll(photos);
|
||||
}
|
||||
|
||||
private void updateSelectBtnStatus() {
|
||||
int selectSize = hasSelectList.size();
|
||||
if (selectSize > 0) {
|
||||
pickerPreview.setEnabled(true);
|
||||
pickerSend.setEnabled(true);
|
||||
pickerSend.setText(String.format(this.getResources().getString(
|
||||
R.string.picker_image_send_select), selectSize));
|
||||
} else {
|
||||
pickerPreview.setEnabled(false);
|
||||
pickerSend.setEnabled(false);
|
||||
pickerSend.setText(R.string.picker_image_send);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.picker_bottombar_preview) {
|
||||
PickerAlbumPreviewActivity.start(this, hasSelectList, 0, isSupportOriginal,
|
||||
isSendOriginalImage, hasSelectList, mutiSelectLimitSize);
|
||||
} else if (v.getId() == R.id.picker_bottombar_select) {
|
||||
setResult(RESULT_OK, PickerContract.makeDataIntent(hasSelectList, isSendOriginalImage));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isAlbumPage) {
|
||||
finish();
|
||||
} else {
|
||||
backToAlbumPage();
|
||||
}
|
||||
}
|
||||
|
||||
private void backToAlbumPage() {
|
||||
setTitle(R.string.picker_image_folder);
|
||||
isAlbumPage = true;
|
||||
pickerAlbumLayout.setVisibility(View.VISIBLE);
|
||||
pickerPhotosLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == RequestCode.PICKER_IMAGE_PREVIEW) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
setResult(RESULT_OK, new Intent(data));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onNotifyUpdatePhotoListEvent(NotifyUpdatePhotoListEvent event) {
|
||||
// update photo fragment
|
||||
isSendOriginalImage = event.isSendOriginalImage;
|
||||
List<PhotoInfo> list = event.photoLists;
|
||||
if (photoFragment != null && list != null) {
|
||||
photoFragment.updateGridview(list);
|
||||
}
|
||||
// update select photo list
|
||||
List<PhotoInfo> selectList = event.selectPhotoList;
|
||||
resetSelectPhotos(selectList);
|
||||
updateSelectBtnStatus();
|
||||
if (photoFragment != null && hasSelectList != null) {
|
||||
photoFragment.updateSelectedForAdapter(hasSelectList.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
PickerImageLoader.initCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
PhotoListCache.get().onDestroy();
|
||||
|
||||
PickerImageLoader.clearCache();
|
||||
}
|
||||
}
|
@@ -1,216 +0,0 @@
|
||||
package com.netease.nim.uikit.common.media.picker.activity;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.api.wrapper.NimToolBarOptions;
|
||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||
import com.netease.nim.uikit.business.session.constant.RequestCode;
|
||||
import com.netease.nim.uikit.common.activity.ToolBarOptions;
|
||||
import com.netease.nim.uikit.common.activity.UI;
|
||||
import com.netease.nim.uikit.common.util.file.AttachmentStore;
|
||||
import com.netease.nim.uikit.common.util.media.BitmapDecoder;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageType;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PreviewImageFromCameraActivity extends UI {
|
||||
|
||||
public static final String RESULT_RETAKE = "RESULT_RETAKE";
|
||||
public static final String RESULT_SEND = "RESULT_SEND";
|
||||
|
||||
private ImageView previewImageView;
|
||||
|
||||
private File imageFile;
|
||||
|
||||
private Button sendButton;
|
||||
|
||||
private String origImageFilePath;
|
||||
|
||||
private String btnText;
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.nim_preview_image_from_camera_activity);
|
||||
|
||||
ToolBarOptions options = new NimToolBarOptions();
|
||||
setToolBar(R.id.toolbar, options);
|
||||
|
||||
initActionBar();
|
||||
getIntentData();
|
||||
findViews();
|
||||
initSendBtn();
|
||||
showPicture();
|
||||
}
|
||||
|
||||
private void findViews() {
|
||||
sendButton = (Button) findViewById(R.id.buttonSend);
|
||||
previewImageView = (ImageView) findViewById(R.id.imageViewPreview);
|
||||
}
|
||||
|
||||
private void getIntentData() {
|
||||
String imageFilePathString = getIntent().getExtras().getString("ImageFilePath");
|
||||
origImageFilePath = getIntent().getExtras().getString("OrigImageFilePath");
|
||||
btnText = getIntent().getExtras().getString(Extras.EXTRA_PREVIEW_IMAGE_BTN_TEXT);
|
||||
imageFile = new File(imageFilePathString);
|
||||
}
|
||||
|
||||
private void initSendBtn() {
|
||||
if (!TextUtils.isEmpty(btnText)) {
|
||||
sendButton.setText(btnText);
|
||||
}
|
||||
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ArrayList<String> imageList = new ArrayList<String>();
|
||||
ArrayList<String> origImageList = new ArrayList<String>();
|
||||
imageList.add(imageFile.getPath());
|
||||
origImageList.add(origImageFilePath);
|
||||
|
||||
boolean isOrig = false;
|
||||
if (!isOrig) {
|
||||
// 拍照不是原图发送的话,原图需要手动删掉
|
||||
AttachmentStore.delete(origImageFilePath);
|
||||
}
|
||||
|
||||
Intent intent = PreviewImageFromLocalActivity.initPreviewImageIntent(imageList, origImageList, isOrig);
|
||||
intent.setClass(PreviewImageFromCameraActivity.this, getIntent().getClass());
|
||||
intent.putExtra(RESULT_SEND, true);
|
||||
setResult(RESULT_OK, intent);
|
||||
PreviewImageFromCameraActivity.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initActionBar() {
|
||||
TextView toolbarView = findView(R.id.action_bar_right_clickable_textview);
|
||||
toolbarView.setText(R.string.recapture);
|
||||
toolbarView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
deleteTempFile();
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(PreviewImageFromCameraActivity.this, getIntent().getClass());
|
||||
intent.putExtra(RESULT_RETAKE, true);
|
||||
setResult(RESULT_OK, intent);
|
||||
PreviewImageFromCameraActivity.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
deleteTempFile();
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(PreviewImageFromCameraActivity.this, getIntent().getClass());
|
||||
setResult(RESULT_CANCELED, intent);
|
||||
PreviewImageFromCameraActivity.this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Drawable dr = previewImageView.getDrawable();
|
||||
previewImageView.setImageBitmap(null);
|
||||
|
||||
if (dr != null) {
|
||||
Bitmap bitmap = getBitmap(dr);
|
||||
if (bitmap != null) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public static final Bitmap getBitmap(Drawable dr) {
|
||||
if (dr == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dr instanceof BitmapDrawable) {
|
||||
return ((BitmapDrawable) dr).getBitmap();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void showPicture() {
|
||||
try {
|
||||
Bitmap bitmap = BitmapDecoder.decodeSampledForDisplay(imageFile.getAbsolutePath());
|
||||
|
||||
if (bitmap != null) {
|
||||
previewImageView.setImageBitmap(bitmap);
|
||||
} else {
|
||||
// Toast.makeText(this, R.string.image_show_error, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.image_show_error);
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
// Toast.makeText(this, R.string.memory_out, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.memory_out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地图片
|
||||
*/
|
||||
protected void choosePictureFromLocal() {
|
||||
if (!StorageUtil.hasEnoughSpaceForWrite(PreviewImageFromCameraActivity.this, StorageType.TYPE_IMAGE, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new AsyncTask<String, Integer, Boolean>() {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
// Toast.makeText(PreviewImageFromCameraActivity.this, R.string.waitfor_image_local, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.waitfor_image_local);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... params) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
||||
}
|
||||
try {
|
||||
PreviewImageFromCameraActivity.this.startActivityForResult(intent, RequestCode.GET_LOCAL_IMAGE);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
// Toast.makeText(PreviewImageFromCameraActivity.this, R.string.gallery_invalid, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.gallery_invalid);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void deleteTempFile() {
|
||||
if (imageFile != null) {
|
||||
imageFile.delete();
|
||||
}
|
||||
|
||||
AttachmentStore.delete(origImageFilePath);
|
||||
}
|
||||
}
|
@@ -1,10 +1,8 @@
|
||||
package com.netease.nim.uikit.common.media.picker.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
@@ -17,6 +15,7 @@ import android.widget.TextView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
|
||||
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.netease.nim.uikit.R;
|
||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||
import com.netease.nim.uikit.business.session.constant.RequestCode;
|
||||
@@ -28,9 +27,6 @@ import com.netease.nim.uikit.common.util.file.AttachmentStore;
|
||||
import com.netease.nim.uikit.common.util.file.FileUtil;
|
||||
import com.netease.nim.uikit.common.util.media.BitmapDecoder;
|
||||
import com.netease.nim.uikit.common.util.media.ImageUtil;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageType;
|
||||
import com.netease.nim.uikit.common.util.storage.StorageUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -267,29 +263,29 @@ public class PreviewImageFromLocalActivity extends UI {
|
||||
* 获取本地图片
|
||||
*/
|
||||
protected void choosePictureFromLocal() {
|
||||
if (!StorageUtil.hasEnoughSpaceForWrite(PreviewImageFromLocalActivity.this, StorageType.TYPE_IMAGE, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new AsyncTask<String, Integer, Boolean>() {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
// Toast.makeText(PreviewImageFromLocalActivity.this, R.string.waitfor_image_local, Toast.LENGTH_LONG).show();
|
||||
SingleToastUtil.showToastShort(R.string.waitfor_image_local);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... params) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
int from = PickImageActivity.FROM_LOCAL;
|
||||
Activity thiz = PreviewImageFromLocalActivity.this;
|
||||
PickImageActivity.start(thiz, RequestCode.GET_LOCAL_IMAGE, from, "");
|
||||
}
|
||||
}.execute();
|
||||
// if (!StorageUtil.hasEnoughSpaceForWrite(PreviewImageFromLocalActivity.this, StorageType.TYPE_IMAGE, true)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// new AsyncTask<String, Integer, Boolean>() {
|
||||
// @Override
|
||||
// protected void onPreExecute() {
|
||||
//// Toast.makeText(PreviewImageFromLocalActivity.this, R.string.waitfor_image_local, Toast.LENGTH_LONG).show();
|
||||
// SingleToastUtil.showToastShort(R.string.waitfor_image_local);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected Boolean doInBackground(String... params) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onPostExecute(Boolean result) {
|
||||
// int from = PickImageActivity.FROM_LOCAL;
|
||||
// Activity thiz = PreviewImageFromLocalActivity.this;
|
||||
// PickImageActivity.start(thiz, RequestCode.GET_LOCAL_IMAGE, from, "");
|
||||
// }
|
||||
// }.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user