Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/ui/activity/PermissionsActivity.kt app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt collect-library/src/main/java/com/navinfo/collect/library/map/handler/LayerManagerHandler.kt
This commit is contained in:
@@ -31,8 +31,11 @@ open class PermissionsActivity : BaseActivity() {
|
||||
permissionList.add(Permission.ACCESS_COARSE_LOCATION)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
// permissionList.add(Permission.ACCESS_BACKGROUND_LOCATION)
|
||||
//android10
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
|
||||
permissionList.add(Permission.ACCESS_BACKGROUND_LOCATION)
|
||||
}
|
||||
XXPermissions.with(this)
|
||||
/* XXPermissions.with(this)
|
||||
// 申请单个权限
|
||||
.permission(permissionList)
|
||||
// 设置权限请求拦截器(局部设置)
|
||||
@@ -72,7 +75,7 @@ open class PermissionsActivity : BaseActivity() {
|
||||
onPermissionsDenied()
|
||||
}
|
||||
}
|
||||
})
|
||||
})*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.os.Bundle
|
||||
import android.provider.ContactsContract.Contacts
|
||||
import android.util.Log
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.findNavController
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.NiLocationListener
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.ActivityMainBinding
|
||||
import com.navinfo.omqs.db.TraceDataBase
|
||||
import com.navinfo.omqs.http.offlinemapdownload.OfflineMapDownloadManager
|
||||
import com.navinfo.omqs.system.SystemConstant
|
||||
import com.navinfo.omqs.ui.activity.BaseActivity
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import javax.inject.Inject
|
||||
@@ -69,6 +72,13 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
//开启定位
|
||||
mapController.locationLayerHandler.startLocation()
|
||||
//启动轨迹存储
|
||||
mapController.locationLayerHandler.setNiLocationListener(NiLocationListener {
|
||||
binding!!.viewModel!!.addSaveTrace(it)
|
||||
binding!!.viewModel!!.startSaveTraceThread(this)
|
||||
})
|
||||
//显示轨迹图层
|
||||
mapController.layerManagerHandler.showNiLocationLayer(Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite")
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@@ -94,6 +104,13 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivityDrawer.open()
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开相机预览
|
||||
*/
|
||||
fun openCamera() {
|
||||
binding!!.viewModel!!.onClickCameraButton(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击录音按钮
|
||||
*/
|
||||
|
||||
@@ -1,14 +1,28 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.db.TraceDataBase
|
||||
import com.navinfo.omqs.system.SystemConstant
|
||||
import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
||||
import io.realm.RealmSet
|
||||
import org.videolan.libvlc.LibVlcUtil
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* 创建Activity全局viewmode
|
||||
@@ -19,6 +33,9 @@ class MainViewModel @Inject constructor(
|
||||
) : ViewModel() {
|
||||
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
private var mCameraDialog: CommonDialog? = null
|
||||
|
||||
private var niLocationList:MutableList<NiLocation> = ArrayList<NiLocation>()
|
||||
|
||||
init {
|
||||
mapController.layerManagerHandler.setOnQsRecordItemClickListener(object :
|
||||
@@ -39,4 +56,81 @@ class MainViewModel @Inject constructor(
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
//点击相机按钮
|
||||
fun onClickCameraButton(context: Context){
|
||||
|
||||
Log.e("qj", LibVlcUtil.hasCompatibleCPU(context).toString())
|
||||
|
||||
ToastUtils.showShort("点击了相机")
|
||||
|
||||
if (mCameraDialog == null) {
|
||||
mCameraDialog = CommonDialog(context, context.resources.getDimension(R.dimen.head_img_width).toInt() * 3 + context.resources.getDimension(R.dimen.ten).toInt() + context.resources.getDimension(R.dimen.twenty_four).toInt(), context.resources.getDimension(R.dimen.head_img_width).toInt() + 10, 1)
|
||||
mCameraDialog!!.setCancelable(true)
|
||||
}
|
||||
mCameraDialog!!.openCamear(mCameraDialog!!.getmShareUtil().continusTakePhotoState)
|
||||
mCameraDialog!!.show()
|
||||
mCameraDialog!!.setOnDismissListener(DialogInterface.OnDismissListener {
|
||||
mCameraDialog!!.hideLoading()
|
||||
mCameraDialog!!.stopVideo()
|
||||
try {
|
||||
if (!mCameraDialog!!.getmShareUtil().connectstate){
|
||||
mCameraDialog!!.updateCameraResources(1, mCameraDialog!!.getmDeviceNum())
|
||||
}
|
||||
TakePhotoManager.getInstance().getCameraVedioClent(mCameraDialog!!.getmDeviceNum()).StopSearch()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
})
|
||||
mCameraDialog!!.setOnShowListener(DialogInterface.OnShowListener {
|
||||
mCameraDialog!!.initmTakePhotoOrRecord(mCameraDialog!!.getmShareUtil().selectTakePhotoOrRecord)
|
||||
if (!mCameraDialog!!.isShowVideo && mCameraDialog!!.getmShareUtil().connectstate && mCameraDialog!!.getmShareUtil().continusTakePhotoState) {
|
||||
mCameraDialog!!.playVideo()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun startSaveTraceThread(context: Context){
|
||||
Thread(Runnable {
|
||||
try {
|
||||
while (true){
|
||||
|
||||
if(niLocationList!=null&&niLocationList.size>0){
|
||||
|
||||
var niLocation = niLocationList[0]
|
||||
var doubleArray = doubleArrayOf()
|
||||
doubleArray[0] = niLocation.longitude
|
||||
doubleArray[1] = niLocation.latitude
|
||||
val geometry = GeometryTools.createGeometry(doubleArray)
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
niLocation.tilex = x
|
||||
niLocation.tiley = y
|
||||
}
|
||||
}
|
||||
|
||||
TraceDataBase.getDatabase(context, Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite").niLocationDao.insert(niLocation)
|
||||
niLocationList.removeAt(0)
|
||||
Log.e("qj","saveTrace")
|
||||
}
|
||||
Thread.sleep(30)
|
||||
}
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
Log.e("qj","异常==${e.message}")
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
|
||||
//增加轨迹存储
|
||||
fun addSaveTrace(niLocation: NiLocation){
|
||||
if(niLocation!=null&&niLocationList!=null){
|
||||
niLocationList.add(niLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
1608
app/src/main/java/com/navinfo/omqs/ui/dialog/CommonDialog.java
Normal file
1608
app/src/main/java/com/navinfo/omqs/ui/dialog/CommonDialog.java
Normal file
File diff suppressed because it is too large
Load Diff
11
app/src/main/java/com/navinfo/omqs/ui/dialog/DataSource.java
Normal file
11
app/src/main/java/com/navinfo/omqs/ui/dialog/DataSource.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.navinfo.omqs.ui.dialog;
|
||||
/**
|
||||
* @ClassName: DataSource.java
|
||||
* @author zcs
|
||||
* @version V1.0
|
||||
* @Date 2015年9月17日 下午1:20:08
|
||||
* @Description: Dialog关闭时调用
|
||||
*/
|
||||
public abstract class DataSource {
|
||||
public abstract void Data(String str,Object obg);
|
||||
}
|
||||
510
app/src/main/java/com/navinfo/omqs/ui/dialog/FirstDialog.java
Normal file
510
app/src/main/java/com/navinfo/omqs/ui/dialog/FirstDialog.java
Normal file
@@ -0,0 +1,510 @@
|
||||
package com.navinfo.omqs.ui.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.navinfo.omqs.R;
|
||||
|
||||
/**
|
||||
* @author zcs
|
||||
* @version V1.0
|
||||
* @ClassName: FirstDialog.java
|
||||
* @Date 2015年11月18日 下午5:25:27
|
||||
* @Description: 弹出默认的dialog
|
||||
*/
|
||||
public class FirstDialog extends MyDialog {
|
||||
|
||||
private CharSequence mPositiveButtonText;
|
||||
private OnClickListener mPositiveButtonListener;
|
||||
private CharSequence mNegativeButtonText;
|
||||
private OnClickListener mNegativeButtonListener;
|
||||
private CharSequence mMiddleButtonText;
|
||||
private OnClickListener mMiddleButtonListener;
|
||||
private Object tag;
|
||||
|
||||
public FirstDialog(Context context) {
|
||||
|
||||
super(context);
|
||||
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
View rootView = LayoutInflater.from(context).inflate(R.layout.dialog_default, null);
|
||||
setContentView(rootView/*, layoutParams*/);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void request(Object obj) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置标题文字
|
||||
*/
|
||||
@Override
|
||||
public void setTitle(CharSequence string) {
|
||||
findViewById(R.id.ll_title).setVisibility(View.VISIBLE);
|
||||
TextView tv = (TextView) findViewById(R.id.tv_title);
|
||||
tv.setText(TextUtils.isEmpty(string) ? "" : string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题颜色
|
||||
*/
|
||||
public void setTitleColor(int color) {
|
||||
((TextView) findViewById(R.id.tv_title)).setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题2文字
|
||||
*/
|
||||
public void setTitle2(CharSequence string) {
|
||||
findViewById(R.id.tv_title2).setVisibility(View.VISIBLE);
|
||||
TextView tv = (TextView) findViewById(R.id.tv_title2);
|
||||
tv.setText(TextUtils.isEmpty(string) ? "" : string);
|
||||
}
|
||||
|
||||
public void setTitle2Color(int color) {
|
||||
((TextView) findViewById(R.id.tv_title2)).setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题下分割线显隐
|
||||
*/
|
||||
public void setTitleDividerVisible(int visible) {
|
||||
findViewById(R.id.title_divider).setVisibility(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标题下分割线显隐
|
||||
*/
|
||||
public void setTitleDividerVisible2(int visible) {
|
||||
findViewById(R.id.title_divider2).setVisibility(visible);
|
||||
}
|
||||
|
||||
public void setBottomDividerVisible(int visible) {
|
||||
findViewById(R.id.v_divice).setVisibility(visible);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认按钮
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setConfirm(CharSequence string) {
|
||||
mPositiveButtonText = string;
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_confirm);
|
||||
showBottomView();
|
||||
btn.setText(TextUtils.isEmpty(string) ? "确定" : string);
|
||||
}
|
||||
|
||||
public void setConfirmEnable(boolean enable) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_confirm);
|
||||
btn.setEnabled(enable);
|
||||
}
|
||||
|
||||
|
||||
public void setConfirmVisibility(int visibility) {
|
||||
findViewById(R.id.btn_fm_confirm).setVisibility(visibility);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认按钮
|
||||
*
|
||||
* @param colors
|
||||
*/
|
||||
public void setConfirmTxtColor(int colors) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_confirm);
|
||||
btn.setTextColor(colors);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认按钮字体大小
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setConfirmSize(float size) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_confirm);
|
||||
btn.setTextSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setCancel(CharSequence string) {
|
||||
mNegativeButtonText = string;
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_cancel);
|
||||
btn.setText(TextUtils.isEmpty(string) ? "取消" : string);
|
||||
showBottomView();
|
||||
btn.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮字体颜色
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void setCancelTxtColor(int color) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_cancel);
|
||||
btn.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮是否可点
|
||||
*
|
||||
* @param bl
|
||||
*/
|
||||
public void setCancelIsCanClick(Boolean bl) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_cancel);
|
||||
btn.setEnabled(bl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮字体大小
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setCancelSize(float size) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_cancel);
|
||||
btn.setTextSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 中间按钮
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setMiddle(CharSequence string) {
|
||||
mNegativeButtonText = string;
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_middle);
|
||||
btn.setText(TextUtils.isEmpty(string) ? "中间" : string);
|
||||
showBottomView();
|
||||
btn.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 中间按钮字体颜色
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void setMiddleTxtColor(int color) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_middle);
|
||||
btn.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* 中间按钮是否可点
|
||||
*
|
||||
* @param bl
|
||||
*/
|
||||
public void setMiddleIsCanClick(Boolean bl) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_middle);
|
||||
btn.setEnabled(bl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 中间按钮字体大小
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setMiddleSize(float size) {
|
||||
TextView btn = (TextView) findViewById(R.id.btn_fm_middle);
|
||||
btn.setTextSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置中间提示信息
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setContentTxt(CharSequence string) {
|
||||
TextView tv = (TextView) findViewById(R.id.tv_content);
|
||||
tv.setText(TextUtils.isEmpty(string) ? "" : string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置中间提示信息是否可长按复制
|
||||
*
|
||||
* @param isSelectable
|
||||
*/
|
||||
public void setTextIsSelectable(boolean isSelectable) {
|
||||
TextView tv = (TextView) findViewById(R.id.tv_content);
|
||||
tv.setTextIsSelectable(isSelectable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置点击事件
|
||||
*
|
||||
* @param click
|
||||
*/
|
||||
public void setContentClickListener(View.OnClickListener click) {
|
||||
findViewById(R.id.tv_content).setOnClickListener(click);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置中间显隐
|
||||
*
|
||||
* @param visable
|
||||
*/
|
||||
public void setContentTxtVisable(int visable) {
|
||||
TextView tv = (TextView) findViewById(R.id.tv_content);
|
||||
tv.setVisibility(visable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置中间提示信息
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public void setMessage(CharSequence string) {
|
||||
setContentTxt(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置中间提示颜色
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void setMessageColor(int color) {
|
||||
TextView tv = (TextView) findViewById(R.id.tv_content);
|
||||
tv.setTextColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置中间提示文字
|
||||
*
|
||||
* @param txtId
|
||||
*/
|
||||
public void setMessage(int txtId) {
|
||||
String txt = context.getResources().getString(txtId);
|
||||
TextView tv = (TextView) findViewById(R.id.tv_content);
|
||||
tv.setText(txt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置中间显示的内容
|
||||
*/
|
||||
public void setMiddleView(View view) {
|
||||
RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl_content_view);
|
||||
rl.removeAllViews();
|
||||
if (view != null)
|
||||
rl.addView(view);
|
||||
}
|
||||
|
||||
public void setMiddleViewMatch(View view) {
|
||||
RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl_content_view);
|
||||
rl.removeAllViews();
|
||||
if (view != null)
|
||||
rl.addView(view, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
}
|
||||
|
||||
public void removeMideView() {
|
||||
RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl_content_view);
|
||||
rl.removeAllViews();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置中间显示的内容
|
||||
*/
|
||||
public View setMiddleView(int id) {
|
||||
RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl_content_view);
|
||||
rl.removeAllViews();
|
||||
View inflate = View.inflate(getContext(), id, rl);
|
||||
return rl.getChildAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定按钮 点击事件
|
||||
*
|
||||
* @param click
|
||||
*/
|
||||
public Dialog setConfirmListener(OnClickListener click) {
|
||||
return setPositiveButton(mPositiveButtonText, click);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮 点击事件
|
||||
*
|
||||
* @param click
|
||||
*/
|
||||
public Dialog setCancelListener(OnClickListener click) {
|
||||
return setNegativeButton(mNegativeButtonText, click);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮 点击事件
|
||||
*
|
||||
* @param click
|
||||
*/
|
||||
public Dialog setMiddleListener(OnClickListener click) {
|
||||
return setMiddleButton(mMiddleButtonText, click);
|
||||
}
|
||||
|
||||
/**
|
||||
* 中间按钮 是否可点
|
||||
*
|
||||
* @param bl
|
||||
*/
|
||||
public void setMiddleButtonIsCanClick(Boolean bl) {
|
||||
TextView btn_fm_confirm = (TextView) findViewById(R.id.btn_fm_middle);
|
||||
btn_fm_confirm.setEnabled(bl);
|
||||
}
|
||||
|
||||
public Dialog setMiddleButton(CharSequence text, OnClickListener listener) {
|
||||
mMiddleButtonText = text;
|
||||
mMiddleButtonListener = listener;
|
||||
setMiddle(text);
|
||||
findViewById(R.id.middle_view).setVisibility(View.VISIBLE);
|
||||
TextView btn_fm_middle = (TextView) findViewById(R.id.btn_fm_middle);
|
||||
btn_fm_middle.setVisibility(View.VISIBLE);
|
||||
btn_fm_middle.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mMiddleButtonListener != null) {
|
||||
mMiddleButtonListener.onClick(FirstDialog.this, 3);
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public Dialog setMiddleButton(int txtId, final OnClickListener listener) {
|
||||
String text = context.getResources().getString(txtId);
|
||||
return setMiddleButton(text, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认按钮 是否可点
|
||||
*
|
||||
* @param bl
|
||||
*/
|
||||
public void setPositiveButtonIsCanClick(Boolean bl) {
|
||||
TextView btn_fm_confirm = (TextView) findViewById(R.id.btn_fm_confirm);
|
||||
btn_fm_confirm.setEnabled(bl);
|
||||
}
|
||||
|
||||
public Dialog setPositiveButton(CharSequence text, OnClickListener listener) {
|
||||
mPositiveButtonText = text;
|
||||
mPositiveButtonListener = listener;
|
||||
setConfirm(text);
|
||||
findViewById(R.id.btn_fm_confirm).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mPositiveButtonListener != null) {
|
||||
mPositiveButtonListener.onClick(FirstDialog.this, 2);
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
//如果设置了确定或取消按钮,则不允许点击其他区域隐藏对话框
|
||||
this.setCancelable(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Dialog setPositiveButton(int txtId, final OnClickListener listener) {
|
||||
String text = context.getResources().getString(txtId);
|
||||
return setPositiveButton(text, listener);
|
||||
}
|
||||
|
||||
public Dialog setNegativeButton(CharSequence text, OnClickListener listener) {
|
||||
mNegativeButtonText = text;
|
||||
mNegativeButtonListener = listener;
|
||||
setCancel(text);
|
||||
findViewById(R.id.btn_fm_cancel).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mNegativeButtonListener != null) {
|
||||
mNegativeButtonListener.onClick(FirstDialog.this, 1);
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
//如果设置了确定或取消按钮,则不允许点击其他区域隐藏对话框
|
||||
this.setCancelable(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Dialog setNegativeButton(int txtId, final OnClickListener listener) {
|
||||
String text = context.getResources().getString(txtId);
|
||||
return setNegativeButton(text, listener);
|
||||
}
|
||||
|
||||
public interface OnClickListener {
|
||||
/**
|
||||
* This method will be invoked when a button in the dialog is clicked.
|
||||
*
|
||||
* @param dialog The dialog that received the click.
|
||||
* @param which The button that was clicked (e.g.
|
||||
* {@link DialogInterface#BUTTON1}) or the position
|
||||
* of the item clicked.
|
||||
*/
|
||||
/* TODO: Change to use BUTTON_POSITIVE after API council */
|
||||
public void onClick(Dialog dialog, int which);
|
||||
}
|
||||
|
||||
private void showBottomView() {
|
||||
findViewById(R.id.v_divice).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.ll_bottom_btn).setVisibility(View.VISIBLE);
|
||||
//如果设置了确定或取消按钮,则不允许点击其他区域隐藏对话框
|
||||
this.setCancelable(false);
|
||||
}
|
||||
|
||||
|
||||
public void setNegativeView(int View) {
|
||||
findViewById(R.id.btn_fm_cancel).setVisibility(View);
|
||||
findViewById(R.id.view_dialog).setVisibility(View);
|
||||
}
|
||||
|
||||
public void setCancelVisibility(int isVisibility) {
|
||||
findViewById(R.id.btn_fm_cancel).setVisibility(isVisibility);
|
||||
}
|
||||
|
||||
public void setBottomLayoutVisibility(int isVisibility) {
|
||||
findViewById(R.id.ll_bottom_layout).setVisibility(isVisibility);
|
||||
}
|
||||
|
||||
public Object getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(Object tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public void setNegativeButtonEnable(boolean enable) {
|
||||
findViewById(R.id.btn_fm_cancel).setEnabled(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置北京资源
|
||||
*/
|
||||
public void setBackgroundColor(int res) {
|
||||
LinearLayout rl = (LinearLayout) findViewById(R.id.ll_dialog);
|
||||
if(rl!=null)
|
||||
rl.setBackgroundColor(res);
|
||||
}
|
||||
}
|
||||
34
app/src/main/java/com/navinfo/omqs/ui/dialog/IDialog.java
Normal file
34
app/src/main/java/com/navinfo/omqs/ui/dialog/IDialog.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.navinfo.omqs.ui.dialog;
|
||||
/**
|
||||
* @ClassName: Dialog.java
|
||||
* @author zcs
|
||||
* @version V1.0
|
||||
* @param <T>
|
||||
* @Date 2023年4月14日 上午10:15:44
|
||||
* @Description: 所有弹出框的父类
|
||||
*/
|
||||
public interface IDialog {
|
||||
|
||||
//void result(T t);
|
||||
//public <T> void result(T t);
|
||||
//public <T> void showData(T t);
|
||||
/**
|
||||
* 给弹出框赋值
|
||||
* @param str
|
||||
* @param obj
|
||||
*/
|
||||
public void setData(String str,Object obj);
|
||||
|
||||
/**
|
||||
* 给Diaolog传递的数据,显示时调用
|
||||
* @param obj
|
||||
*/
|
||||
public void request(Object obj);
|
||||
|
||||
/**
|
||||
* 获得数据
|
||||
* @return
|
||||
*/
|
||||
public Object getData();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.navinfo.omqs.ui.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.navinfo.omqs.R;
|
||||
|
||||
/**
|
||||
* @author zcs
|
||||
* @version V1.0
|
||||
* @ClassName: LoadingDialog.java
|
||||
* @Date 2015年9月17日 下午1:34:39
|
||||
* @Description: 弹出等待框
|
||||
*/
|
||||
public class LoadingDialog extends MyDialog {
|
||||
|
||||
private CharSequence text;
|
||||
|
||||
private View.OnClickListener textListener;
|
||||
|
||||
private TextView tv_msg;
|
||||
|
||||
public LoadingDialog(Context context) {
|
||||
|
||||
super(context);
|
||||
|
||||
// requestWindowFeature(Window.FEATURE_NO_TITLE);//不显示标题
|
||||
}
|
||||
|
||||
@Override
|
||||
public void request(Object obj) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
View customFrame = View.inflate(context, R.layout.dialog_loading_custom_frame_layout, null);
|
||||
|
||||
((AnimationDrawable) customFrame.findViewById(R.id.customFrameLoadImg).getBackground()).start();
|
||||
|
||||
tv_msg = (TextView) customFrame.findViewById(R.id.customFrameMsg);
|
||||
|
||||
tv_msg.setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE);
|
||||
|
||||
tv_msg.setText(TextUtils.isEmpty(text) ? "" : text);
|
||||
|
||||
tv_msg.setOnClickListener(textListener);
|
||||
|
||||
setContentView(customFrame);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置等待提示文字
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
public void setText(CharSequence text) {
|
||||
|
||||
this.text = text;
|
||||
if (tv_msg!=null){
|
||||
tv_msg.setVisibility(TextUtils.isEmpty(this.text) ? View.GONE : View.VISIBLE);
|
||||
tv_msg.setText(TextUtils.isEmpty(this.text) ? "" : this.text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置文本点击事件
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void setTextClickListener(View.OnClickListener listener){
|
||||
|
||||
this.textListener = listener;
|
||||
|
||||
if (tv_msg!=null){
|
||||
tv_msg.setOnClickListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
app/src/main/java/com/navinfo/omqs/ui/dialog/MyDialog.java
Normal file
92
app/src/main/java/com/navinfo/omqs/ui/dialog/MyDialog.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package com.navinfo.omqs.ui.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Window;
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
* @param <T>
|
||||
* @author qj
|
||||
* @version V1.0
|
||||
* @ClassName: MyDialog.java
|
||||
* @Date 2023年4月14日 上午10:18:52
|
||||
* @Description: 所有提示框的父类(在onCreate设置布局)
|
||||
*/
|
||||
public abstract class MyDialog extends Dialog implements IDialog {
|
||||
|
||||
protected Context context;
|
||||
|
||||
private Object obj;
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private String str;
|
||||
|
||||
public MyDialog(Context context) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);//不显示标题
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
|
||||
if (dataSource != null) {
|
||||
|
||||
dataSource.Data(str, obj);
|
||||
|
||||
}
|
||||
|
||||
super.dismiss();
|
||||
}
|
||||
|
||||
public void setWidthHeight(int width, int height) {
|
||||
getWindow().setLayout(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
|
||||
request(obj);
|
||||
|
||||
super.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String str, Object obj) {
|
||||
|
||||
this.str = str;
|
||||
|
||||
this.obj = obj;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData() {
|
||||
|
||||
return obj;
|
||||
|
||||
}
|
||||
|
||||
public void getResponse(DataSource dataSource) {
|
||||
|
||||
this.dataSource = dataSource;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置背景色
|
||||
*
|
||||
* @param drawable
|
||||
*/
|
||||
public void setBackground(Drawable drawable) {
|
||||
|
||||
getWindow().setBackgroundDrawable(drawable);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,578 @@
|
||||
package com.navinfo.omqs.ui.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.volley.VolleyError;
|
||||
import com.navinfo.collect.library.garminvirbxe.CameraEventListener;
|
||||
import com.navinfo.collect.library.garminvirbxe.CameraGarminVirbXE;
|
||||
import com.navinfo.collect.library.garminvirbxe.HostBean;
|
||||
import com.navinfo.collect.library.garminvirbxe.SensorParams;
|
||||
import com.navinfo.collect.library.sensor.ISensor.enmConnectionStatus;
|
||||
import com.navinfo.collect.library.sensor.ISensor.enmSensorModel;
|
||||
import com.navinfo.collect.library.sensor.ISensor.SensorWorkingMode;
|
||||
import com.navinfo.collect.library.sensor.ISensor.enmSensorType;
|
||||
import com.navinfo.collect.library.sensor.ISensor.enmSignalQuality;
|
||||
import com.navinfo.collect.library.sensor.SensorManager;
|
||||
import com.navinfo.omqs.system.SystemConstant;
|
||||
import com.navinfo.omqs.util.ShareUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qj
|
||||
* @version V1.0
|
||||
* @Date 2023/4/14.
|
||||
* @Description: (外设相机控制类)
|
||||
*/
|
||||
public class TakePhotoManager {
|
||||
|
||||
/**
|
||||
* 拍照控制类集合
|
||||
*/
|
||||
private List<CameraGarminVirbXE> mSensorInstanceList;
|
||||
|
||||
/**
|
||||
* 拍照过程回调监听
|
||||
*/
|
||||
/**
|
||||
* 拍照管理类
|
||||
*/
|
||||
private static volatile TakePhotoManager mInstance;
|
||||
//外设相机连接状态
|
||||
private HashMap<String, enmConnectionStatus> mConnectionStatusHashMap;
|
||||
//上下文
|
||||
private Context mCon;
|
||||
|
||||
/**
|
||||
* 装拍照过程回调数组
|
||||
*/
|
||||
private final List<CameraEventListener> mOnCameraEventListeners = new ArrayList<CameraEventListener>();
|
||||
|
||||
public static TakePhotoManager getInstance() {
|
||||
if (mInstance == null) {
|
||||
synchronized (TakePhotoManager.class) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new TakePhotoManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
public void init(Context context, int cameraCount) {
|
||||
|
||||
mCon = context;
|
||||
|
||||
if (cameraCount == 0)
|
||||
cameraCount = 1;
|
||||
|
||||
mSensorInstanceList = new ArrayList<CameraGarminVirbXE>();
|
||||
|
||||
mConnectionStatusHashMap = new HashMap<String, enmConnectionStatus>();
|
||||
|
||||
CameraEventListener cameraEevent = new CameraEventListener() {
|
||||
@Override
|
||||
public void OnSnapPictureResponse(HostBean hostBean, Bitmap bitmap, String picName, int tag) {
|
||||
Log.i("info", "bitmap:" + bitmap);
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnSnapPictureResponse(hostBean, bitmap, picName, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestError(HostBean hostBean, com.android.volley.VolleyError e, CameraGarminVirbXE.enmCommandType commandType, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.requestError(hostBean, e, commandType, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnStartRecordResponse(HostBean hostBean, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnStartRecordResponse(hostBean, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnStopRecordResponse(HostBean hostBean, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnStopRecordResponse(hostBean, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnStatusResponse(HostBean hostBean, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnStatusResponse(hostBean, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnSearchResponse(int tag, ArrayList<HostBean> scanIpList) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnSearchResponse(tag, scanIpList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnConnectStatusChanged(HostBean hostBean, enmConnectionStatus connectStatus, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnConnectStatusChanged(hostBean, connectStatus, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnGetGpsStatusResponse(HostBean hostBean, boolean status, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnGetGpsStatusResponse(hostBean, status, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnConnectionStatusChanged(HostBean hostBean, enmConnectionStatus cs, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnConnectionStatusChanged(hostBean, cs, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnContinuousPhototTimeLapseRateResponse(HostBean hostBean, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnContinuousPhototTimeLapseRateResponse(hostBean, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnContinuousPhototTimeLapseRateStartResponse(HostBean hostBean, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnContinuousPhototTimeLapseRateStartResponse(hostBean, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnContinuousPhototTimeLapseRateStopResponse(HostBean hostBean, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnContinuousPhototTimeLapseRateStopResponse(hostBean, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnContinuousPhototSingle(HostBean hostBean, String url, String name, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnContinuousPhototSingle(hostBean, url, name, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnGetMediaList(HostBean hostBean, String json, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnGetMediaList(hostBean, json, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnSensorEvent() {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnSensorEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnConnectionStatusChanged(enmConnectionStatus cs) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnConnectionStatusChanged(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnGetDeviceInfo(HostBean hostBean, String devicesId, int tag) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnGetDeviceInfo(hostBean, devicesId, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnSignalQualityChanged(enmSignalQuality sq) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null) {
|
||||
weakRef.OnSignalQualityChanged(sq);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < cameraCount; i++) {
|
||||
|
||||
CameraGarminVirbXE clent = (CameraGarminVirbXE) SensorManager.getInstance().CreateSensor(context, enmSensorType.SENSOR_CAMEAR, enmSensorModel.CAMERA_GARMIN_VIRB_XE);
|
||||
clent.setmTag(i + 1);
|
||||
clent.RegisterSensorEvent(cameraEevent);
|
||||
mSensorInstanceList.add(clent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//连接网络
|
||||
public boolean connect(int indexClent, HostBean hostBean, SensorParams params) {
|
||||
if (hostBean != null) {
|
||||
CameraGarminVirbXE cameraGarminVirbXE = getCameraVedioClent(indexClent);
|
||||
if (cameraGarminVirbXE != null) {
|
||||
cameraGarminVirbXE.Connect(hostBean, params);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public enmConnectionStatus getConnectionStatus(HostBean hostBean) {
|
||||
|
||||
if (hostBean != null && mConnectionStatusHashMap != null && mConnectionStatusHashMap.containsKey(hostBean.hardwareAddress)) {
|
||||
return mConnectionStatusHashMap.get(hostBean.hardwareAddress);
|
||||
}
|
||||
|
||||
|
||||
return enmConnectionStatus.DISCONNECTTED;
|
||||
}
|
||||
|
||||
public enmConnectionStatus getConnectionStatus() {
|
||||
|
||||
if (mSensorInstanceList != null && mConnectionStatusHashMap != null) {
|
||||
enmConnectionStatus mEnmConnectionStatus = enmConnectionStatus.DISCONNECTTED;
|
||||
for (CameraGarminVirbXE cameraGarminVirbXE : mSensorInstanceList) {
|
||||
mEnmConnectionStatus = cameraGarminVirbXE.GetConnectionStatus();
|
||||
if (mEnmConnectionStatus == enmConnectionStatus.CONNECTTED)
|
||||
return enmConnectionStatus.CONNECTTED;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return enmConnectionStatus.DISCONNECTTED;
|
||||
}
|
||||
|
||||
//设置相机模式
|
||||
public void setCameraMode(int indexClent, SensorWorkingMode mode) {
|
||||
if (indexClent > 0 && mSensorInstanceList!=null && indexClent <= mSensorInstanceList.size()) {
|
||||
getCameraVedioClent(indexClent).SetMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
//获取当前相机模式
|
||||
public SensorWorkingMode getCameraMode(int indexClent) {
|
||||
if (mSensorInstanceList != null && indexClent > 0 && indexClent <= mSensorInstanceList.size()) {
|
||||
return getCameraVedioClent(indexClent).GetMode();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String mediaList(int indexClent, String path) {
|
||||
if (mSensorInstanceList != null && indexClent > 0 && indexClent <= mSensorInstanceList.size()) {
|
||||
getCameraVedioClent(indexClent).mediaList(path);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//搜索网络
|
||||
public void SearchNet(HostBean hostBean, int indexClent, boolean isReadCache) {
|
||||
if (mSensorInstanceList != null && mSensorInstanceList.size() > 0 && indexClent > 0 && indexClent <= mSensorInstanceList.size()) {
|
||||
mSensorInstanceList.get(indexClent - 1).Search(isReadCache);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//连续拍照
|
||||
public void StartRecording(HostBean hostBean, int indexCamera) {
|
||||
if (mSensorInstanceList != null && indexCamera > 0 && indexCamera <= mSensorInstanceList.size()) {
|
||||
getCameraVedioClent(indexCamera).StartRecording();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void getGpsStatus() {
|
||||
if (mSensorInstanceList != null && mSensorInstanceList.size() > 0) {
|
||||
for (CameraGarminVirbXE cameraGarminVirbXE : mSensorInstanceList) {
|
||||
cameraGarminVirbXE.GetGpsStatus();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//获取GPS状态
|
||||
public void getGpsStatus(HostBean hostBean, int index) {
|
||||
if (hostBean != null) {
|
||||
CameraGarminVirbXE cameraGarminVirbXE = findCameraGarminVirbXE(hostBean, index);
|
||||
if (cameraGarminVirbXE != null) {
|
||||
cameraGarminVirbXE.GetGpsStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startCameraVedio(HostBean hostBean, int indexClent) {
|
||||
if (hostBean != null) {
|
||||
|
||||
StopContinuousTakePhoto(hostBean, indexClent);
|
||||
|
||||
setCameraMode(indexClent, SensorWorkingMode.CAMERA_VEDIO_TIMELAPSE);
|
||||
|
||||
ShareUtil.getCameraMode(mCon).setContinusTakePhotoState(SystemConstant.USER_ID, false);
|
||||
|
||||
StartRecording(hostBean, indexClent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//抓拍
|
||||
public void SnapShot(HostBean hostBean, int index) {
|
||||
if (hostBean != null) {
|
||||
CameraGarminVirbXE cameraGarminVirbXE = findCameraGarminVirbXE(hostBean, index);
|
||||
if (cameraGarminVirbXE != null) {
|
||||
cameraGarminVirbXE.snapPicture(SystemConstant.getUuid(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Long getGoogleTime() {
|
||||
if (mSensorInstanceList != null && mSensorInstanceList.size() > 0) {
|
||||
for (CameraGarminVirbXE cameraGarminVirbXE : mSensorInstanceList) {
|
||||
if (cameraGarminVirbXE.getGoogleGpsTime() > 0) {
|
||||
return cameraGarminVirbXE.getGoogleGpsTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0l;
|
||||
}
|
||||
|
||||
//停止时间线程,减少电量消耗
|
||||
public void stopTimeThread() {
|
||||
if (mSensorInstanceList != null && mSensorInstanceList.size() > 0) {
|
||||
for (CameraGarminVirbXE cameraGarminVirbXE : mSensorInstanceList) {
|
||||
cameraGarminVirbXE.stopTimeThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//设置拍照路径
|
||||
public void setSavePath(HostBean hostBean, String path, int index) {
|
||||
if (path == null || path.equals("")) {
|
||||
return;
|
||||
|
||||
}
|
||||
if (hostBean != null) {
|
||||
CameraGarminVirbXE cameraGarminVirbXE = findCameraGarminVirbXE(hostBean, index);
|
||||
if (cameraGarminVirbXE != null) {
|
||||
File file = new File(path);
|
||||
if (file.exists() && file.isDirectory()) {
|
||||
cameraGarminVirbXE.SetCameraPictureSavaPath(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//停止搜索
|
||||
public void StopSearchNet(HostBean hostBean, int indexClent) {
|
||||
if (hostBean != null) {
|
||||
CameraGarminVirbXE cameraGarminVirbXE = findCameraGarminVirbXE(hostBean, indexClent);
|
||||
if (cameraGarminVirbXE != null) {
|
||||
cameraGarminVirbXE.StopSearch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//停止连拍
|
||||
public void StopContinuousTakePhoto(HostBean hostBean, int indexCamera) {
|
||||
if (mSensorInstanceList != null && indexCamera > 0 && indexCamera <= mSensorInstanceList.size()) {
|
||||
getCameraVedioClent(indexCamera).StopRecording();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//停止所有相机
|
||||
public void StopContinuousTakePhotoAll() {
|
||||
if (mSensorInstanceList != null) {
|
||||
for (CameraGarminVirbXE cameraGarminVirbXE : mSensorInstanceList) {
|
||||
cameraGarminVirbXE.StopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//查找对应控制类
|
||||
private CameraGarminVirbXE findCameraGarminVirbXE(HostBean hostBean, int index) {
|
||||
|
||||
if (mSensorInstanceList != null && mSensorInstanceList.size() > 0) {
|
||||
|
||||
for (CameraGarminVirbXE cameraGarminVirbXE : mSensorInstanceList) {
|
||||
if (cameraGarminVirbXE.getmHostBean() != null && hostBean != null && !TextUtils.isEmpty(cameraGarminVirbXE.getmHostBean().hardwareAddress)
|
||||
&& !TextUtils.isEmpty(hostBean.hardwareAddress) && cameraGarminVirbXE.getmHostBean().hardwareAddress.equalsIgnoreCase(hostBean.hardwareAddress) && cameraGarminVirbXE.getmTag() == index) {
|
||||
return cameraGarminVirbXE;
|
||||
}
|
||||
}
|
||||
|
||||
return mSensorInstanceList.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void setOnCameraEventChangeListener(CameraEventListener listener) {
|
||||
synchronized (mOnCameraEventListeners) {
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (CameraEventListener weakRef : mOnCameraEventListeners) {
|
||||
if (weakRef != null
|
||||
&& weakRef == listener) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
mOnCameraEventListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCameraEventListener(HostBean hostBean, CameraEventListener listener) {
|
||||
synchronized (mOnCameraEventListeners) {
|
||||
CameraEventListener weakRef;
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (int idx = 0; idx < mOnCameraEventListeners.size(); idx++) {
|
||||
if ((weakRef = mOnCameraEventListeners.get(idx)) != null) {
|
||||
if (weakRef == listener) {
|
||||
mOnCameraEventListeners.remove(idx);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
mOnCameraEventListeners.remove(idx);
|
||||
idx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCameraEventListenerAll(CameraEventListener listener) {
|
||||
synchronized (mOnCameraEventListeners) {
|
||||
CameraEventListener weakRef;
|
||||
if (mOnCameraEventListeners != null && mOnCameraEventListeners.size() > 0) {
|
||||
for (int idx = 0; idx < mOnCameraEventListeners.size(); idx++) {
|
||||
if ((weakRef = mOnCameraEventListeners.get(idx)) != null) {
|
||||
if (weakRef == listener) {
|
||||
mOnCameraEventListeners.remove(idx);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
mOnCameraEventListeners.remove(idx);
|
||||
idx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//根据拍照模式获取控制类
|
||||
public CameraGarminVirbXE getCameraVedioClent(SensorWorkingMode mode) {
|
||||
|
||||
if (mode == null)
|
||||
return null;
|
||||
|
||||
if (mSensorInstanceList != null && mSensorInstanceList.size() > 0) {
|
||||
for (CameraGarminVirbXE cameraGarminVirbXE : mSensorInstanceList) {
|
||||
if (cameraGarminVirbXE.GetMode() != null && cameraGarminVirbXE.GetMode() == mode) {
|
||||
return cameraGarminVirbXE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CameraGarminVirbXE getCameraVedioClent(int indexClent) {
|
||||
|
||||
if (indexClent <= 0)
|
||||
return null;
|
||||
|
||||
if (mSensorInstanceList != null && mSensorInstanceList.size() > 0 && indexClent <= mSensorInstanceList.size()) {
|
||||
return mSensorInstanceList.get(indexClent - 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
77
app/src/main/java/com/navinfo/omqs/ui/other/BaseToast.java
Normal file
77
app/src/main/java/com/navinfo/omqs/ui/other/BaseToast.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package com.navinfo.omqs.ui.other;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import com.navinfo.omqs.R;
|
||||
|
||||
/**
|
||||
* 在屏幕中间出现toast提示
|
||||
*/
|
||||
public class BaseToast extends Toast{
|
||||
final Context mContext;
|
||||
|
||||
private static int height;
|
||||
static Toast result;
|
||||
public BaseToast(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
// 获取屏幕信息
|
||||
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
|
||||
height = dm.heightPixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 屏幕中间显示toast
|
||||
* @param context
|
||||
* @param text 显示内容
|
||||
* @param duration 显示时长
|
||||
* @return
|
||||
*/
|
||||
public static Toast makeText(Context context, CharSequence text, int duration) {
|
||||
try{
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
height = dm.heightPixels;
|
||||
result =result==null? new Toast(context):result;
|
||||
LayoutInflater inflate = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View v = inflate.inflate(R.layout.transient_notification, null);
|
||||
TextView tv = (TextView) v.findViewById(android.R.id.message);
|
||||
tv.setText(text);
|
||||
result.setView(v);
|
||||
if(duration<Toast.LENGTH_SHORT)
|
||||
duration = Toast.LENGTH_SHORT;
|
||||
result.setDuration(duration);
|
||||
result.setGravity(Gravity.CENTER, 0, height/6);
|
||||
}catch (Exception e){
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 屏幕中心显示toast
|
||||
* @param context
|
||||
* @param resId 文字资源id
|
||||
* @param duration 显示时长
|
||||
* @return
|
||||
* @throws Resources.NotFoundException
|
||||
*/
|
||||
public static Toast makeText(Context context, int resId, int duration)
|
||||
throws Resources.NotFoundException {
|
||||
return makeText(context, context.getResources().getText(resId),
|
||||
duration);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user