Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
p x
MapMultiEngine
Commits
b785e7cb
Commit
b785e7cb
authored
Jun 24, 2025
by
p x
Browse files
四维搜索
parent
0665639d
Changes
54
Expand all
Show whitespace changes
Inline
Side-by-side
maplibrary/src/main/java/com/sd/maplibrary/ui/view/CleanableEditText.java
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.ui.view
;
import
android.content.Context
;
import
android.graphics.drawable.Drawable
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.util.AttributeSet
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
androidx.appcompat.widget.AppCompatEditText
;
/**
* @author Administrator
* 在焦点变化时和输入内容发生变化时均要判断是否显示右边clean图标
*/
public
class
CleanableEditText
extends
AppCompatEditText
{
private
Drawable
mRightDrawable
;
private
boolean
isHasFocus
;
public
CleanableEditText
(
Context
context
)
{
super
(
context
);
init
();
}
public
CleanableEditText
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
();
}
public
CleanableEditText
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
init
();
}
private
void
init
()
{
// getCompoundDrawables:
// Returns drawables for the left, top, right, and bottom borders.
Drawable
[]
drawables
=
this
.
getCompoundDrawables
();
// 取得right位置的Drawable
// 即我们在布局文件中设置的android:drawableRight
mRightDrawable
=
drawables
[
2
];
// mRightDrawable.setBounds(0,0,25,25);
// 设置焦点变化的监听
this
.
setOnFocusChangeListener
(
new
FocusChangeListenerImpl
());
// 设置EditText文字变化的监听
this
.
addTextChangedListener
(
new
TextWatcherImpl
());
// 初始化时让右边clean图标不可见
setClearDrawableVisible
(
false
);
}
/**
* 当手指抬起的位置在clean的图标的区域 我们将此视为进行清除操作 getWidth():得到控件的宽度
* event.getX():抬起时的坐标(改坐标是相对于控件本身而言的)
* getTotalPaddingRight():clean的图标左边缘至控件右边缘的距离
* getPaddingRight():clean的图标右边缘至控件右边缘的距离 于是: getWidth() -
* getTotalPaddingRight()表示: 控件左边到clean的图标左边缘的区域 getWidth() -
* getPaddingRight()表示: 控件左边到clean的图标右边缘的区域 所以这两者之间的区域刚好是clean的图标的区域
*/
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_UP
:
boolean
isClean
=
(
event
.
getX
()
>
(
getWidth
()
-
getTotalPaddingRight
()))
&&
(
event
.
getX
()
<
(
getWidth
()
-
getPaddingRight
()));
if
(
isClean
)
{
setText
(
""
);
}
break
;
default
:
break
;
}
return
super
.
onTouchEvent
(
event
);
}
private
class
FocusChangeListenerImpl
implements
OnFocusChangeListener
{
@Override
public
void
onFocusChange
(
View
v
,
boolean
hasFocus
)
{
isHasFocus
=
hasFocus
;
if
(
isHasFocus
)
{
boolean
isVisible
=
getText
().
toString
().
length
()
>=
1
;
setClearDrawableVisible
(
isVisible
);
}
else
{
setClearDrawableVisible
(
false
);
}
}
}
// 当输入结束后判断是否显示右边clean的图标
private
class
TextWatcherImpl
implements
TextWatcher
{
@Override
public
void
afterTextChanged
(
Editable
s
)
{
boolean
isVisible
=
getText
().
toString
().
length
()
>=
1
;
setClearDrawableVisible
(
isVisible
);
}
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
}
}
// 隐藏或者显示右边clean的图标
protected
void
setClearDrawableVisible
(
boolean
isVisible
)
{
Drawable
rightDrawable
;
if
(
isVisible
)
{
rightDrawable
=
mRightDrawable
;
}
else
{
rightDrawable
=
null
;
}
// 使用代码设置该控件left, top, right, and bottom处的图标
setCompoundDrawables
(
getCompoundDrawables
()[
0
],
getCompoundDrawables
()[
1
],
rightDrawable
,
getCompoundDrawables
()[
3
]);
}
}
maplibrary/src/main/java/com/sd/maplibrary/ui/view/ForeMapView.kt
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.ui.view
import
android.content.Context
import
android.graphics.Rect
import
android.util.AttributeSet
import
com.minedata.minenavi.map.MapView
import
com.minedata.minenavi.map.MineMap
import
com.minedata.minenavi.map.TrafficEventInfo
import
com.minedata.minenavi.mapdal.InitializationException
import
javax.microedition.khronos.egl.EGLConfig
import
javax.microedition.khronos.opengles.GL10
/***四维地图**/
class
ForeMapView
:
MapView
{
constructor
(
context
:
Context
?)
:
super
(
context
)
constructor
(
context
:
Context
?,
attrs
:
AttributeSet
?)
:
super
(
context
,
attrs
)
interface
Listener
{
fun
onCameraChanged
(
changeType
:
Int
)
fun
onTrafficEventIconClicked
(
type
:
Int
,
trafficEventInfo
:
TrafficEventInfo
?)
fun
onScrollStarted
()
fun
onScrollFinished
()
}
private
val
mListeners
=
arrayListOf
<
ForeMapView
.
Listener
>()
fun
addListener
(
listener
:
Listener
)
{
mListeners
.
add
(
listener
)
}
override
fun
onSurfaceCreated
(
gl10
:
GL10
?,
eglConfig
:
EGLConfig
?)
{
super
.
onSurfaceCreated
(
gl10
,
eglConfig
)
}
override
fun
onSurfaceChanged
(
gl
:
GL10
?,
width
:
Int
,
height
:
Int
)
{
super
.
onSurfaceChanged
(
gl
,
width
,
height
)
}
override
fun
onCameraChanged
(
changeType
:
Int
)
{
super
.
onCameraChanged
(
changeType
)
for
(
listener
in
mListeners
)
{
listener
.
onCameraChanged
(
changeType
)
}
}
override
fun
onTrafficEventIconClicked
(
type
:
Int
,
trafficEventInfo
:
TrafficEventInfo
?)
{
super
.
onTrafficEventIconClicked
(
type
,
trafficEventInfo
)
for
(
listener
in
mListeners
)
{
listener
.
onTrafficEventIconClicked
(
type
,
trafficEventInfo
)
}
}
override
fun
onScrollStarted
()
{
super
.
onScrollStarted
()
for
(
listener
in
mListeners
)
{
listener
.
onScrollStarted
()
}
}
override
fun
onScrollFinished
(
isScroll
:
Boolean
)
{
super
.
onScrollFinished
(
isScroll
)
for
(
listener
in
mListeners
)
{
listener
.
onScrollFinished
()
}
}
override
fun
createMineMap
(
rct
:
Rect
?,
listener
:
MineMap
.
Listener
?):
MineMap
?
{
try
{
return
MineMap
(
context
,
listener
,
true
)
}
catch
(
e
:
InitializationException
)
{
e
.
printStackTrace
()
}
return
null
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/utils/DisplayUtil.kt
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.utils
import
android.app.Activity
import
android.content.Context
import
android.content.res.Configuration
import
android.content.res.Resources
import
android.os.Build
import
android.provider.Settings
import
android.util.DisplayMetrics
import
android.util.TypedValue
import
android.view.View
import
android.view.View.MeasureSpec
/**
*author:pc-20171125
*data:2019/11/7 16:08
*/
object
DisplayUtil
{
fun
getDpi
():
Int
{
return
Resources
.
getSystem
().
displayMetrics
.
densityDpi
}
fun
px2dp
(
pxValue
:
Float
):
Int
{
val
scale
=
Resources
.
getSystem
().
displayMetrics
.
density
return
(
pxValue
/
scale
+
0.5f
).
toInt
()
}
fun
dp2px
(
dipValue
:
Float
):
Int
{
val
scale
=
Resources
.
getSystem
().
displayMetrics
.
density
return
(
dipValue
*
scale
+
0.5f
).
toInt
()
}
fun
px2sp
(
pxValue
:
Float
):
Int
{
val
fontScale
=
Resources
.
getSystem
().
displayMetrics
.
scaledDensity
return
(
pxValue
/
fontScale
+
0.5f
).
toInt
()
}
fun
sp2px
(
spValue
:
Float
):
Int
{
val
fontScale
=
Resources
.
getSystem
().
displayMetrics
.
scaledDensity
return
(
spValue
*
fontScale
+
0.5f
).
toInt
()
}
fun
getScreenWidthDp
():
Int
{
val
displayMetrics
=
Resources
.
getSystem
().
displayMetrics
val
widthPixels
=
displayMetrics
.
widthPixels
val
density
=
displayMetrics
.
density
return
Math
.
round
(
widthPixels
/
density
)
}
fun
getScreenWidthPx
():
Int
{
val
displayMetrics
=
Resources
.
getSystem
().
displayMetrics
return
displayMetrics
.
widthPixels
}
fun
getScreenHeightDp
():
Int
{
val
displayMetrics
=
Resources
.
getSystem
().
displayMetrics
val
heightPixels
=
displayMetrics
.
heightPixels
val
density
=
displayMetrics
.
density
return
Math
.
round
(
heightPixels
/
density
)
}
fun
getScreenHeightPx
():
Int
{
val
displayMetrics
=
Resources
.
getSystem
().
displayMetrics
return
displayMetrics
.
heightPixels
}
fun
forceMeasure
(
view
:
View
)
{
val
widthMeasureSpec
=
MeasureSpec
.
makeMeasureSpec
(
0
,
MeasureSpec
.
UNSPECIFIED
)
val
heightMeasureSpec
=
MeasureSpec
.
makeMeasureSpec
(
0
,
MeasureSpec
.
UNSPECIFIED
)
view
.
measure
(
widthMeasureSpec
,
heightMeasureSpec
)
}
private
val
mTmpValue
=
TypedValue
()
fun
getXmlDef
(
context
:
Context
,
id
:
Int
):
Int
{
synchronized
(
mTmpValue
)
{
val
value
:
TypedValue
=
mTmpValue
context
.
resources
.
getValue
(
id
,
value
,
true
)
return
TypedValue
.
complexToFloat
(
value
.
data
).
toInt
()
}
}
fun
getNavigationBarHeight
(
context
:
Context
):
Int
{
val
mInPortrait
=
context
.
resources
.
configuration
.
orientation
==
Configuration
.
ORIENTATION_PORTRAIT
val
result
=
0
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
ICE_CREAM_SANDWICH
)
{
if
(
hasNavBar
(
context
as
Activity
))
{
val
key
:
String
if
(
mInPortrait
)
{
key
=
"navigation_bar_height"
}
else
{
key
=
"navigation_bar_height_landscape"
}
return
getInternalDimensionSize
(
context
,
key
)
}
}
return
result
}
private
fun
hasNavBar
(
activity
:
Activity
):
Boolean
{
//判断小米手机是否开启了全面屏,开启了,直接返回false
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
if
(
Settings
.
Global
.
getInt
(
activity
.
contentResolver
,
"force_fsg_nav_bar"
,
0
)
!=
0
)
{
return
false
}
}
//其他手机根据屏幕真实高度与显示高度是否相同来判断
val
windowManager
=
activity
.
windowManager
val
d
=
windowManager
.
defaultDisplay
val
realDisplayMetrics
=
DisplayMetrics
()
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
d
.
getRealMetrics
(
realDisplayMetrics
)
}
val
realHeight
=
realDisplayMetrics
.
heightPixels
val
realWidth
=
realDisplayMetrics
.
widthPixels
val
displayMetrics
=
DisplayMetrics
()
d
.
getMetrics
(
displayMetrics
)
val
displayHeight
=
displayMetrics
.
heightPixels
val
displayWidth
=
displayMetrics
.
widthPixels
return
realWidth
-
displayWidth
>
0
||
realHeight
-
displayHeight
>
0
}
private
fun
getInternalDimensionSize
(
context
:
Context
,
key
:
String
):
Int
{
var
result
=
0
try
{
val
resourceId
=
context
.
resources
.
getIdentifier
(
key
,
"dimen"
,
"android"
)
if
(
resourceId
>
0
)
{
result
=
Math
.
round
(
context
.
resources
.
getDimensionPixelSize
(
resourceId
)
*
Resources
.
getSystem
().
displayMetrics
.
density
/
context
.
resources
.
displayMetrics
.
density
)
}
}
catch
(
ignored
:
Resources
.
NotFoundException
)
{
return
0
}
return
result
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/utils/MyContants.kt
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.utils
object
MyContants
{
const
val
IS_DEBUG
=
true
var
HOST
=
if
(
IS_DEBUG
)
"http://laravel.suiyigou.shop/"
else
"https://api.suixinsuiyi.cn/"
var
PORT
=
if
(
IS_DEBUG
)
"123"
else
"34534"
var
SOCKET_HOSTNAME
=
if
(
IS_DEBUG
)
"192.168.60.77"
else
""
var
SOCKET_RECEIVE_PORT
=
if
(
IS_DEBUG
)
8082
else
0
const
val
PERMISSON_REQUESTCODE
:
Int
=
10
const
val
online
=
true
/**
* 智旅APK传智*/
const
val
LAT_LNG_INFO
=
"LAT_LNG_INFO"
/***当前速度***/
var
CUR_SPEED
=
0f
const
val
MOCK_LAT
=
39.9129
const
val
MOCK_LNG
=
116.3723
// var CUR_LAT = MOCK_LAT
// var CUR_LNG = MOCK_LNG
var
CUR_LAT
=
0.0
var
CUR_LNG
=
0.0
// const val MOCK_LAT = 39.56
// const val MOCK_LNG = 116.20
// 116.372641,39.913242
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/utils/MyGeoTools.kt
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.utils
import
android.location.Location
import
com.minedata.minenavi.addons.DistanceBean
object
MyGeoTools
{
/**
* 计算我的位置到目标的直线距离
*/
fun
cauMyLocDistance
(
lat
:
Double
,
lng
:
Double
):
DistanceBean
{
var
mUtils
=
Utils
()
var
results
=
FloatArray
(
1
)
Location
.
distanceBetween
(
MyContants
.
CUR_LAT
,
MyContants
.
CUR_LNG
,
lat
,
lng
,
results
)
var
distanceInMeters
=
results
[
0
]
val
distanceBean
:
DistanceBean
=
mUtils
.
formatDistance
(
distanceInMeters
.
toInt
(),
false
)
return
distanceBean
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/utils/SystemUtils.kt
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.utils
import
android.app.Activity
import
android.app.ActivityManager
import
android.content.*
import
android.content.pm.PackageManager
import
android.net.Uri
import
android.os.Build
import
android.os.PowerManager
import
android.provider.Settings
import
android.telephony.TelephonyManager
import
android.view.View
import
android.view.WindowManager
import
android.view.inputmethod.InputMethodManager
import
android.widget.EditText
import
androidx.annotation.RequiresPermission
import
androidx.core.content.ContextCompat
import
androidx.core.content.FileProvider
import
java.io.File
object
SystemUtils
{
/**
* 调用系统打电话
*
* @param phone
*/
fun
callSystemTell
(
context
:
Context
,
phone
:
String
)
{
if
(!
phone
.
isNullOrEmpty
())
{
try
{
// var intent = Intent(Intent.ACTION_DIAL, phone.toUri())
var
intent
=
Intent
(
Intent
.
ACTION_DIAL
,
Uri
.
parse
(
"tel:$phone"
))
context
.
startActivity
(
intent
)
}
catch
(
e
:
ActivityNotFoundException
)
{
}
}
}
/**
* 获取当前应用程序的版本号
*/
fun
getAppVersionCode
(
context
:
Context
):
Int
{
var
version
=
0
try
{
version
=
context
.
packageManager
.
getPackageInfo
(
context
.
packageName
,
0
).
versionCode
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
throw
RuntimeException
(
context
.
javaClass
.
simpleName
+
"the application not found"
)
}
return
version
}
/**
* 获取当前应用程序的版本号
*/
fun
getAppVersionName
(
context
:
Context
):
String
{
var
version
=
"0"
try
{
version
=
context
.
packageManager
.
getPackageInfo
(
context
.
packageName
,
0
).
versionName
.
toString
()
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
throw
RuntimeException
(
"the application not found"
)
}
return
version
}
/**
* 关闭软键盘
*/
fun
closeKeyboard
(
et
:
EditText
,
context
:
Context
)
{
et
.
clearFocus
()
val
imm
=
ContextCompat
.
getSystemService
(
context
,
InputMethodManager
::
class
.
java
)
// 对于当前焦点的View
imm
?.
hideSoftInputFromWindow
(
et
.
windowToken
,
0
)
}
/**
* 打卡软键盘
*/
fun
showKeyboard
(
view
:
View
,
context
:
Context
)
{
view
.
isFocusable
=
true
view
.
requestFocus
()
val
imm
=
ContextCompat
.
getSystemService
(
context
,
InputMethodManager
::
class
.
java
)
imm
?.
showSoftInput
(
view
,
0
)
}
/**
* 适配华为安全键盘
*/
fun
etHuaWeiKeybroad
(
et
:
EditText
)
{
// if (MobileUtils.isEMUI() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
// with(et) {
// inputType =
// android.text.InputType.TYPE_CLASS_TEXT or android.text.InputType.TYPE_TEXT_VARIATION_NORMAL
// transformationMethod =
// android.text.method.PasswordTransformationMethod.getInstance()
// }
// }
}
fun
setStatusBarColor
(
activity
:
Activity
,
colorId
:
Int
)
{
val
window
=
activity
.
window
window
.
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_STATUS
)
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
)
window
.
statusBarColor
=
ContextCompat
.
getColor
(
activity
,
colorId
)
}
/**
* 通过上下文找到activity
*/
fun
findActivity
(
context
:
Context
):
Activity
?
{
if
(
context
is
Activity
)
{
return
context
}
return
if
(
context
is
ContextWrapper
)
{
val
wrapper
=
context
as
ContextWrapper
findActivity
(
wrapper
.
baseContext
)
}
else
{
null
}
}
@RequiresPermission
(
"android.permission.READ_PRIVILEGED_PHONE_STATE"
)
fun
getPhoneIMEI
(
context
:
Context
):
String
?
{
val
tm
=
ContextCompat
.
getSystemService
(
context
,
TelephonyManager
::
class
.
java
)
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
O
)
{
return
tm
?.
deviceId
}
else
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
Q
)
{
return
tm
?.
getImei
(
0
)
}
else
{
return
Settings
.
System
.
getString
(
context
.
contentResolver
,
Settings
.
Secure
.
ANDROID_ID
)
}
}
/**
* 复制文字到剪切板
*/
fun
copyTextClip
(
context
:
Context
,
text
:
String
)
{
// 得到剪贴板管理器
val
cmb
=
ContextCompat
.
getSystemService
(
context
,
ClipboardManager
::
class
.
java
)
var
clipData
=
ClipData
.
newPlainText
(
""
,
text
)
cmb
?.
setPrimaryClip
(
clipData
)
}
fun
exitApp
(
context
:
Context
)
{
// val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val
activityManager
=
ContextCompat
.
getSystemService
(
context
,
ActivityManager
::
class
.
java
)
val
appTaskList
=
activityManager
?.
appTasks
if
(
appTaskList
!=
null
)
{
for
(
appTask
in
appTaskList
)
{
appTask
.
finishAndRemoveTask
()
}
}
}
fun
openThridUrl
(
url
:
String
,
context
:
Context
)
{
var
myurl
=
url
if
(!
url
.
startsWith
(
"http://"
)
&&
!
url
.
startsWith
(
"https://"
))
{
myurl
=
"http://$url"
}
try
{
val
uri
=
Uri
.
parse
(
myurl
)
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
uri
)
context
.
startActivity
(
intent
)
}
catch
(
e
:
ActivityNotFoundException
)
{
// LogUtil.e("--------", "没找到Activity url=$url")
}
}
//android获取一个用于打开HTML文件的intent
fun
openHtmlFileIntent
(
urlParam
:
String
,
context
:
Context
)
{
val
intent
=
Intent
(
"android.intent.action.VIEW"
)
intent
.
addCategory
(
"android.intent.category.DEFAULT"
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
// val uri = Uri.fromFile(File(urlParam))
var
file
=
File
(
urlParam
)
var
uri
:
Uri
?
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
intent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
uri
=
FileProvider
.
getUriForFile
(
context
,
"com.zhaolaobao.fileProvider"
,
file
)
}
else
{
uri
=
Uri
.
fromFile
(
file
)
}
var
type
=
""
/* 取得扩展名 */
var
suffix
=
urlParam
.
substringAfterLast
(
"."
).
toLowerCase
()
println
(
"----url 后缀 = ${suffix}"
)
when
(
suffix
)
{
"pdf"
->
type
=
"application/pdf"
"ppt"
,
"pptx"
->
type
=
"application/vnd.ms-powerpoint"
// "pptx" -> type =
// "application/vnd.openxmlformats-officedocument.presentationml.presentation"
"doc"
->
type
=
"application/msword"
"docx"
->
type
=
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
"xls"
,
"xlsx"
->
type
=
"application/vnd.ms-excel"
"txt"
->
type
=
"text/plain"
else
->
type
=
"*/*"
}
intent
.
setDataAndType
(
uri
,
type
)
try
{
context
.
startActivity
(
intent
)
}
catch
(
e
:
ActivityNotFoundException
)
{
ToastHelper
.
showShort
(
context
,
"不支持打开"
)
}
}
/**
*跳转到应用外部打开
*/
fun
openFile
(
file
:
File
,
context
:
Context
)
{
var
intent
=
Intent
(
Intent
.
ACTION_VIEW
)
intent
.
addCategory
(
"android.intent.category.DEFAULT"
)
var
uri
:
Uri
?
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
intent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
)
uri
=
FileProvider
.
getUriForFile
(
context
,
"com.zhaolaobao.fileProvider"
,
file
)
}
else
{
uri
=
Uri
.
fromFile
(
file
)
}
var
type
=
""
/* 取得扩展名 */
var
end
=
file
.
name
.
substringAfterLast
(
"."
).
toLowerCase
()
when
(
end
)
{
"pdf"
->
type
=
"application/pdf"
"ppt"
->
type
=
"application/vnd.ms-powerpoint"
"pptx"
->
type
=
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
"doc"
->
type
=
"application/msword"
"docx"
->
type
=
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
"xls"
->
type
=
"application/vnd.ms-excel"
"xlsx"
->
type
=
"application/vnd.ms-excel"
"txt"
->
type
=
"text/plain"
else
->
type
=
"*/*"
}
intent
.
setDataAndType
(
uri
,
type
)
try
{
context
.
startActivity
(
intent
)
}
catch
(
e
:
ActivityNotFoundException
)
{
// context.toast("不支持打开")
}
}
/**
* 登录超时
*/
fun
timeOutLoginActivity
(
context
:
Context
)
{
context
.
startActivity
(
Intent
().
apply
{
// flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
action
=
"goLoginActivity"
putExtra
(
"is_login_timeout"
,
true
)
})
}
/**
* 账户禁用
*/
fun
accountDisLoginActivity
(
context
:
Context
)
{
context
.
startActivity
(
Intent
().
apply
{
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
or
Intent
.
FLAG_ACTIVITY_CLEAR_TASK
action
=
"goLoginActivity"
putExtra
(
"is_login_timeout"
,
false
)
})
}
/**
* 应用是否在电池白名单里
*/
fun
isIgnoringBatteryOptimizations
(
context
:
Context
):
Boolean
{
var
isIgnoring
=
false
val
powerManager
=
ContextCompat
.
getSystemService
(
context
,
PowerManager
::
class
.
java
)
if
(
powerManager
!=
null
)
{
isIgnoring
=
powerManager
.
isIgnoringBatteryOptimizations
(
context
.
packageName
)
}
return
isIgnoring
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/utils/Utils.java
0 → 100644
View file @
b785e7cb
This diff is collapsed.
Click to expand it.
maplibrary/src/main/java/com/sd/maplibrary/viewmodels/Ee.kt
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.viewmodels
import
androidx.lifecycle.ViewModel
import
androidx.lifecycle.viewModelScope
class
Ee
:
ViewModel
()
{
fun
sdsd
(){
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/viewmodels/FourMapOpVm.kt
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.viewmodels
import
android.annotation.SuppressLint
import
android.app.Application
import
android.os.Bundle
import
androidx.lifecycle.AndroidViewModel
import
androidx.lifecycle.LiveData
import
androidx.lifecycle.MutableLiveData
import
com.minedata.minenavi.location.MineLocation
import
com.minedata.minenavi.location.MineLocationListener
import
com.minedata.minenavi.location.MineLocationManager
import
com.minedata.minenavi.location.MineLocationOptions
import
com.minedata.minenavi.map.MineMap
import
com.minedata.minenavi.map.MyLocationStyle
import
com.minedata.minenavi.mapdal.CoordType
import
com.sd.maplibrary.bean.MyLocBean
import
com.sd.maplibrary.ui.view.ForeMapView
import
com.sd.maplibrary.utils.MyContants
/***四维地图操作类***/
class
FourMapOpVm
(
private
var
application
:
Application
)
:
AndroidViewModel
(
application
)
{
@SuppressLint
(
"StaticFieldLeak"
)
private
lateinit
var
mMapView
:
ForeMapView
private
lateinit
var
mMineMap
:
MineMap
private
var
mMyLocationStyle
:
MyLocationStyle
?
=
null
//我的定位信息
var
myLocBean
=
MutableLiveData
<
MyLocBean
>()
fun
init
(
foreMapView
:
ForeMapView
)
{
mMapView
=
foreMapView
MineLocationManager
.
getInstance
()
.
init
(
application
,
MineLocationManager
.
LocationSource
.
all
)
MineLocationManager
.
getInstance
().
addListener
(
mineLocationListener
)
mMapView
.
addMapRenderCallback
{
mineMap
:
MineMap
->
mMineMap
=
mineMap
mMineMap
.
minZoomLevel
=
0.0f
mMineMap
.
maxZoomLevel
=
17.0f
addMyLocationStyle
()
mOnMapViewListener
?.
onMapReady
()
}
}
private
fun
addMyLocationStyle
()
{
// 定位蓝点,默认使用内置定位
mMyLocationStyle
=
MyLocationStyle
()
// 使用外部传入位置信息
mMyLocationStyle
?.
myLocationType
(
MyLocationStyle
.
LOCATION_TYPE_LOCATE
)
// mMyLocationStyle.setPosition(point);
// mMyLocationStyle.orientAngle(30.0f);
// mMyLocationStyle.interval(2000);
mMyLocationStyle
?.
showMyLocation
(
true
)
mMyLocationStyle
?.
setClickable
(
true
)
mMineMap
.
setMyLocationStyle
(
mMyLocationStyle
)
}
/***
* 开启定位
*/
fun
starLoc
():
LiveData
<
MyLocBean
>
{
// 设置定位参数,并开始定位。
val
options
=
MineLocationOptions
()
options
.
setCoordType
(
CoordType
.
GCJ02
)
options
.
setGpsInterval
(
1000
);
//GPS定位更新时间,最小1000
options
.
setNetWorkInterval
(
3000
);
//WiFi定位更新时间,最小3000
options
.
setStationInterval
(
5000
);
//基站定位更新时间,最小500
MineLocationManager
.
getInstance
().
start
(
options
)
return
myLocBean
}
fun
stopLoc
()
{
MineLocationManager
.
getInstance
().
removeAllListener
()
MineLocationManager
.
getInstance
().
stop
()
MineLocationManager
.
getInstance
().
cleanup
()
}
////////////////////////////////////
////////////////////////////////////
////////////////////////////////////
var
mOnMapViewListener
:
OnMapViewListener
?
=
null
interface
OnMapViewListener
{
fun
onMapReady
()
fun
onswitchLocation
(
imageLevel
:
Int
)
}
private
var
mineLocationListener
=
object
:
MineLocationListener
{
override
fun
onSimLocationChanged
(
location
:
MineLocation
?)
{
var
a
=
0
}
override
fun
onLocationChanged
(
location
:
MineLocation
?)
{
println
(
"-------定位改变 = ${location?.latitude} curLng=${location?.longitude} speed=${location?.speed}"
)
// var df = DecimalFormat("#.00000000")
MyContants
.
CUR_LAT
=
location
?.
latitude
?:
0.0
MyContants
.
CUR_LNG
=
location
?.
longitude
?:
0.0
MyContants
.
CUR_SPEED
=
location
?.
speed
?:
0f
// MyPres.curLat = MyContants.CUR_LAT
// MyPres.curLng = MyContants.CUR_LNG
if
(
MyContants
.
CUR_SPEED
>
0f
)
{
// MyPres.curSpeed = MyContants.CUR_SPEED
}
var
myLoc
=
MyLocBean
().
apply
{
curLat
=
MyContants
.
CUR_LAT
curLng
=
MyContants
.
CUR_LNG
// curLat = MyContants.MOCK_LAT
// curLng = MyContants.MOCK_LNG
speed
=
MyContants
.
CUR_SPEED
}
// myLocBean.postValue(bean)
myLocBean
.
value
=
myLoc
}
override
fun
onStatusChanged
(
provider
:
String
?,
status
:
Int
,
extras
:
Bundle
?)
{
var
a
=
0
}
override
fun
onProviderEnabled
(
provider
:
String
?)
{
var
a
=
0
}
override
fun
onProviderDisabled
(
provider
:
String
?)
{
var
b
=
0
}
}
}
\ No newline at end of file
maplibrary/src/main/java/com/sd/maplibrary/viewmodels/SearchForeMapVm.kt
0 → 100644
View file @
b785e7cb
package
com.sd.maplibrary.viewmodels
import
android.annotation.SuppressLint
import
android.app.Application
import
android.content.Context
import
androidx.lifecycle.AndroidViewModel
import
androidx.lifecycle.LiveData
import
androidx.lifecycle.MutableLiveData
import
androidx.lifecycle.ViewModel
import
com.minedata.minenavi.mapdal.PoiItem
import
com.minedata.minenavi.poiquery.LatLonPoint
import
com.minedata.minenavi.poiquery.PoiResult
import
com.minedata.minenavi.poiquery.PoiSearch
import
com.minedata.minenavi.poiquery.SearchErrorCode
import
com.minedata.minenavi.poiquery.SortType
import
com.sd.maplibrary.bean.PoiSearchBean
import
com.sd.maplibrary.utils.MyContants
/***四维地图搜索相关***/
class
SearchForeMapVm
(
private
var
application
:
Application
)
:
AndroidViewModel
(
application
)
{
@SuppressLint
(
"StaticFieldLeak"
)
private
var
ctx
:
Context
?
=
null
private
var
poiSearch
:
PoiSearch
?
=
null
//搜索结果
var
poiSearchBean
=
MutableLiveData
<
List
<
PoiSearchBean
>>()
init
{
ctx
=
application
.
applicationContext
poiSearch
=
PoiSearch
(
ctx
)
poiSearch
?.
setOnPoiSearchListener
(
object
:
PoiSearch
.
OnPoiSearchListener
{
override
fun
onPoiItemSearched
(
poiItem
:
PoiItem
?,
errorCode
:
Int
)
{
var
a
=
0
}
override
fun
onPoiSearched
(
poiResult
:
PoiResult
?,
errorCode
:
Int
)
{
if
(
errorCode
==
SearchErrorCode
.
none
)
{
var
temps
=
poiResult
?.
getPois
()
var
poiList
=
temps
!!
.
map
{
pos
->
PoiSearchBean
().
apply
{
lat
=
pos
.
location
.
latitude
lng
=
pos
.
location
.
longitude
// title = "${pos.provinceName}${pos.cityName}${pos.district}${pos.title}"
title
=
pos
.
title
snippet
=
pos
.
snippet
cityName
=
pos
.
cityName
//这里为0 因为不是范围搜素
distance
=
pos
.
distance
adCode
=
pos
.
adCode
}
}
poiSearchBean
.
postValue
(
poiList
)
}
else
{
}
}
})
}
fun
getPoiList
(
str
:
String
,
curLat
:
Double
,
curLng
:
Double
):
LiveData
<
List
<
PoiSearchBean
>>
{
val
query
=
PoiSearch
.
Query
(
str
,
""
)
// 限制严格按照设置城市搜索
// query.setCityLimit(true)
// 设置查询位置点
if
(
curLat
!=
0.0
&&
curLng
!=
0.0
)
{
query
.
setLocation
(
LatLonPoint
(
curLat
,
curLng
))
}
// 设置排序方式为热度排序
query
.
setSortType
(
SortType
.
SORT_TYPE_HIT
)
// 返回父子关系
query
.
requireSubPois
(
false
)
// 设置查询每页的结果数目
query
.
setPageSize
(
10
)
poiSearch
?.
setQuery
(
query
)
// 开始搜索
poiSearch
?.
searchPOIAsyn
()
return
poiSearchBean
}
}
\ No newline at end of file
maplibrary/src/main/res/drawable-xhdpi/btn_change_normal.png
0 → 100644
View file @
b785e7cb
3.4 KB
maplibrary/src/main/res/drawable-xhdpi/btn_change_press.png
0 → 100644
View file @
b785e7cb
3.25 KB
maplibrary/src/main/res/drawable-xhdpi/edit_delete.png
0 → 100644
View file @
b785e7cb
563 Bytes
maplibrary/src/main/res/drawable-xhdpi/go_here.png
0 → 100644
View file @
b785e7cb
1.31 KB
maplibrary/src/main/res/drawable-xhdpi/icon_search.png
0 → 100644
View file @
b785e7cb
661 Bytes
maplibrary/src/main/res/drawable/btn_change_bg.xml
0 → 100644
View file @
b785e7cb
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@drawable/btn_change_press"
android:state_focused=
"true"
/>
<item
android:drawable=
"@drawable/btn_change_press"
android:state_pressed=
"true"
/>
<item
android:drawable=
"@drawable/btn_change_normal"
/>
</selector>
\ No newline at end of file
maplibrary/src/main/res/drawable/rect_white_10.xml
0 → 100644
View file @
b785e7cb
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<corners
android:radius=
"10dp"
/>
<solid
android:color=
"@color/white"
/>
</shape>
\ No newline at end of file
maplibrary/src/main/res/layout/activity_search.xml
0 → 100644
View file @
b785e7cb
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<data>
</data>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<include
android:id=
"@+id/r_input_layout"
layout=
"@layout/route_input_view"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/poi_list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginTop=
"5dp"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
/>
</LinearLayout>
</layout>
\ No newline at end of file
maplibrary/src/main/res/layout/fragment_a_map.xml
0 → 100644
View file @
b785e7cb
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".fragments.AMapFragment"
>
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:text=
"@string/hello_blank_fragment"
/>
</FrameLayout>
\ No newline at end of file
maplibrary/src/main/res/layout/fragment_fore_map.xml
0 → 100644
View file @
b785e7cb
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
</data>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".fragments.ForeMapFragment"
>
<!-- smallView="true"-->
<!-- smallViewBottom="10"-->
<!-- smallViewEnableEvent="true"-->
<!-- smallViewLeft="0"-->
<!-- smallViewRight="10"-->
<!-- smallViewTop="0"-->
<com.sd.maplibrary.ui.view.ForeMapView
android:id=
"@+id/mapView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<include
android:id=
"@+id/s_layout"
layout=
"@layout/search_layout"
/>
</RelativeLayout>
</layout>
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment