Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fastdevelop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高超
fastdevelop
Commits
ebc4d466
Commit
ebc4d466
authored
Feb 26, 2019
by
gao.chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
位置页
parent
c0611b2a
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
851 additions
and
4 deletions
+851
-4
app/build.gradle
+20
-0
app/keyStore.jks
+0
-0
app/src/main/AndroidManifest.xml
+6
-0
app/src/main/java/com/mayi/demo/PageActivity.java
+23
-1
app/src/main/res/layout/activity_page.xml
+6
-0
app/src/main/res/mipmap-xxhdpi/b1.jpg
+0
-0
app/src/main/res/mipmap-xxhdpi/b2.jpg
+0
-0
app/src/main/res/mipmap-xxhdpi/b3.jpg
+0
-0
fastDevelop/build.gradle
+5
-0
fastDevelop/src/main/AndroidManifest.xml
+1
-0
fastDevelop/src/main/java/com/mayi/fastdevelop/commonpage/WebActivity.java
+32
-2
fastDevelop/src/main/java/com/mayi/fastdevelop/commonpage/amap/MapLocationActivity.java
+530
-0
fastDevelop/src/main/java/com/mayi/fastdevelop/commonpage/amap/SearchResultAdapter.java
+101
-0
fastDevelop/src/main/java/com/mayi/fastdevelop/comnon/Key.java
+5
-0
fastDevelop/src/main/java/com/mayi/fastdevelop/comnon/RequestCode.java
+2
-0
fastDevelop/src/main/res/drawable/bg_edit_contact_search.xml
+9
-0
fastDevelop/src/main/res/layout/activity_search_adress.xml
+57
-0
fastDevelop/src/main/res/layout/route_inputs.xml
+10
-0
fastDevelop/src/main/res/layout/view_holder_result.xml
+42
-0
fastDevelop/src/main/res/mipmap-xxhdpi/icon_affirm_selected.png
+0
-0
fastDevelop/src/main/res/mipmap-xxhdpi/purple_pin.png
+0
-0
fastDevelop/src/main/res/values/strings.xml
+2
-1
No files found.
app/build.gradle
View file @
ebc4d466
...
...
@@ -10,6 +10,26 @@ android {
versionName
"1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs
{
debug
{
keyAlias
'mayiguide'
keyPassword
'mayi888'
storeFile
file
(
'keyStore.jks'
)
storePassword
'mayi888'
v1SigningEnabled
true
v2SigningEnabled
true
}
release
{
keyAlias
'mayiguide'
keyPassword
'mayi888'
storeFile
file
(
'keyStore.jks'
)
storePassword
'mayi888'
v1SigningEnabled
true
v2SigningEnabled
true
}
}
buildTypes
{
release
{
minifyEnabled
false
...
...
keyStore.jks
→
app/
keyStore.jks
View file @
ebc4d466
File moved
app/src/main/AndroidManifest.xml
View file @
ebc4d466
...
...
@@ -24,6 +24,12 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<meta-data
android:name=
"com.amap.api.v2.apikey"
android:value=
"d78a6d571c700f3ad33f374d81fed6a2"
/>
<activity
android:name=
".MainActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
app/src/main/java/com/mayi/demo/PageActivity.java
View file @
ebc4d466
package
com
.
mayi
.
demo
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.view.View
;
import
com.mayi.fastdevelop.base.BaseActivity
;
import
com.mayi.fastdevelop.commonpage.WebActivity
;
import
com.mayi.fastdevelop.commonpage.zxing.BaseScanActivity
;
import
com.mayi.fastdevelop.commonpage.amap.MapLocationActivity
;
import
com.mayi.fastdevelop.comnon.Key
;
import
com.mayi.fastdevelop.comnon.RequestCode
;
import
com.mayi.fastdevelop.util.ToastUtil
;
import
com.mayi.fastdevelop.util.ToolUtils
;
import
com.mayi.fastdevelop.view.OnMultiClickListener
;
...
...
@@ -58,5 +63,22 @@ public class PageActivity extends BaseActivity {
gotoActivity
(
StartActivity
.
class
);
}
});
findViewById
(
R
.
id
.
b7
).
setOnClickListener
(
new
OnMultiClickListener
()
{
@Override
public
void
onMultiClick
(
View
v
)
{
Intent
intent
=
new
Intent
(
PageActivity
.
this
,
MapLocationActivity
.
class
);
startActivityForResult
(
intent
,
RequestCode
.
MAP_LOCATION_ACTIVITY_RESULTCODE
);
}
});
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
data
)
{
if
(
requestCode
==
RequestCode
.
MAP_LOCATION_ACTIVITY_RESULTCODE
){
if
(
resultCode
==
Activity
.
RESULT_OK
){
showToast
(
data
.
getStringExtra
(
Key
.
AVTIVITY_RESULT
));
}
}
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
}
app/src/main/res/layout/activity_page.xml
View file @
ebc4d466
...
...
@@ -44,6 +44,12 @@
android:layout_height=
"wrap_content"
android:text=
"起屏页"
/>
<Button
android:id=
"@+id/b7"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"搜索地址页"
/>
</LinearLayout>
...
...
fastDevelo
p/src/main/res/mipmap-xxhdpi/b1.jpg
→
ap
p/src/main/res/mipmap-xxhdpi/b1.jpg
View file @
ebc4d466
File moved
fastDevelo
p/src/main/res/mipmap-xxhdpi/b2.jpg
→
ap
p/src/main/res/mipmap-xxhdpi/b2.jpg
View file @
ebc4d466
File moved
fastDevelo
p/src/main/res/mipmap-xxhdpi/b3.jpg
→
ap
p/src/main/res/mipmap-xxhdpi/b3.jpg
View file @
ebc4d466
File moved
fastDevelop/build.gradle
View file @
ebc4d466
...
...
@@ -26,6 +26,11 @@ android {
dependencies
{
api
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
//高德地图
api
'com.amap.api:location:latest.integration'
api
'com.amap.api:search:latest.integration'
api
'com.amap.api:3dmap:latest.integration'
api
'com.yanzhenjie:permission:2.0.0-rc12'
//权限申请
api
'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'
//下拉刷新,加载更多
api
'com.youth.banner:banner:1.4.10'
//图片轮播控件
...
...
fastDevelop/src/main/AndroidManifest.xml
View file @
ebc4d466
...
...
@@ -16,6 +16,7 @@
<application>
<activity
android:name=
".commonpage.amap.MapLocationActivity"
/>
<activity
android:name=
".commonpage.WebActivity"
/>
<!-- 解决 Android N 7.0 上 报错:android.os.FileUriExposedException -->
...
...
fastDevelop/src/main/java/com/mayi/fastdevelop/commonpage/WebActivity.java
View file @
ebc4d466
package
com
.
mayi
.
fastdevelop
.
commonpage
;
import
android.Manifest
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
...
...
@@ -23,6 +24,7 @@ import android.webkit.JavascriptInterface;
import
com.mayi.fastdevelop.R
;
import
com.mayi.fastdevelop.base.BaseActivity
;
import
com.mayi.fastdevelop.commonpage.amap.MapLocationActivity
;
import
com.mayi.fastdevelop.comnon.Key
;
import
com.mayi.fastdevelop.comnon.RequestCode
;
import
com.mayi.fastdevelop.util.BitmapUtil
;
...
...
@@ -30,11 +32,15 @@ import com.mayi.fastdevelop.util.DialogUtils;
import
com.mayi.fastdevelop.util.SpUtil
;
import
com.mayi.fastdevelop.view.CustomTitleBar
;
import
com.mayi.fastdevelop.view.dialog.BaseDialog
;
import
com.tencent.bugly.crashreport.CrashReport
;
import
com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback
;
import
com.tencent.smtt.export.external.interfaces.WebResourceError
;
import
com.tencent.smtt.export.external.interfaces.WebResourceRequest
;
import
com.tencent.smtt.sdk.ValueCallback
;
import
com.tencent.smtt.sdk.WebChromeClient
;
import
com.tencent.smtt.sdk.WebSettings
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebViewClient
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -93,6 +99,22 @@ public class WebActivity extends BaseActivity {
uploadPicture
();
}
});
webView
.
setWebViewClient
(
new
WebViewClient
()
{
@Override
public
void
onReceivedError
(
WebView
view
,
int
errorCode
,
String
description
,
String
failingUrl
)
{
//处理网页加载失败时
super
.
onReceivedError
(
view
,
errorCode
,
description
,
failingUrl
);
Throwable
thr
=
new
Throwable
(
"web加载错误: errorCode"
+
errorCode
+
" \ndescription="
+
description
+
" \nfailingUrl="
+
failingUrl
);
CrashReport
.
postCatchedException
(
thr
);
}
@Override
public
void
onReceivedError
(
WebView
view
,
WebResourceRequest
request
,
WebResourceError
error
)
{
//处理网页加载失败时
super
.
onReceivedError
(
view
,
request
,
error
);
Throwable
thr
=
new
Throwable
(
"web加载错误: errorCode"
+
error
.
getErrorCode
()
+
" \ndescription="
+
error
.
getDescription
()
+
" \nfailingUrl="
+
request
.
getUrl
());
CrashReport
.
postCatchedException
(
thr
);
}
});
initView
();
}
...
...
@@ -262,7 +284,10 @@ public class WebActivity extends BaseActivity {
* @param parameter
*/
public
void
goPage
(
String
pageName
,
String
parameter
)
{
if
(
TextUtils
.
equals
(
pageName
,
"MapLocation"
))
{
//地图定位页面
Intent
intent
=
new
Intent
(
this
,
MapLocationActivity
.
class
);
startActivityForResult
(
intent
,
RequestCode
.
MAP_LOCATION_ACTIVITY_RESULTCODE
);
}
}
private
void
initWebView
()
{
...
...
@@ -310,7 +335,11 @@ public class WebActivity extends BaseActivity {
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
RequestCode
.
REQUEST_CODE_ALBUM
||
requestCode
==
RequestCode
.
REQUEST_CODE_CAMERA
)
{
if
(
requestCode
==
RequestCode
.
MAP_LOCATION_ACTIVITY_RESULTCODE
){
if
(
resultCode
==
Activity
.
RESULT_OK
){
showToast
(
data
.
getStringExtra
(
Key
.
AVTIVITY_RESULT
));
}
}
else
if
(
requestCode
==
RequestCode
.
REQUEST_CODE_ALBUM
||
requestCode
==
RequestCode
.
REQUEST_CODE_CAMERA
)
{
if
(
uploadMessage
==
null
&&
uploadMessageAboveL
==
null
)
{
return
;
}
...
...
@@ -364,4 +393,5 @@ public class WebActivity extends BaseActivity {
};
asyncTask
.
execute
();
}
}
fastDevelop/src/main/java/com/mayi/fastdevelop/commonpage/amap/MapLocationActivity.java
0 → 100644
View file @
ebc4d466
package
com
.
mayi
.
fastdevelop
.
commonpage
.
amap
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.Point
;
import
android.os.Bundle
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.animation.Interpolator
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.AdapterView
;
import
android.widget.ArrayAdapter
;
import
android.widget.AutoCompleteTextView
;
import
android.widget.ListView
;
import
android.widget.Toast
;
import
com.amap.api.location.AMapLocation
;
import
com.amap.api.location.AMapLocationClient
;
import
com.amap.api.location.AMapLocationClientOption
;
import
com.amap.api.location.AMapLocationListener
;
import
com.amap.api.maps.AMap
;
import
com.amap.api.maps.CameraUpdateFactory
;
import
com.amap.api.maps.LocationSource
;
import
com.amap.api.maps.MapView
;
import
com.amap.api.maps.model.BitmapDescriptorFactory
;
import
com.amap.api.maps.model.CameraPosition
;
import
com.amap.api.maps.model.LatLng
;
import
com.amap.api.maps.model.Marker
;
import
com.amap.api.maps.model.MarkerOptions
;
import
com.amap.api.maps.model.animation.Animation
;
import
com.amap.api.maps.model.animation.TranslateAnimation
;
import
com.amap.api.services.core.AMapException
;
import
com.amap.api.services.core.LatLonPoint
;
import
com.amap.api.services.core.PoiItem
;
import
com.amap.api.services.geocoder.GeocodeResult
;
import
com.amap.api.services.geocoder.GeocodeSearch
;
import
com.amap.api.services.geocoder.RegeocodeQuery
;
import
com.amap.api.services.geocoder.RegeocodeResult
;
import
com.amap.api.services.help.Inputtips
;
import
com.amap.api.services.help.InputtipsQuery
;
import
com.amap.api.services.help.Tip
;
import
com.amap.api.services.poisearch.PoiResult
;
import
com.amap.api.services.poisearch.PoiSearch
;
import
com.mayi.fastdevelop.R
;
import
com.mayi.fastdevelop.base.BaseActivity
;
import
com.mayi.fastdevelop.comnon.Key
;
import
com.mayi.fastdevelop.util.DisplayUtil
;
import
com.mayi.fastdevelop.util.LogUtils
;
import
com.mayi.fastdevelop.util.ToastUtil
;
import
com.mayi.fastdevelop.view.CustomTitleBar
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 地图定位页面,
* 精确获取当前地址,防止定位误差
* 返回数据
* {
* "latitude": 31.235719,
* "longitude": 121.390442,
* "areaName": "普陀区",
* "areaCode": "310107",
* "cityName": "上海市",
* "cityCode": "021",
* "provinceName": "上海市",
* "provinceCode": "310000",
* "address": "新曹杨科技大厦长征镇怒江北路399号"
* }
*/
public
class
MapLocationActivity
extends
BaseActivity
implements
LocationSource
,
AMapLocationListener
,
GeocodeSearch
.
OnGeocodeSearchListener
,
PoiSearch
.
OnPoiSearchListener
{
private
ListView
listView
;
private
AutoCompleteTextView
searchText
;
private
AMap
aMap
;
private
MapView
mapView
;
private
OnLocationChangedListener
mListener
;
private
AMapLocationClient
mlocationClient
;
private
AMapLocationClientOption
mLocationOption
;
private
Marker
locationMarker
;
private
GeocodeSearch
geocoderSearch
;
private
int
currentPage
=
0
;
// 当前页面,从0开始计数
private
PoiSearch
.
Query
query
;
// Poi查询条件类
private
PoiSearch
poiSearch
;
private
List
<
PoiItem
>
poiItems
;
// poi数据
private
String
searchKey
=
""
;
private
LatLonPoint
searchLatlonPoint
;
private
List
<
PoiItem
>
resultData
;
private
SearchResultAdapter
searchResultAdapter
;
private
boolean
isItemClickAction
;
private
List
<
Tip
>
autoTips
;
private
boolean
isfirstinput
=
true
;
private
String
city
=
""
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
setContentView
(
R
.
layout
.
activity_search_adress
);
mapView
=
findViewById
(
R
.
id
.
map
);
mapView
.
onCreate
(
savedInstanceState
);
init
();
initView
();
resultData
=
new
ArrayList
<>();
}
private
void
initView
()
{
listView
=
findViewById
(
R
.
id
.
listview
);
searchResultAdapter
=
new
SearchResultAdapter
(
MapLocationActivity
.
this
);
listView
.
setAdapter
(
searchResultAdapter
);
listView
.
setOnItemClickListener
(
onItemClickListener
);
searchText
=
findViewById
(
R
.
id
.
keyWord
);
CustomTitleBar
titleBar
=
findViewById
(
R
.
id
.
title
);
titleBar
.
setTextCenter
(
R
.
string
.
position
);
titleBar
.
setOnClickLeftViewListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
finish
();
}
});
titleBar
.
setTextRight
(
R
.
string
.
send
);
titleBar
.
setOnClickRightTextListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
JSONObject
jsonObject
=
new
JSONObject
();
PoiItem
poiItem
=
searchResultAdapter
.
getItem
(
searchResultAdapter
.
getSelectedPosition
());
try
{
jsonObject
.
put
(
"latitude"
,
poiItem
.
getLatLonPoint
().
getLatitude
());
jsonObject
.
put
(
"longitude"
,
poiItem
.
getLatLonPoint
().
getLongitude
());
jsonObject
.
put
(
"areaName"
,
poiItem
.
getAdName
());
jsonObject
.
put
(
"areaCode"
,
poiItem
.
getAdCode
());
jsonObject
.
put
(
"cityName"
,
poiItem
.
getCityName
());
jsonObject
.
put
(
"cityCode"
,
poiItem
.
getCityCode
());
jsonObject
.
put
(
"provinceName"
,
poiItem
.
getProvinceName
());
jsonObject
.
put
(
"provinceCode"
,
poiItem
.
getProvinceCode
());
jsonObject
.
put
(
"address"
,
poiItem
.
getTitle
()
+
poiItem
.
getSnippet
());
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
Key
.
AVTIVITY_RESULT
,
jsonObject
.
toString
());
setResult
(
Activity
.
RESULT_OK
,
intent
);
finish
();
}
});
searchText
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
String
newText
=
s
.
toString
().
trim
();
if
(
newText
.
length
()
>
0
)
{
InputtipsQuery
inputquery
=
new
InputtipsQuery
(
newText
,
city
);
Inputtips
inputTips
=
new
Inputtips
(
MapLocationActivity
.
this
,
inputquery
);
inputquery
.
setCityLimit
(
true
);
inputTips
.
setInputtipsListener
(
inputtipsListener
);
inputTips
.
requestInputtipsAsyn
();
}
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{
}
});
searchText
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
if
(
autoTips
!=
null
&&
autoTips
.
size
()
>
position
)
{
Tip
tip
=
autoTips
.
get
(
position
);
searchPoi
(
tip
);
}
}
});
geocoderSearch
=
new
GeocodeSearch
(
this
);
geocoderSearch
.
setOnGeocodeSearchListener
(
this
);
hideSoftKey
(
searchText
);
}
/**
* 初始化
*/
private
void
init
()
{
if
(
aMap
==
null
)
{
aMap
=
mapView
.
getMap
();
setUpMap
();
}
aMap
.
setOnCameraChangeListener
(
new
AMap
.
OnCameraChangeListener
()
{
@Override
public
void
onCameraChange
(
CameraPosition
cameraPosition
)
{
}
@Override
public
void
onCameraChangeFinish
(
CameraPosition
cameraPosition
)
{
if
(!
isItemClickAction
&&
!
isInputKeySearch
)
{
geoAddress
();
startJumpAnimation
();
}
searchLatlonPoint
=
new
LatLonPoint
(
cameraPosition
.
target
.
latitude
,
cameraPosition
.
target
.
longitude
);
isInputKeySearch
=
false
;
isItemClickAction
=
false
;
}
});
aMap
.
setOnMapLoadedListener
(
new
AMap
.
OnMapLoadedListener
()
{
@Override
public
void
onMapLoaded
()
{
addMarkerInScreenCenter
();
}
});
}
/**
* 设置一些amap的属性
*/
private
void
setUpMap
()
{
aMap
.
getUiSettings
().
setZoomControlsEnabled
(
false
);
aMap
.
setLocationSource
(
this
);
// 设置定位监听
aMap
.
getUiSettings
().
setMyLocationButtonEnabled
(
true
);
// 设置默认定位按钮是否显示
aMap
.
setMyLocationEnabled
(
true
);
// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
aMap
.
setMyLocationType
(
AMap
.
LOCATION_TYPE_LOCATE
);
}
/**
* 方法必须重写
*/
@Override
protected
void
onResume
()
{
super
.
onResume
();
mapView
.
onResume
();
}
/**
* 方法必须重写
*/
@Override
protected
void
onPause
()
{
super
.
onPause
();
mapView
.
onPause
();
deactivate
();
}
/**
* 方法必须重写
*/
@Override
protected
void
onSaveInstanceState
(
Bundle
outState
)
{
super
.
onSaveInstanceState
(
outState
);
mapView
.
onSaveInstanceState
(
outState
);
}
/**
* 方法必须重写
*/
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
mapView
.
onDestroy
();
if
(
null
!=
mlocationClient
)
{
mlocationClient
.
onDestroy
();
}
}
/**
* 定位成功后回调函数
*/
@Override
public
void
onLocationChanged
(
AMapLocation
amapLocation
)
{
if
(
mListener
!=
null
&&
amapLocation
!=
null
)
{
if
(
amapLocation
!=
null
&&
amapLocation
.
getErrorCode
()
==
0
)
{
mListener
.
onLocationChanged
(
amapLocation
);
city
=
amapLocation
.
getCity
();
LatLng
curLatlng
=
new
LatLng
(
amapLocation
.
getLatitude
(),
amapLocation
.
getLongitude
());
searchLatlonPoint
=
new
LatLonPoint
(
curLatlng
.
latitude
,
curLatlng
.
longitude
);
aMap
.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
curLatlng
,
16
f
));
isInputKeySearch
=
false
;
searchText
.
setText
(
""
);
}
else
{
String
errText
=
"定位失败,"
+
amapLocation
.
getErrorCode
()
+
": "
+
amapLocation
.
getErrorInfo
();
LogUtils
.
e
(
"AmapErr"
+
errText
);
}
}
}
/**
* 激活定位
*/
@Override
public
void
activate
(
OnLocationChangedListener
listener
)
{
mListener
=
listener
;
if
(
mlocationClient
==
null
)
{
mlocationClient
=
new
AMapLocationClient
(
this
);
mLocationOption
=
new
AMapLocationClientOption
();
//设置定位监听
mlocationClient
.
setLocationListener
(
this
);
//设置为高精度定位模式
mLocationOption
.
setOnceLocation
(
true
);
mLocationOption
.
setLocationMode
(
AMapLocationClientOption
.
AMapLocationMode
.
Hight_Accuracy
);
//设置定位参数
mlocationClient
.
setLocationOption
(
mLocationOption
);
mlocationClient
.
startLocation
();
}
}
/**
* 停止定位
*/
@Override
public
void
deactivate
()
{
mListener
=
null
;
if
(
mlocationClient
!=
null
)
{
mlocationClient
.
stopLocation
();
mlocationClient
.
onDestroy
();
}
mlocationClient
=
null
;
}
/**
* 响应逆地理编码
*/
public
void
geoAddress
()
{
showLoadingDialog
();
searchText
.
setText
(
""
);
if
(
searchLatlonPoint
!=
null
)
{
RegeocodeQuery
query
=
new
RegeocodeQuery
(
searchLatlonPoint
,
200
,
GeocodeSearch
.
AMAP
);
// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
geocoderSearch
.
getFromLocationAsyn
(
query
);
}
}
/**
* 开始进行poi搜索
*/
protected
void
doSearchQuery
()
{
currentPage
=
0
;
query
=
new
PoiSearch
.
Query
(
searchKey
,
""
,
city
);
// 第一个参数表示搜索字符串,第二个参数表示poi搜索类型,第三个参数表示poi搜索区域(空字符串代表全国)
query
.
setCityLimit
(
true
);
query
.
setPageSize
(
20
);
query
.
setPageNum
(
currentPage
);
if
(
searchLatlonPoint
!=
null
)
{
poiSearch
=
new
PoiSearch
(
this
,
query
);
poiSearch
.
setOnPoiSearchListener
(
this
);
poiSearch
.
setBound
(
new
PoiSearch
.
SearchBound
(
searchLatlonPoint
,
1000
,
true
));
poiSearch
.
searchPOIAsyn
();
}
}
@Override
public
void
onRegeocodeSearched
(
RegeocodeResult
result
,
int
rCode
)
{
dismssLoadingDialog
();
if
(
rCode
==
AMapException
.
CODE_AMAP_SUCCESS
)
{
if
(
result
!=
null
&&
result
.
getRegeocodeAddress
()
!=
null
&&
result
.
getRegeocodeAddress
().
getFormatAddress
()
!=
null
)
{
doSearchQuery
();
}
}
else
{
LogUtils
.
e
(
"error code is "
+
rCode
);
}
}
@Override
public
void
onGeocodeSearched
(
GeocodeResult
geocodeResult
,
int
i
)
{
}
/**
* POI搜索结果回调
*
* @param poiResult 搜索结果
* @param resultCode 错误码
*/
@Override
public
void
onPoiSearched
(
PoiResult
poiResult
,
int
resultCode
)
{
if
(
resultCode
==
AMapException
.
CODE_AMAP_SUCCESS
)
{
if
(
poiResult
!=
null
&&
poiResult
.
getQuery
()
!=
null
)
{
if
(
poiResult
.
getQuery
().
equals
(
query
))
{
poiItems
=
poiResult
.
getPois
();
if
(
poiItems
!=
null
&&
poiItems
.
size
()
>
0
)
{
updateListview
(
poiItems
);
}
else
{
ToastUtil
.
show
(
this
,
"无搜索结果"
);
}
}
}
else
{
Toast
.
makeText
(
MapLocationActivity
.
this
,
"无搜索结果"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
/**
* 更新列表中的item
*
* @param poiItems
*/
private
void
updateListview
(
List
<
PoiItem
>
poiItems
)
{
resultData
.
clear
();
searchResultAdapter
.
setSelectedPosition
(
0
);
resultData
.
addAll
(
poiItems
);
searchResultAdapter
.
setData
(
resultData
);
searchResultAdapter
.
notifyDataSetChanged
();
}
@Override
public
void
onPoiItemSearched
(
PoiItem
poiItem
,
int
i
)
{
}
AdapterView
.
OnItemClickListener
onItemClickListener
=
new
AdapterView
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
if
(
position
!=
searchResultAdapter
.
getSelectedPosition
())
{
PoiItem
poiItem
=
searchResultAdapter
.
getItem
(
position
);
LatLng
curLatlng
=
new
LatLng
(
poiItem
.
getLatLonPoint
().
getLatitude
(),
poiItem
.
getLatLonPoint
().
getLongitude
());
isItemClickAction
=
true
;
aMap
.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
curLatlng
,
16
f
));
searchResultAdapter
.
setSelectedPosition
(
position
);
searchResultAdapter
.
notifyDataSetChanged
();
}
}
};
private
void
addMarkerInScreenCenter
()
{
LatLng
latLng
=
aMap
.
getCameraPosition
().
target
;
Point
screenPosition
=
aMap
.
getProjection
().
toScreenLocation
(
latLng
);
locationMarker
=
aMap
.
addMarker
(
new
MarkerOptions
()
.
anchor
(
0.5f
,
0.5f
)
.
icon
(
BitmapDescriptorFactory
.
fromResource
(
R
.
mipmap
.
purple_pin
)));
//设置Marker在屏幕上,不跟随地图移动
locationMarker
.
setPositionByPixels
(
screenPosition
.
x
,
screenPosition
.
y
);
locationMarker
.
setZIndex
(
1
);
}
/**
* 屏幕中心marker 跳动
*/
public
void
startJumpAnimation
()
{
if
(
locationMarker
!=
null
)
{
//根据屏幕距离计算需要移动的目标点
final
LatLng
latLng
=
locationMarker
.
getPosition
();
Point
point
=
aMap
.
getProjection
().
toScreenLocation
(
latLng
);
point
.
y
-=
DisplayUtil
.
dip2px
(
this
,
125
);
LatLng
target
=
aMap
.
getProjection
()
.
fromScreenLocation
(
point
);
//使用TranslateAnimation,填写一个需要移动的目标点
Animation
animation
=
new
TranslateAnimation
(
target
);
animation
.
setInterpolator
(
new
Interpolator
()
{
@Override
public
float
getInterpolation
(
float
input
)
{
// 模拟重加速度的interpolator
if
(
input
<=
0.5
)
{
return
(
float
)
(
0.5f
-
2
*
(
0.5
-
input
)
*
(
0.5
-
input
));
}
else
{
return
(
float
)
(
0.5f
-
Math
.
sqrt
((
input
-
0.5f
)
*
(
1.5f
-
input
)));
}
}
});
//整个移动所需要的时间
animation
.
setDuration
(
600
);
//设置动画
locationMarker
.
setAnimation
(
animation
);
//开始动画
locationMarker
.
startAnimation
();
}
else
{
LogUtils
.
e
(
"ama screenMarker is null"
);
}
}
Inputtips
.
InputtipsListener
inputtipsListener
=
new
Inputtips
.
InputtipsListener
()
{
@Override
public
void
onGetInputtips
(
List
<
Tip
>
list
,
int
rCode
)
{
if
(
rCode
==
AMapException
.
CODE_AMAP_SUCCESS
)
{
// 正确返回
autoTips
=
list
;
List
<
String
>
listString
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
listString
.
add
(
list
.
get
(
i
).
getName
());
}
ArrayAdapter
<
String
>
aAdapter
=
new
ArrayAdapter
<
String
>(
getApplicationContext
(),
R
.
layout
.
route_inputs
,
listString
);
searchText
.
setAdapter
(
aAdapter
);
aAdapter
.
notifyDataSetChanged
();
if
(
isfirstinput
)
{
isfirstinput
=
false
;
searchText
.
showDropDown
();
}
}
else
{
showToast
(
"erroCode "
+
rCode
);
}
}
};
private
boolean
isInputKeySearch
;
private
void
searchPoi
(
Tip
result
)
{
isInputKeySearch
=
true
;
searchLatlonPoint
=
result
.
getPoint
();
resultData
.
clear
();
searchResultAdapter
.
setSelectedPosition
(
0
);
aMap
.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
new
LatLng
(
searchLatlonPoint
.
getLatitude
(),
searchLatlonPoint
.
getLongitude
()),
16
f
));
hideSoftKey
(
searchText
);
doSearchQuery
();
}
private
void
hideSoftKey
(
View
view
)
{
InputMethodManager
imm
=
(
InputMethodManager
)
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
imm
.
showSoftInput
(
view
,
InputMethodManager
.
SHOW_FORCED
);
imm
.
hideSoftInputFromWindow
(
view
.
getWindowToken
(),
0
);
}
}
fastDevelop/src/main/java/com/mayi/fastdevelop/commonpage/amap/SearchResultAdapter.java
0 → 100644
View file @
ebc4d466
package
com
.
mayi
.
fastdevelop
.
commonpage
.
amap
;
import
android.content.Context
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.BaseAdapter
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.amap.api.services.core.PoiItem
;
import
com.mayi.fastdevelop.R
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
SearchResultAdapter
extends
BaseAdapter
{
private
List
<
PoiItem
>
data
;
private
Context
context
;
private
int
selectedPosition
=
0
;
public
SearchResultAdapter
(
Context
context
)
{
this
.
context
=
context
;
data
=
new
ArrayList
<>();
}
public
void
setData
(
List
<
PoiItem
>
data
)
{
this
.
data
=
data
;
}
public
void
setSelectedPosition
(
int
selectedPosition
)
{
this
.
selectedPosition
=
selectedPosition
;
}
public
int
getSelectedPosition
()
{
return
selectedPosition
;
}
@Override
public
int
getCount
()
{
return
data
.
size
();
}
@Override
public
PoiItem
getItem
(
int
position
)
{
return
data
.
get
(
position
);
}
@Override
public
long
getItemId
(
int
position
)
{
return
position
;
}
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
ViewHolder
viewHolder
;
if
(
convertView
==
null
)
{
LayoutInflater
inflater
=
(
LayoutInflater
)
context
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
convertView
=
inflater
.
inflate
(
R
.
layout
.
view_holder_result
,
parent
,
false
);
viewHolder
=
new
ViewHolder
(
convertView
);
convertView
.
setTag
(
viewHolder
);
}
else
{
viewHolder
=
(
ViewHolder
)
convertView
.
getTag
();
}
viewHolder
.
bindView
(
position
);
return
convertView
;
}
class
ViewHolder
{
TextView
textTitle
;
TextView
textSubTitle
;
ImageView
imageCheck
;
public
ViewHolder
(
View
view
)
{
textTitle
=
view
.
findViewById
(
R
.
id
.
text_title
);
textSubTitle
=
view
.
findViewById
(
R
.
id
.
text_title_sub
);
imageCheck
=
view
.
findViewById
(
R
.
id
.
image_check
);
}
public
void
bindView
(
int
position
)
{
if
(
position
>=
data
.
size
())
return
;
PoiItem
poiItem
=
data
.
get
(
position
);
textTitle
.
setText
(
poiItem
.
getTitle
());
textSubTitle
.
setText
(
poiItem
.
getCityName
()
+
poiItem
.
getAdName
()
+
poiItem
.
getSnippet
());
imageCheck
.
setVisibility
(
position
==
selectedPosition
?
View
.
VISIBLE
:
View
.
INVISIBLE
);
textSubTitle
.
setVisibility
((
position
==
0
&&
poiItem
.
getPoiId
().
equals
(
"regeo"
))
?
View
.
GONE
:
View
.
VISIBLE
);
}
}
}
fastDevelop/src/main/java/com/mayi/fastdevelop/comnon/Key.java
View file @
ebc4d466
package
com
.
mayi
.
fastdevelop
.
comnon
;
public
class
Key
{
/* 保存下载ID的key */
public
static
final
String
ANT_DOWNLOAD_ID
=
"ant_download_id"
;
/* avtivity返回上级页面结果 */
public
static
final
String
AVTIVITY_RESULT
=
"avtivity_result"
;
/* 用户信息 */
public
static
final
String
USER_INFO
=
"userinfo"
;
/*是否首次登录*/
...
...
fastDevelop/src/main/java/com/mayi/fastdevelop/comnon/RequestCode.java
View file @
ebc4d466
...
...
@@ -5,4 +5,6 @@ public class RequestCode {
public
static
final
int
REQUEST_CODE_PERMISSION_CAMERA
=
0x01
;
public
static
final
int
REQUEST_CODE_CAMERA
=
0x02
;
public
static
final
int
REQUEST_CODE_ALBUM
=
0x03
;
/* 地图定位页面 返回 resultcode*/
public
static
final
int
MAP_LOCATION_ACTIVITY_RESULTCODE
=
0x04
;
}
fastDevelop/src/main/res/drawable/bg_edit_contact_search.xml
0 → 100644
View file @
ebc4d466
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"#f6f6f6"
/>
<corners
android:radius=
"10dp"
/>
</shape>
\ No newline at end of file
fastDevelop/src/main/res/layout/activity_search_adress.xml
0 → 100644
View file @
ebc4d466
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/activity_main"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<com.mayi.fastdevelop.view.CustomTitleBar
android:id=
"@+id/title"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/im_dp_40"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
android:orientation=
"horizontal"
>
<AutoCompleteTextView
android:id=
"@+id/keyWord"
android:layout_width=
"match_parent"
android:layout_height=
"36dp"
android:layout_weight=
"1"
android:background=
"@drawable/bg_edit_contact_search"
android:completionThreshold=
"1"
android:dropDownVerticalOffset=
"1.0dip"
android:focusable=
"true"
android:hint=
"请输入关键字"
android:imeOptions=
"actionDone"
android:inputType=
"text|textAutoComplete"
android:maxLength=
"20"
android:paddingLeft=
"@dimen/im_dp_10"
android:paddingRight=
"@dimen/im_dp_10"
android:singleLine=
"true"
android:textColor=
"#000000"
android:textColorHint=
"#C0C0C0"
android:textSize=
"14sp"
/>
</LinearLayout>
<com.amap.api.maps.MapView
android:id=
"@+id/map"
android:layout_width=
"match_parent"
android:layout_height=
"220dp"
/>
<ListView
android:id=
"@+id/listview"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_below=
"@id/map"
android:layout_weight=
"1"
android:cacheColorHint=
"#00000000"
android:divider=
"@android:color/darker_gray"
android:dividerHeight=
"1px"
/>
</LinearLayout>
fastDevelop/src/main/res/layout/route_inputs.xml
0 → 100644
View file @
ebc4d466
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/online_user_list_item_textview"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"20dip"
android:layout_marginTop=
"20dip"
android:padding=
"@dimen/im_dp_2"
android:textColor=
"#898989"
android:textSize=
"15sp"
/>
fastDevelop/src/main/res/layout/view_holder_result.xml
0 → 100644
View file @
ebc4d466
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
android:padding=
"8dp"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/text_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:text=
"title"
android:textSize=
"15sp"
/>
<TextView
android:id=
"@+id/text_title_sub"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"6dp"
android:text=
"sub_title"
android:textColor=
"@android:color/darker_gray"
android:textSize=
"13sp"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/image_check"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_marginLeft=
"8dp"
android:src=
"@mipmap/icon_affirm_selected"
/>
</LinearLayout>
\ No newline at end of file
fastDevelop/src/main/res/mipmap-xxhdpi/icon_affirm_selected.png
0 → 100644
View file @
ebc4d466
3.36 KB
fastDevelop/src/main/res/mipmap-xxhdpi/purple_pin.png
0 → 100644
View file @
ebc4d466
2.78 KB
fastDevelop/src/main/res/values/strings.xml
View file @
ebc4d466
<resources>
<string
name=
"app_name"
>
fastDevelop
</string>
<string
name=
"save_img_failed_2"
>
图片地址异常,保存图片失败!
</string>
<string
name=
"save_img_success"
>
保存图片成功!
</string>
<string
name=
"save_img_failed"
>
保存图片失败!
</string>
...
...
@@ -19,4 +18,6 @@
<string
name=
"scan_tips"
>
将二维码放入框内,即可自动扫描
</string>
<string
name=
"open_light"
>
打开闪光灯
</string>
<string
name=
"close_light"
>
关闭闪光灯
</string>
<string
name=
"position"
>
位置
</string>
<string
name=
"send"
>
发送
</string>
</resources>
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