Skip to content

Commit c7fe2f6

Browse files
committed
feat: 新增【只显示图片】【只显示视频】
1 parent f5f63fe commit c7fe2f6

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

LibMediaPicker/src/main/java/me/bzcoder/mediapicker/camera/CameraActivity.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ public class CameraActivity extends AppCompatActivity {
4040
*/
4141
public int buttonState;
4242

43+
4344
public int duration;
4445

4546
public boolean isMirror;
47+
4648
@Override
4749
protected void onCreate(Bundle savedInstanceState) {
4850
super.onCreate(savedInstanceState);
@@ -72,7 +74,7 @@ public void onError() {
7274

7375
@Override
7476
public void AudioPermissionError() {
75-
Toast.makeText(CameraActivity.this, "给点录音权限可以?", Toast.LENGTH_SHORT).show();
77+
Toast.makeText(CameraActivity.this, "需要打开录音权限?", Toast.LENGTH_SHORT).show();
7678
}
7779
});
7880
if (buttonState != 0)
@@ -161,6 +163,11 @@ protected void onPause() {
161163
jCameraView.onPause();
162164
}
163165

166+
@Override
167+
protected void onDestroy() {
168+
super.onDestroy();
169+
}
170+
164171
private void finishActivityWithAnim() {
165172
finish();
166173
overridePendingTransition(0, R.anim.camera_push_bottom_out);

LibMediaPicker/src/main/java/me/bzcoder/mediapicker/cameralibrary/CameraInterface.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import android.content.Context;
66
import android.graphics.Bitmap;
77
import android.graphics.BitmapFactory;
8-
import android.graphics.Canvas;
98
import android.graphics.ImageFormat;
109
import android.graphics.Matrix;
1110
import android.graphics.Rect;
@@ -96,13 +95,16 @@ public static void destroyCameraInterface() {
9695
public static final int TYPE_RECORDER = 0x090;
9796
public static final int TYPE_CAPTURE = 0x091;
9897
private int nowScaleRate = 0;
99-
private int recordScleRate = 0;
98+
private int recordScaleRate = 0;
10099

101-
//视频质量
100+
101+
/**
102+
* 视频质量
103+
*/
102104
private int mediaQuality = JCameraView.MEDIA_QUALITY_MIDDLE;
103105

104106

105-
private SensorManager sm = null;
107+
private SensorManager sensorManager = null;
106108

107109
//获取CameraInterface单例
108110
public static synchronized CameraInterface getInstance() {
@@ -134,6 +136,7 @@ public void onSensorChanged(SensorEvent event) {
134136
rotationAnimation();
135137
}
136138

139+
@Override
137140
public void onAccuracyChanged(Sensor sensor, int accuracy) {
138141
}
139142
};
@@ -231,10 +234,10 @@ public void setZoom(float zoom, int type) {
231234
if (zoom >= 0) {
232235
//每移动50个像素缩放一个级别
233236
int scaleRate = (int) (zoom / 40);
234-
if (scaleRate <= mParams.getMaxZoom() && scaleRate >= nowScaleRate && recordScleRate != scaleRate) {
237+
if (scaleRate <= mParams.getMaxZoom() && scaleRate >= nowScaleRate && recordScaleRate != scaleRate) {
235238
mParams.setZoom(scaleRate);
236239
mCamera.setParameters(mParams);
237-
recordScleRate = scaleRate;
240+
recordScaleRate = scaleRate;
238241
}
239242
}
240243
break;
@@ -768,18 +771,18 @@ public interface FocusCallback {
768771

769772

770773
void registerSensorManager(Context context) {
771-
if (sm == null) {
772-
sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
774+
if (sensorManager == null) {
775+
sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
773776
}
774-
sm.registerListener(sensorEventListener, sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager
777+
sensorManager.registerListener(sensorEventListener, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager
775778
.SENSOR_DELAY_NORMAL);
776779
}
777780

778781
void unregisterSensorManager(Context context) {
779-
if (sm == null) {
780-
sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
782+
if (sensorManager == null) {
783+
sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
781784
}
782-
sm.unregisterListener(sensorEventListener);
785+
sensorManager.unregisterListener(sensorEventListener);
783786
}
784787

785788
void isPreview(boolean res) {

LibMediaPicker/src/main/java/me/bzcoder/mediapicker/photopicker/PhotoPickUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,14 @@ public void onComplete() {
7979
}
8080
});
8181
}
82+
8283
private static void startMatisse(Boolean aBoolean, MediaPickerConfig config, Matisse matisse) {
8384
if (aBoolean) {
84-
if (config.getImageEngine() == null)
85+
if (config.getImageEngine() == null) {
8586
throw new IllegalArgumentException("ImageEngine cannot be null");
87+
}
8688
matisse.choose(config.getPhotoPickerMediaType())
89+
.showSingleMediaType(config.getMaxVideoSelectable() == 0 || config.getMaxImageSelectable() == 0)
8790
.theme(R.style.Matisse_Zhihu)
8891
.countable(config.isCountable())
8992
.addFilter(new FileSizeFilter(config.getMaxWidth(), config.getMaxHeight(), config.getMaxVideoSize() * Filter.K * Filter.K, config.getMaxImageSize() * Filter.K * Filter.K, config.getMaxVideoLength()))

app/src/main/java/com/bzcoder/mediapicker/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void initView() {
4949

5050
builder = SmartMediaPicker.builder(this)
5151
//最大图片选择数目
52-
.withMaxImageSelectable(5)
52+
.withMaxImageSelectable(0)
5353
//最大视频选择数目
5454
.withMaxVideoSelectable(1)
5555
//图片选择器是否显示数字

0 commit comments

Comments
 (0)