@@ -76,8 +76,6 @@ public class FragmentManagement extends BaseActivity {
|
||||
private PoiFragment poiFragment;//寻宝-上传-POI的fragment -27
|
||||
private RoadFragment roadFragment;//寻宝-上传-道路的fragment -28
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.management_fragment;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import android.Manifest;
|
||||
@@ -8,6 +9,7 @@ import android.content.Intent;
|
||||
import android.os.CountDownTimer;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseActivity;
|
||||
import com.kongzue.dialog.util.DialogSettings;
|
||||
|
||||
@@ -52,8 +54,14 @@ public class MainActivity extends BaseActivity {
|
||||
Manifest.permission.READ_PHONE_STATE,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
};
|
||||
ActivityCompat.requestPermissions(this, pers, 100);
|
||||
ActivityCompat.requestPermissions(this, pers, Constant.PERMISSION_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable @org.jetbrains.annotations.Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
|
||||
@@ -0,0 +1,388 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.location.Location;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseActivity;
|
||||
|
||||
import com.navinfo.outdoor.util.SdkFolderCreate;
|
||||
import com.navinfo.outdoor.util.ToastUtil;
|
||||
import com.otaliastudios.cameraview.CameraException;
|
||||
import com.otaliastudios.cameraview.CameraListener;
|
||||
import com.otaliastudios.cameraview.CameraLogger;
|
||||
|
||||
import com.otaliastudios.cameraview.CameraView;
|
||||
import com.otaliastudios.cameraview.FileCallback;
|
||||
import com.otaliastudios.cameraview.PictureResult;
|
||||
import com.otaliastudios.cameraview.VideoResult;
|
||||
import com.otaliastudios.cameraview.controls.Mode;
|
||||
|
||||
import com.otaliastudios.cameraview.size.AspectRatio;
|
||||
import com.otaliastudios.cameraview.size.SizeSelectors;
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.map.geolocation.TencentLocationListener;
|
||||
import com.tencent.map.geolocation.TencentLocationManager;
|
||||
import com.tencent.map.geolocation.TencentLocationRequest;
|
||||
import com.tencent.tencentmap.mapsdk.maps.LocationSource;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
||||
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PictureActivity extends BaseActivity implements View.OnClickListener, LocationSource, TencentLocationListener {
|
||||
private static final CameraLogger LOG = CameraLogger.create("Picture");
|
||||
private CameraView camera;
|
||||
private ImageButton capturePicture;
|
||||
private long captureTime = 0;
|
||||
private android.widget.Button btnSwitch;
|
||||
private android.widget.ImageView ivPic;
|
||||
private boolean USE_FRAME_PROCESSOR = false;
|
||||
private boolean DECODE_BITMAP = false;
|
||||
private TencentMap tencentMap;
|
||||
private TencentLocationManager locationManager;
|
||||
private TencentLocationRequest locationRequest;
|
||||
private MyLocationStyle locationStyle;
|
||||
private OnLocationChangedListener locationChangedListener;
|
||||
private MapView ivMap;
|
||||
private ImageButton captureVideo;
|
||||
private Button btnVideo;
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.activity_camera;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
|
||||
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
ivMap = (MapView) findViewById(R.id.iv_map);
|
||||
btnVideo = findViewById(R.id.btn_video);
|
||||
btnVideo.setOnClickListener(this::onClick);
|
||||
btnSwitch = (Button) findViewById(R.id.btn_switch);
|
||||
btnSwitch.setOnClickListener(this::onClick);
|
||||
capturePicture = (ImageButton) findViewById(R.id.capturePicture);
|
||||
capturePicture.setOnClickListener(this::onClick);
|
||||
CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE);
|
||||
camera = findViewById(R.id.camera);
|
||||
camera.setOnClickListener(this::onClick);
|
||||
captureVideo = findViewById(R.id.captureVideo);
|
||||
captureVideo.setOnClickListener(this::onClick);
|
||||
|
||||
|
||||
camera.setLifecycleOwner(this);
|
||||
|
||||
//设置拍照的宽高
|
||||
//camera.setVideoSize(SizeSelectors.or(SizeSelectors.maxHeight(1000), SizeSelectors.smallest(), SizeSelectors.aspectRatio(AspectRatio.of(1, 1), 0)));
|
||||
|
||||
// Intent intent = getIntent();
|
||||
// String pic = intent.getStringExtra("pic");
|
||||
// camera.setVideoSize(SizeSelectors.or(SizeSelectors.maxHeight(Integer.parseInt(pic)),SizeSelectors.aspectRatio(AspectRatio.of(1, 1), 0)));
|
||||
|
||||
SdkFolderCreate.mkdirs(Constant.PICTURE_FOLDER);
|
||||
|
||||
//相机预览监听
|
||||
camera.addCameraListener(new CameraListener() {
|
||||
@Override
|
||||
public void onPictureTaken(@NonNull @NotNull PictureResult result) {
|
||||
super.onPictureTaken(result);
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
String format = formatter.format(calendar.getTime());
|
||||
//文件
|
||||
File file = new File(Constant.PICTURE_FOLDER, format + ".jpg");
|
||||
|
||||
result.toFile(file, new FileCallback() {
|
||||
@Override
|
||||
public void onFileReady(@Nullable @org.jetbrains.annotations.Nullable File file) {
|
||||
Toast.makeText(PictureActivity.this, "保存成功:" + file.getPath(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
if (camera.isTakingVideo()) {
|
||||
message("Captured while taking video. Size=" + result.getSize(), false);
|
||||
}
|
||||
long callbackTime = System.currentTimeMillis();
|
||||
captureTime = callbackTime - 300;
|
||||
Log.d("captureTime", captureTime + "");
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
//录像监听
|
||||
@Override
|
||||
public void onVideoTaken(@NonNull @NotNull VideoResult result) {
|
||||
super.onVideoTaken(result);
|
||||
Toast.makeText(PictureActivity.this, "停止摄像", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
// String format = formatter.format(calendar.getTime());
|
||||
//文件
|
||||
// File file = new File(Constant.PICTURE_FOLDER, format + ".mp4");
|
||||
// camera.takeVideo(file,5000);
|
||||
// VideoPreviewActivity.Companion.setVideoResult(result);
|
||||
// Intent videoIntent = new Intent(PictureActivity.this, VideoPreviewActivity.class);
|
||||
// startActivity(videoIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraError(@NonNull @NotNull CameraException exception) {
|
||||
super.onCameraError(exception);
|
||||
Toast.makeText(PictureActivity.this, exception.toString(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void message(String content, Boolean important) {
|
||||
if (important) {
|
||||
LOG.w(content);
|
||||
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
LOG.i(content);
|
||||
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
|
||||
camera.setMode(Mode.VIDEO);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.capturePicture:
|
||||
camera.setMode(Mode.PICTURE);
|
||||
if (!camera.isTakingPicture()) {
|
||||
captureTime = System.currentTimeMillis();
|
||||
message("Capturing picture...", false);
|
||||
camera.takePicture();
|
||||
}
|
||||
break;
|
||||
case R.id.btn_video:
|
||||
// camera.stopVideo();
|
||||
break;
|
||||
case R.id.btn_switch:
|
||||
btnSwich();
|
||||
break;
|
||||
case R.id.captureVideo:
|
||||
Intent intent = getIntent();
|
||||
String pic = intent.getStringExtra("pic");
|
||||
Log.d("lllllllllll", pic + "");
|
||||
if (pic!=null){
|
||||
camera.setVideoSize(SizeSelectors.or(SizeSelectors.maxHeight(Integer.parseInt(pic))));
|
||||
}
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
String format = formatter.format(calendar.getTime());
|
||||
//文件
|
||||
File file = new File(Constant.PICTURE_FOLDER, format + ".mp4");
|
||||
camera.takeVideo(file, 15000);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位的一些初始化设置
|
||||
*/
|
||||
private void initLocation() {
|
||||
//用于访问腾讯定位服务的类, 周期性向客户端提供位置更新
|
||||
locationManager = TencentLocationManager.getInstance(this);
|
||||
//设置坐标系
|
||||
locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02);
|
||||
//创建定位请求
|
||||
locationRequest = TencentLocationRequest.create();
|
||||
//设置定位周期(位置监听器回调周期)为3s
|
||||
// locationRequest.setInterval(3000);
|
||||
//地图上设置定位数据源
|
||||
tencentMap.setLocationSource(this);
|
||||
//设置当前位置可见
|
||||
tencentMap.setMyLocationEnabled(true);
|
||||
//设置定位图标样式
|
||||
setLocMarkerStyle();
|
||||
// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
}
|
||||
|
||||
private Bitmap getBitMap(int resourceId) {
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
int newWidth = 55;
|
||||
int newHeight = 55;
|
||||
float widthScale = ((float) newWidth) / width;
|
||||
float heightScale = ((float) newHeight) / height;
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale(widthScale, heightScale);
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置定位图标样式
|
||||
*/
|
||||
private void setLocMarkerStyle() {
|
||||
locationStyle = new MyLocationStyle();
|
||||
//创建图标
|
||||
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.location));
|
||||
locationStyle.icon(bitmapDescriptor);
|
||||
//设置定位圆形区域的边框宽度;
|
||||
locationStyle.strokeWidth(1);
|
||||
//设置圆区域的颜色
|
||||
// locationStyle.fillColor(R.color.colormap);
|
||||
// locationStyle.anchor(1000,2000);
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
}
|
||||
|
||||
|
||||
public void btnSwich() {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
System.out.println("width-display :" + dm.widthPixels);
|
||||
System.out.println("heigth-display :" + dm.heightPixels);
|
||||
ViewGroup.LayoutParams layoutParams = ivMap.getLayoutParams();//地图的宽高
|
||||
int height = layoutParams.height;
|
||||
int width = layoutParams.width;
|
||||
ViewGroup.LayoutParams layoutParams1 = camera.getLayoutParams();
|
||||
int height1 = layoutParams1.height;
|
||||
int width1 = layoutParams1.width;
|
||||
if (width > width1) {
|
||||
layoutParams1.width = dm.widthPixels;
|
||||
layoutParams1.height = dm.heightPixels;
|
||||
layoutParams.height = height1;
|
||||
layoutParams.width = width1;
|
||||
camera.setLayoutParams(layoutParams1);
|
||||
ivMap.setLayoutParams(layoutParams);
|
||||
} else {
|
||||
layoutParams.height = dm.heightPixels;
|
||||
layoutParams.width = dm.widthPixels;
|
||||
layoutParams1.height = height;
|
||||
layoutParams1.width = width;
|
||||
camera.setLayoutParams(layoutParams1);
|
||||
ivMap.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
|
||||
super.onResume();
|
||||
camera.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
camera.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
camera.destroy();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate(OnLocationChangedListener onLocationChangedListener) {
|
||||
locationChangedListener = onLocationChangedListener;
|
||||
int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper());
|
||||
switch (err) {
|
||||
case 1:
|
||||
ToastUtil.showShort(this, Constant.GET_ERR_MESSAGE1);
|
||||
break;
|
||||
case 2:
|
||||
ToastUtil.showShort(this, Constant.GET_ERR_MESSAGE2);
|
||||
break;
|
||||
case 3:
|
||||
ToastUtil.showShort(this, Constant.GET_ERR_MESSAGE3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
locationManager.removeUpdates(this);
|
||||
locationManager = null;
|
||||
locationRequest = null;
|
||||
locationChangedListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
|
||||
if (i == TencentLocation.ERROR_OK && locationChangedListener != null) {
|
||||
Location location = new Location(tencentLocation.getProvider());
|
||||
//设置经纬度以及精度
|
||||
location.setLatitude(tencentLocation.getLatitude());
|
||||
location.setLongitude(tencentLocation.getLongitude());
|
||||
location.setAccuracy(tencentLocation.getAccuracy());
|
||||
locationChangedListener.onLocationChanged(location);
|
||||
Constant.currentLocation = tencentLocation;
|
||||
//显示回调的实时位置信息
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//打印tencentLocation的json字符串
|
||||
// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusUpdate(String s, int i, String s1) {
|
||||
Log.v("State changed", s + "===" + s1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,430 @@
|
||||
package com.navinfo.outdoor.activity.camer
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.*
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.navinfo.outdoor.R
|
||||
import com.otaliastudios.cameraview.*
|
||||
import com.otaliastudios.cameraview.controls.Facing
|
||||
import com.otaliastudios.cameraview.controls.Mode
|
||||
import com.otaliastudios.cameraview.controls.Preview
|
||||
import com.otaliastudios.cameraview.filter.Filters
|
||||
import com.otaliastudios.cameraview.frame.Frame
|
||||
import com.otaliastudios.cameraview.frame.FrameProcessor
|
||||
import com.tencent.map.geolocation.TencentLocationManager
|
||||
import com.tencent.map.geolocation.TencentLocationRequest
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle
|
||||
import kotlinx.android.synthetic.main.activity_camera.*
|
||||
import kotlinx.android.synthetic.main.activity_my_camer.*
|
||||
import kotlinx.android.synthetic.main.activity_my_camer.capturePicture
|
||||
import kotlinx.android.synthetic.main.activity_my_camer.capturePictureSnapshot
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
|
||||
class MyCamerActivity : AppCompatActivity(), View.OnClickListener, OptionView.Callback {
|
||||
|
||||
companion object {
|
||||
private val LOG = CameraLogger.create("DemoApp")
|
||||
private const val USE_FRAME_PROCESSOR = false
|
||||
private const val DECODE_BITMAP = false
|
||||
}
|
||||
|
||||
private var locationManager: TencentLocationManager? = null
|
||||
private var locationRequest: TencentLocationRequest? = null
|
||||
private val tencentMap: TencentMap? = null
|
||||
private var locationStyle: MyLocationStyle? = null
|
||||
private val camera: CameraView by lazy { findViewById(R.id.camera) }
|
||||
private val edit : ImageButton by lazy { findViewById(R.id.edit) }
|
||||
private val ivmap: ImageView by lazy { findViewById(R.id.iv_map) }
|
||||
// private val ivmap: MapView by lazy { findViewById(R.id.iv_map) }
|
||||
|
||||
private val controlPanel: ViewGroup by lazy { findViewById(R.id.controls) }
|
||||
private var captureTime: Long = 0
|
||||
|
||||
private var currentFilter = 0
|
||||
private val allFilters = Filters.values()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_camera)
|
||||
CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE)
|
||||
camera.setLifecycleOwner(this)
|
||||
camera.addCameraListener(Listener())
|
||||
if (USE_FRAME_PROCESSOR) {
|
||||
camera.addFrameProcessor(object : FrameProcessor {
|
||||
private var lastTime = System.currentTimeMillis()
|
||||
override fun process(frame: Frame) {
|
||||
val newTime = frame.time
|
||||
val delay = newTime - lastTime
|
||||
lastTime = newTime
|
||||
LOG.v("Frame delayMillis:", delay, "FPS:", 1000 / delay)
|
||||
if (DECODE_BITMAP) {
|
||||
if (frame.format == ImageFormat.NV21
|
||||
&& frame.dataClass == ByteArray::class.java) {
|
||||
val data = frame.getData<ByteArray>()
|
||||
val yuvImage = YuvImage(data,
|
||||
frame.format,
|
||||
frame.size.width,
|
||||
frame.size.height,
|
||||
null)
|
||||
val jpegStream = ByteArrayOutputStream()
|
||||
yuvImage.compressToJpeg(Rect(0, 0,
|
||||
frame.size.width,
|
||||
frame.size.height), 100, jpegStream)
|
||||
val jpegByteArray = jpegStream.toByteArray()
|
||||
val bitmap = BitmapFactory.decodeByteArray(jpegByteArray,
|
||||
0, jpegByteArray.size)
|
||||
bitmap.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
edit.setOnClickListener(this)
|
||||
capturePicture.setOnClickListener(this)
|
||||
capturePictureSnapshot.setOnClickListener(this)
|
||||
btn_switch.setOnClickListener(this)
|
||||
// captureVideo.setOnClickListener(this)
|
||||
// captureVideoSnapshot.setOnClickListener(this)
|
||||
// toggleCamera.setOnClickListener(this)
|
||||
|
||||
val group = controlPanel.getChildAt(0) as ViewGroup
|
||||
// val watermark = findViewById<View>( R.id.watermark)
|
||||
val options: List<Option<*>> = listOf(
|
||||
// Layout
|
||||
Option.Width(), Option.Height(),
|
||||
// Engine and preview
|
||||
Option.Mode(), Option.Engine(), Option.Preview(),
|
||||
// Some controls
|
||||
Option.Flash(), Option.WhiteBalance(), Option.Hdr(),
|
||||
Option.PictureMetering(), Option.PictureSnapshotMetering(),
|
||||
Option.PictureFormat(),
|
||||
// Video recording
|
||||
Option.PreviewFrameRate(), Option.VideoCodec(), Option.Audio(), Option.AudioCodec(),
|
||||
// Gestures
|
||||
Option.Pinch(), Option.HorizontalScroll(), Option.VerticalScroll(),
|
||||
Option.Tap(), Option.LongTap(),
|
||||
// Watermarks
|
||||
// Option.OverlayInPreview(watermark),
|
||||
// Option.OverlayInPictureSnapshot(watermark),
|
||||
// Option.OverlayInVideoSnapshot(watermark),
|
||||
// Frame Processing
|
||||
Option.FrameProcessingFormat(),
|
||||
// Other
|
||||
Option.Grid(), Option.GridColor(), Option.UseDeviceOrientation()
|
||||
)
|
||||
val dividers = listOf(
|
||||
// Layout
|
||||
false, true,
|
||||
// Engine and preview
|
||||
false, false, true,
|
||||
// Some controls
|
||||
false, false, false, false, false, true,
|
||||
// Video recording
|
||||
false, false, false, true,
|
||||
// Gestures
|
||||
false, false, false, false, true,
|
||||
// Watermarks
|
||||
// false, false, true,
|
||||
// Frame Processing
|
||||
true,
|
||||
// Other
|
||||
false, false, true
|
||||
)
|
||||
for (i in options.indices) {
|
||||
val view = OptionView<Any>(this)
|
||||
view.setOption(options[i] as Option<Any>, this)
|
||||
view.setHasDivider(dividers[i])
|
||||
group.addView(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
controlPanel.viewTreeObserver.addOnGlobalLayoutListener {
|
||||
BottomSheetBehavior.from(controlPanel).state = BottomSheetBehavior.STATE_HIDDEN
|
||||
}
|
||||
|
||||
// Animate the watermark just to show we record the animation in video snapshots
|
||||
val animator = ValueAnimator.ofFloat(1f, 0.8f)
|
||||
animator.duration = 300
|
||||
animator.repeatCount = ValueAnimator.INFINITE
|
||||
animator.repeatMode = ValueAnimator.REVERSE
|
||||
// animator.addUpdateListener { animation ->
|
||||
// val scale = animation.animatedValue as Float
|
||||
// watermark.scaleX = scale
|
||||
// watermark.scaleY = scale
|
||||
// watermark.rotation = watermark.rotation + 2
|
||||
// }
|
||||
animator.start()
|
||||
}
|
||||
|
||||
|
||||
private fun message(content: String, important: Boolean) {
|
||||
if (important) {
|
||||
LOG.w(content)
|
||||
Toast.makeText(this, content, Toast.LENGTH_LONG).show()
|
||||
} else {
|
||||
LOG.i(content)
|
||||
Toast.makeText(this, content, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private inner class Listener : CameraListener() {
|
||||
override fun onCameraOpened(options: CameraOptions) {
|
||||
val group = controlPanel.getChildAt(0) as ViewGroup
|
||||
for (i in 0 until group.childCount) {
|
||||
val view = group.getChildAt(i) as OptionView<*>
|
||||
view.onCameraOpened(camera, options)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCameraError(exception: CameraException) {
|
||||
super.onCameraError(exception)
|
||||
message("Got CameraException #" + exception.reason, true)
|
||||
}
|
||||
|
||||
override fun onPictureTaken(result: PictureResult) {
|
||||
super.onPictureTaken(result)
|
||||
if (camera.isTakingVideo) {
|
||||
message("Captured while taking video. Size=" + result.size, false)
|
||||
return
|
||||
}
|
||||
|
||||
// This can happen if picture was taken with a gesture.
|
||||
val callbackTime = System.currentTimeMillis()
|
||||
if (captureTime == 0L) captureTime = callbackTime - 300
|
||||
LOG.w("onPictureTaken called! Launching activity. Delay:", callbackTime - captureTime)
|
||||
PicturePreviewActivity.pictureResult = result
|
||||
val intent = Intent(this@MyCamerActivity, PicturePreviewActivity::class.java)
|
||||
intent.putExtra("delay", callbackTime - captureTime)
|
||||
startActivity(intent)
|
||||
captureTime = 0
|
||||
LOG.w("onPictureTaken called! Launched activity.")
|
||||
}
|
||||
|
||||
override fun onVideoTaken(result: VideoResult) {
|
||||
super.onVideoTaken(result)
|
||||
LOG.w("onVideoTaken called! Launching activity.")
|
||||
VideoPreviewActivity.videoResult = result
|
||||
val intent = Intent(this@MyCamerActivity, VideoPreviewActivity::class.java)
|
||||
startActivity(intent)
|
||||
LOG.w("onVideoTaken called! Launched activity.")
|
||||
}
|
||||
|
||||
override fun onVideoRecordingStart() {
|
||||
super.onVideoRecordingStart()
|
||||
LOG.w("onVideoRecordingStart!")
|
||||
}
|
||||
|
||||
override fun onVideoRecordingEnd() {
|
||||
super.onVideoRecordingEnd()
|
||||
message("Video taken. Processing...", false)
|
||||
LOG.w("onVideoRecordingEnd!")
|
||||
}
|
||||
|
||||
override fun onExposureCorrectionChanged(newValue: Float, bounds: FloatArray, fingers: Array<PointF>?) {
|
||||
super.onExposureCorrectionChanged(newValue, bounds, fingers)
|
||||
message("Exposure correction:$newValue", false)
|
||||
}
|
||||
|
||||
override fun onZoomChanged(newValue: Float, bounds: FloatArray, fingers: Array<PointF>?) {
|
||||
super.onZoomChanged(newValue, bounds, fingers)
|
||||
message("Zoom:$newValue", false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.edit -> edit()
|
||||
R.id.capturePicture -> capturePicture()
|
||||
R.id.capturePictureSnapshot -> capturePictureSnapshot()
|
||||
R.id.btn_switch -> btnSwitch()
|
||||
// R.id.captureVideo -> captureVideo()
|
||||
// R.id.captureVideoSnapshot -> captureVideoSnapshot()
|
||||
// R.id.toggleCamera -> toggleCamera()
|
||||
// R.id.changeFilter -> changeCurrentFilter()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
val b = BottomSheetBehavior.from(controlPanel)
|
||||
if (b.state != BottomSheetBehavior.STATE_HIDDEN) {
|
||||
b.state = BottomSheetBehavior.STATE_HIDDEN
|
||||
return
|
||||
}
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun edit() {
|
||||
BottomSheetBehavior.from(controlPanel).state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
|
||||
private fun capturePicture() {
|
||||
if (camera.mode == Mode.VIDEO) return run {
|
||||
message("Can't take HQ pictures while in VIDEO mode.", false)
|
||||
}
|
||||
if (camera.isTakingPicture) return
|
||||
captureTime = System.currentTimeMillis()
|
||||
message("Capturing picture...", false)
|
||||
camera.takePicture()
|
||||
}
|
||||
|
||||
private fun capturePictureSnapshot() {
|
||||
if (camera.isTakingPicture) return
|
||||
if (camera.preview != Preview.GL_SURFACE) return run {
|
||||
message("Picture snapshots are only allowed with the GL_SURFACE preview.", true)
|
||||
}
|
||||
captureTime = System.currentTimeMillis()
|
||||
message("Capturing picture snapshot...", false)
|
||||
camera.takePictureSnapshot()
|
||||
}
|
||||
|
||||
private fun captureVideo() {
|
||||
if (camera.mode == Mode.PICTURE) return run {
|
||||
message("Can't record HQ videos while in PICTURE mode.", false)
|
||||
}
|
||||
if (camera.isTakingPicture || camera.isTakingVideo) return
|
||||
message("Recording for 5 seconds...", true)
|
||||
camera.takeVideo(File(filesDir, "video.mp4"), 5000)
|
||||
}
|
||||
|
||||
private fun captureVideoSnapshot() {
|
||||
if (camera.isTakingVideo) return run {
|
||||
message("Already taking video.", false)
|
||||
}
|
||||
if (camera.preview != Preview.GL_SURFACE) return run {
|
||||
message("Video snapshots are only allowed with the GL_SURFACE preview.", true)
|
||||
}
|
||||
message("Recording snapshot for 5 seconds...", true)
|
||||
camera.takeVideoSnapshot(File(filesDir, "video.mp4"), 5000)
|
||||
}
|
||||
|
||||
private fun toggleCamera() {
|
||||
if (camera.isTakingPicture || camera.isTakingVideo) return
|
||||
when (camera.toggleFacing()) {
|
||||
Facing.BACK -> message("Switched to back camera!", false)
|
||||
Facing.FRONT -> message("Switched to front camera!", false)
|
||||
}
|
||||
}
|
||||
//动态设置地图 相机切换的宽高
|
||||
private fun btnSwitch() {
|
||||
val layoutParams = ivmap.getLayoutParams()
|
||||
val height = layoutParams.height
|
||||
val width = layoutParams.width
|
||||
val layoutParams1 = camera.getLayoutParams()
|
||||
val height1 = layoutParams1.height
|
||||
val width1 = layoutParams1.width
|
||||
if (width > width1) {
|
||||
layoutParams1.height = height
|
||||
layoutParams1.width = width
|
||||
camera.setLayoutParams(layoutParams1)
|
||||
} else {
|
||||
layoutParams.height = height1
|
||||
layoutParams.width = width1
|
||||
ivmap.setLayoutParams(layoutParams1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun changeCurrentFilter() {
|
||||
if (camera.preview != Preview.GL_SURFACE) return run {
|
||||
message("Filters are supported only when preview is Preview.GL_SURFACE.", true)
|
||||
}
|
||||
if (currentFilter < allFilters.size - 1) {
|
||||
currentFilter++
|
||||
} else {
|
||||
currentFilter = 0
|
||||
}
|
||||
val filter = allFilters[currentFilter]
|
||||
message(filter.toString(), false)
|
||||
|
||||
// Normal behavior:
|
||||
camera.filter = filter.newInstance()
|
||||
|
||||
// To test MultiFilter:
|
||||
// DuotoneFilter duotone = new DuotoneFilter();
|
||||
// duotone.setFirstColor(Color.RED);
|
||||
// duotone.setSecondColor(Color.GREEN);
|
||||
// camera.setFilter(new MultiFilter(duotone, filter.newInstance()));
|
||||
}
|
||||
|
||||
override fun <T : Any> onValueChanged(option: Option<T>, value: T, name: String): Boolean {
|
||||
if (option is Option.Width || option is Option.Height) {
|
||||
val preview = camera.preview
|
||||
val wrapContent = value as Int == ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
if (preview == Preview.SURFACE && !wrapContent) {
|
||||
message("The SurfaceView preview does not support width or height changes. " +
|
||||
"The view will act as WRAP_CONTENT by default.", true)
|
||||
return false
|
||||
}
|
||||
}
|
||||
option.set(camera, value)
|
||||
BottomSheetBehavior.from(controlPanel).state = BottomSheetBehavior.STATE_HIDDEN
|
||||
message("Changed " + option.name + " to " + name, false)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String?>, grantResults: IntArray) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
val valid = grantResults.all { it == PackageManager.PERMISSION_GRANTED }
|
||||
if (valid && !camera.isOpened) {
|
||||
camera.open()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位的一些初始化设置
|
||||
*/
|
||||
// private fun initLocation() {
|
||||
////用于访问腾讯定位服务的类, 周期性向客户端提供位置更新
|
||||
// locationManager = TencentLocationManager.getInstance(getContext())
|
||||
// //设置坐标系
|
||||
// locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02)
|
||||
// //创建定位请求
|
||||
// locationRequest = TencentLocationRequest.create()
|
||||
// //设置定位周期(位置监听器回调周期)为3s
|
||||
// // locationRequest.setInterval(3000);
|
||||
// //地图上设置定位数据源
|
||||
// tencentMap.setLocationSource(this)
|
||||
// //设置当前位置可见
|
||||
// tencentMap.setMyLocationEnabled(true)
|
||||
// //设置定位图标样式
|
||||
// setLocMarkerStyle()
|
||||
// // locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
|
||||
// tencentMap.setMyLocationStyle(locationStyle)
|
||||
// }
|
||||
|
||||
/**
|
||||
* 设置定位图标样式
|
||||
*/
|
||||
// private fun setLocMarkerStyle() {
|
||||
// locationStyle = MyLocationStyle()
|
||||
// //创建图标
|
||||
// val bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.location))
|
||||
// locationStyle.icon(bitmapDescriptor)
|
||||
// //设置定位圆形区域的边框宽度;
|
||||
// locationStyle.strokeWidth(1)
|
||||
// //设置圆区域的颜色
|
||||
// // locationStyle.fillColor(R.color.colormap);
|
||||
// // locationStyle.anchor(1000,2000);
|
||||
// tencentMap!!.setMyLocationStyle(locationStyle)
|
||||
// }
|
||||
|
||||
override fun onResume() {
|
||||
/**
|
||||
* 设置为横屏
|
||||
*/
|
||||
if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
super.onResume()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.navinfo.outdoor.api;
|
||||
|
||||
import com.navinfo.outdoor.util.SdkFolderCreate;
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
|
||||
/**
|
||||
@@ -20,6 +21,15 @@ public class Constant {
|
||||
public static final String GET_ERR_MESSAGE1 = "设备缺少使用腾讯定位服务需要的基本条件";
|
||||
public static final String GET_ERR_MESSAGE2 = "manifest 中配置的 key 不正确";
|
||||
public static final String GET_ERR_MESSAGE3 = "自动加载libtencentloc.so失败";
|
||||
public static final String BASE_FOLDER = SdkFolderCreate.getSDPath()+"/navinfoOutDoor";
|
||||
// 保存图片的目录
|
||||
public static final String PICTURE_FOLDER = BASE_FOLDER+"/picture";
|
||||
// 申请权限的RequestCode
|
||||
public static final int PERMISSION_REQUEST_CODE = 0x100;
|
||||
|
||||
public static final int ROAD_PICTURE = 101;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户当前位置
|
||||
|
||||
@@ -1,22 +1,35 @@
|
||||
package com.navinfo.outdoor.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.activity.PictureActivity;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseFragment;
|
||||
import com.otaliastudios.cameraview.size.AspectRatio;
|
||||
import com.otaliastudios.cameraview.size.SizeSelectors;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
/**
|
||||
* 寻宝-点击上传弹窗-道路
|
||||
*/
|
||||
public class RoadFragment extends BaseFragment implements View.OnClickListener {
|
||||
|
||||
|
||||
private TextView tvPictures;
|
||||
private EditText etHeight;
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.fragment_road;
|
||||
@@ -25,15 +38,38 @@ public class RoadFragment extends BaseFragment implements View.OnClickListener {
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
|
||||
tvPictures = (TextView) findViewById(R.id.tv_pictures);
|
||||
tvPictures.setOnClickListener(this::onClick);
|
||||
etHeight = (EditText) findViewById(R.id.et_height);
|
||||
etHeight.setOnClickListener(this::onClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
switch (v.getId()) {
|
||||
case R.id.tv_pictures:
|
||||
Intent picturesIntent = new Intent(getContext(), PictureActivity.class);
|
||||
startActivity(picturesIntent);
|
||||
break;
|
||||
case R.id.et_height:
|
||||
String ssss = etHeight.getText().toString();
|
||||
if (ssss != null && !ssss.isEmpty()) {
|
||||
//
|
||||
Intent intent = new Intent(getContext(), PictureActivity.class);
|
||||
// PictureActivity activity = (PictureActivity) getActivity();
|
||||
// activity.
|
||||
intent.putExtra("pic", etHeight.getText().toString());
|
||||
Log.d("TAG", "onClick: jjjjjj"+etHeight.getText()+"");
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Toast.makeText(getContext(), "不能为空", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
app/src/main/java/com/navinfo/outdoor/util/PictureName.java
Normal file
16
app/src/main/java/com/navinfo/outdoor/util/PictureName.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class PictureName {
|
||||
public static String pictureDay() {
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
String format = formatter.format(calendar.getTime());
|
||||
return format;
|
||||
}
|
||||
|
||||
}
|
||||
42
app/src/main/java/com/navinfo/outdoor/util/PictureUtil.java
Normal file
42
app/src/main/java/com/navinfo/outdoor/util/PictureUtil.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PictureUtil {
|
||||
//保存bitmap图片到本地
|
||||
public static void saveBitmap(Bitmap bitmap, Context context, String path, String saveName) {
|
||||
try {
|
||||
|
||||
File dirFile = new File(path);
|
||||
if (!dirFile.exists()) { //如果不存在,那就建立这个文件夹
|
||||
dirFile.mkdirs();
|
||||
}
|
||||
File file = new File(path, saveName);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 把文件插入到系统图库
|
||||
// try {
|
||||
// MediaStore.Images.Media.insertImage(context.getContentResolver(),
|
||||
// file.getAbsolutePath(), fileName, null);
|
||||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// // 通知图库更新
|
||||
// context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
|
||||
// Uri.parse("file://" + "/sdcard/namecard/")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Environment;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SdkFolderCreate {
|
||||
//获取SDK根目录
|
||||
public static String getSDPath() {
|
||||
File sdDir = null;
|
||||
boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);// 判断sd卡是否存在
|
||||
if (sdCardExist) {
|
||||
sdDir = Environment.getExternalStorageDirectory();// 获取跟目录
|
||||
}
|
||||
return sdDir.toString();
|
||||
}
|
||||
public static String mkdirs(String path) {
|
||||
String sdcard = getSDPath();
|
||||
if (path.indexOf(getSDPath()) == -1) {
|
||||
path = sdcard + (path.indexOf("/") == 0 ? "" : "/") + path;
|
||||
}
|
||||
File destDir = new File(path);
|
||||
if (!destDir.exists()) {
|
||||
boolean result = destDir.mkdirs();
|
||||
System.out.println("文件夹创建:"+result);
|
||||
// path = makedir(path);
|
||||
// if (path == null) {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
return path;
|
||||
}
|
||||
//创建文件夹
|
||||
private static String makedir(String path) {
|
||||
String sdPath = getSDPath();
|
||||
String[] dirs = path.replace(sdPath, "").split("/");
|
||||
StringBuffer filePath = new StringBuffer(sdPath);
|
||||
for (String dir : dirs) {
|
||||
if (!"".equals(dir) && !dir.equals(sdPath)) {
|
||||
filePath.append("/").append(dir);
|
||||
File destDir = new File(filePath.toString());
|
||||
if (!destDir.exists()) {
|
||||
boolean b = destDir.mkdirs();
|
||||
if (!b) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return filePath.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user