Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_street
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_street
Commits
3064de6c
Commit
3064de6c
authored
Jul 21, 2021
by
fengruiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
搜索页面历史记录的功能已完成(包含境内和境外的功能)
搜索回调到地图页面的功能已完成
parent
79a9f635
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
209 additions
and
86 deletions
+209
-86
build.gradle
app/build.gradle
+8
-6
HistoryRecordAdapter.kt
...ain/java/com/mints/street/adapter/HistoryRecordAdapter.kt
+73
-23
PopularSceneAdapter.kt
...main/java/com/mints/street/adapter/PopularSceneAdapter.kt
+6
-0
HistoryBean.kt
app/src/main/java/com/mints/street/bean/HistoryBean.kt
+10
-0
AppDatabase.kt
app/src/main/java/com/mints/street/db/AppDatabase.kt
+2
-2
ScenicSpotDao.kt
app/src/main/java/com/mints/street/db/ScenicSpotDao.kt
+1
-2
TableBean.kt
app/src/main/java/com/mints/street/db/TableBean.kt
+1
-2
HomeFragment.kt
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
+14
-2
HomeViewModel.kt
...src/main/java/com/mints/street/main/home/HomeViewModel.kt
+1
-0
SearchAfterItem.kt
...c/main/java/com/mints/street/main/home/SearchAfterItem.kt
+3
-3
SearchMapActivity.kt
...main/java/com/mints/street/main/home/SearchMapActivity.kt
+30
-23
SearchMapViewModel.kt
...ain/java/com/mints/street/main/home/SearchMapViewModel.kt
+5
-0
cursor_bg_shape.xml
app/src/main/res/drawable/cursor_bg_shape.xml
+1
-0
activity_search_map.xml
app/src/main/res/layout/activity_search_map.xml
+16
-11
item_history_record_adapter.xml
app/src/main/res/layout/item_history_record_adapter.xml
+19
-2
item_history_record_name.xml
app/src/main/res/layout/item_history_record_name.xml
+6
-5
item_search_after.xml
app/src/main/res/layout/item_search_after.xml
+12
-5
popular_scenic_spots_icon.png
app/src/main/res/mipmap-xxhdpi/popular_scenic_spots_icon.png
+0
-0
positioning_small_icon.png
app/src/main/res/mipmap-xxhdpi/positioning_small_icon.png
+0
-0
trash_can_icon.png
app/src/main/res/mipmap-xxhdpi/trash_can_icon.png
+0
-0
colors.xml
app/src/main/res/values/colors.xml
+1
-0
No files found.
app/build.gradle
View file @
3064de6c
...
@@ -190,11 +190,13 @@ dependencies {
...
@@ -190,11 +190,13 @@ dependencies {
//room数据库
//room数据库
def
room_version
=
"2.3.0"
def
room_version
=
"2.3.0"
implementation
(
"androidx.room:room-runtime:$room_version"
)
implementation
"androidx.room:room-runtime:$room_version"
annotationProcessor
"androidx.room:room-compiler:$room_version"
annotationProcessor
"androidx.room:room-compiler:$room_version"
// use kapt for Kotlin
// optional - Kotlin Extensions and Coroutines support for Room
// optional - RxJava support for Room
implementation
(
"androidx.room:room-ktx:$room_version"
)
implementation
"androidx.room:room-rxjava2:$room_version"
// optional - Test helpers
// optional - Guava support for Room, including Optional and ListenableFuture
testImplementation
(
"androidx.room:room-testing:$room_version"
)
implementation
"androidx.room:room-guava:$room_version"
// Test helpers
testImplementation
"androidx.room:room-testing:$room_version"
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/adapter/HistoryRecordAdapter.kt
View file @
3064de6c
package
com.mints.street.adapter
package
com.mints.street.adapter
import
android.content.
Contex
t
import
android.content.
Inten
t
import
android.text.TextUtils
import
android.text.TextUtils
import
android.view.View
import
androidx.databinding.ViewDataBinding
import
androidx.databinding.ViewDataBinding
import
com.alibaba.android.vlayout.layout.LinearLayoutHelper
import
com.alibaba.android.vlayout.layout.LinearLayoutHelper
import
com.fry.base.adapter.AbstractVLayoutBaseAdapter
import
com.fry.base.adapter.AbstractVLayoutBaseAdapter
...
@@ -9,55 +10,95 @@ import com.fry.base.adapter.BindingViewHolder
...
@@ -9,55 +10,95 @@ import com.fry.base.adapter.BindingViewHolder
import
com.fry.base.recycler_view.VHMAdapter
import
com.fry.base.recycler_view.VHMAdapter
import
com.fry.base.recycler_view.VHModel
import
com.fry.base.recycler_view.VHModel
import
com.google.gson.Gson
import
com.google.gson.Gson
import
com.google.gson.reflect.TypeToken
import
com.mints.street.BR
import
com.mints.street.BR
import
com.mints.street.R
import
com.mints.street.R
import
com.mints.street.bean.HistoryBean
import
com.mints.street.databinding.ItemHistoryRecordAdapterBinding
import
com.mints.street.databinding.ItemHistoryRecordAdapterBinding
import
com.mints.street.main.home.SearchMapActivity
import
com.mints.street.main.home.SearchMapActivity
import
com.mints.street.main.home.SearchMapViewModel
import
me.goldze.mvvmhabit.binding.command.BindingAction
import
me.goldze.mvvmhabit.binding.command.BindingCommand
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.RxUtils
import
me.goldze.mvvmhabit.utils.SPUtils
import
me.goldze.mvvmhabit.utils.SPUtils
import
java.lang.reflect.Type
/**
/**
* Created by 冯瑞雨 on 2021/7/14.
* Created by 冯瑞雨 on 2021/7/14.
* 历史记录的adapter
* 历史记录的adapter
*/
*/
class
HistoryRecordAdapter
(
val
context
:
Context
,
var
name
:
String
?
=
null
)
:
class
HistoryRecordAdapter
(
val
activity
:
SearchMapActivity
,
val
viewModel
:
SearchMapViewModel
AbstractVLayoutBaseAdapter
<
ItemHistoryRecordAdapterBinding
,
String
>(
context
,
name
,
1
)
{
,
var
type
:
Int
=
0
,
var
name
:
String
?
=
null
)
:
AbstractVLayoutBaseAdapter
<
ItemHistoryRecordAdapterBinding
,
String
>(
activity
,
name
,
1
)
{
var
listName
:
List
<
String
>?
=
getHistoryData
()
var
listName
:
MutableList
<
HistoryBean
>?=
null
var
binding
:
ItemHistoryRecordAdapterBinding
?=
null
override
fun
onBindViewHolder
(
override
fun
onBindViewHolder
(
holder
:
BindingViewHolder
<
ItemHistoryRecordAdapterBinding
>,
holder
:
BindingViewHolder
<
ItemHistoryRecordAdapterBinding
>,
position
:
Int
position
:
Int
)
{
)
{
binding
=
holder
.
binding
listName
=
getHistoryData
()
if
(
listName
!=
null
&&
listName
!!
.
size
>
0
){
binding
?.
historyBg
?.
visibility
=
View
.
VISIBLE
}
else
{
binding
?.
historyBg
?.
visibility
=
View
.
GONE
}
val
adapter
=
VHMAdapter
<
HistoryRecordItemVHM
>()
val
adapter
=
VHMAdapter
<
HistoryRecordItemVHM
>()
listName
?.
apply
{
listName
?.
let
{
for
(
i
tems
in
this
)
{
for
(
i
ndex
in
it
.
size
-
1
downTo
0
)
{
adapter
.
add
(
HistoryRecordItemVHM
(
items
))
adapter
.
add
(
HistoryRecordItemVHM
(
activity
,
viewModel
,
it
[
index
]
))
}
}
}
}
holder
.
binding
.
listView
.
adapter
=
adapter
holder
.
binding
.
listView
.
adapter
=
adapter
//清空
RxUtils
.
onMultiClick
(
binding
?.
tvClear
){
listName
?.
clear
()
SPUtils
.
getInstance
(
SearchMapActivity
.
HISTORY_NAME
)
.
removeKey
(
if
(
type
==
0
){
"Territory"
}
else
{
"Abroad"
})
binding
?.
historyBg
?.
visibility
=
View
.
GONE
notifyDataSetChanged
()
}
}
}
private
fun
getHistoryData
():
List
<
String
>?
{
private
fun
getHistoryData
():
MutableList
<
HistoryBean
>?
{
val
instance
=
SPUtils
.
getInstance
(
SearchMapActivity
.
HISTORY_NAME
)
val
instance
=
SPUtils
.
getInstance
(
SearchMapActivity
.
HISTORY_NAME
)
val
string
=
instance
.
decodeString
(
"name"
)
val
string
=
instance
.
decodeString
(
if
(
type
==
0
){
"Territory"
}
else
{
"Abroad"
}
)
if
(
TextUtils
.
isEmpty
(
string
)){
if
(
TextUtils
.
isEmpty
(
string
))
{
return
null
return
null
}
}
return
Gson
().
fromJson
<
List
<
String
>>(
string
,
List
::
class
.
java
)
return
try
{
val
listType
:
Type
=
object
:
TypeToken
<
List
<
HistoryBean
?>?>()
{}.
type
Gson
().
fromJson
(
string
,
listType
)
}
catch
(
e
:
Exception
){
null
}
}
}
fun
addHistoryData
(
addName
:
String
)
{
fun
addHistoryData
(
addName
:
HistoryBean
)
{
val
instance
=
SPUtils
.
getInstance
(
SearchMapActivity
.
HISTORY_NAME
)
if
(
listName
==
null
)
{
if
(
listName
==
null
){
listName
=
ArrayList
<
HistoryBean
>()
listName
=
ArrayList
<
String
>()
}
}
for
(
index
in
listName
!!
.
indices
){
if
(
listName
?.
size
?:
0
>=
15
)
{
if
(
listName
!!
[
index
]
==
addName
||
addName
==
listName
!!
[
index
]){
val
size
=
listName
!!
.
size
-
15
for
(
index
in
0
..
size
)
{
listName
?.
removeAt
(
index
)
}
}
}
}
for
(
index
in
listName
!!
.
indices
)
{
instance
?.
encode
(
"name"
,
Gson
().
toJson
(
listName
).
toString
())
if
(
listName
!!
[
index
].
name
==
addName
.
name
)
{
listName
?.
removeAt
(
index
)
break
}
}
if
(
listName
!=
null
&&
listName
!!
.
size
>
0
&&
binding
?.
historyBg
?.
visibility
==
View
.
GONE
){
binding
?.
historyBg
?.
visibility
=
View
.
VISIBLE
}
listName
?.
add
(
addName
)
val
instance
=
SPUtils
.
getInstance
(
SearchMapActivity
.
HISTORY_NAME
)
instance
?.
encode
(
if
(
type
==
0
){
"Territory"
}
else
{
"Abroad"
},
Gson
().
toJson
(
listName
).
toString
())
}
}
override
fun
getItemCount
()
=
1
override
fun
getItemCount
()
=
1
...
@@ -68,8 +109,8 @@ class HistoryRecordAdapter(val context: Context, var name: String? = null) :
...
@@ -68,8 +109,8 @@ class HistoryRecordAdapter(val context: Context, var name: String? = null) :
}
}
class
HistoryRecordItemVHM
(
class
HistoryRecordItemVHM
(
val
activity
:
SearchMapActivity
,
val
viewModel
:
SearchMapViewModel
,
var
name
:
String
var
historyBean
:
HistoryBean
)
:
VHModel
()
{
)
:
VHModel
()
{
override
fun
getLayoutId
()
=
R
.
layout
.
item_history_record_name
override
fun
getLayoutId
()
=
R
.
layout
.
item_history_record_name
...
@@ -79,4 +120,13 @@ class HistoryRecordItemVHM(
...
@@ -79,4 +120,13 @@ class HistoryRecordItemVHM(
super
.
onBind
(
binding
)
super
.
onBind
(
binding
)
}
}
val
onClick
=
BindingCommand
<
Any
>(
BindingAction
{
activity
.
goTOSearch
(
historyBean
.
name
)
viewModel
.
searchName
.
value
=
HistoryBean
(
name
=
historyBean
.
name
,
latitude
=
historyBean
.
latitude
,
longitude
=
historyBean
.
longitude
)
val
intent
=
Intent
()
intent
.
putExtra
(
"latitude"
,
historyBean
.
latitude
)
intent
.
putExtra
(
"longitude"
,
historyBean
.
longitude
)
viewModel
.
finishData
(
SearchMapActivity
.
REQUEST_CODE
,
intent
)
})
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/adapter/PopularSceneAdapter.kt
View file @
3064de6c
...
@@ -21,6 +21,11 @@ import me.goldze.mvvmhabit.utils.RxUtils
...
@@ -21,6 +21,11 @@ import me.goldze.mvvmhabit.utils.RxUtils
class
PopularSceneAdapter
(
val
context
:
Context
,
var
list
:
List
<
Places
>?
=
null
)
:
class
PopularSceneAdapter
(
val
context
:
Context
,
var
list
:
List
<
Places
>?
=
null
)
:
AbstractVLayoutBaseAdapter
<
ItemPopularSceneAdapterBinding
,
List
<
Places
>>(
context
,
list
,
2
)
{
AbstractVLayoutBaseAdapter
<
ItemPopularSceneAdapterBinding
,
List
<
Places
>>(
context
,
list
,
2
)
{
fun
setData
(
list
:
List
<
Places
>?){
this
.
list
=
list
notifyDataSetChanged
()
}
override
fun
onBindViewHolder
(
override
fun
onBindViewHolder
(
holder
:
BindingViewHolder
<
ItemPopularSceneAdapterBinding
>,
holder
:
BindingViewHolder
<
ItemPopularSceneAdapterBinding
>,
position
:
Int
position
:
Int
...
@@ -31,6 +36,7 @@ class PopularSceneAdapter(val context: Context, var list: List<Places>? = null)
...
@@ -31,6 +36,7 @@ class PopularSceneAdapter(val context: Context, var list: List<Places>? = null)
,
longitude
=
list
?.
get
(
position
)
?.
longitude
.
toString
())
,
longitude
=
list
?.
get
(
position
)
?.
longitude
.
toString
())
}
}
holder
.
binding
.
tvName
.
text
=
list
?.
get
(
position
)
?.
name
holder
.
binding
.
tvName
.
text
=
list
?.
get
(
position
)
?.
name
if
(
list
?.
get
(
position
)
?.
images
!=
null
){
if
(
list
?.
get
(
position
)
?.
images
!=
null
){
for
(
index
in
list
?.
get
(
position
)
?.
images
!!
.
indices
){
for
(
index
in
list
?.
get
(
position
)
?.
images
!!
.
indices
){
if
(
list
?.
get
(
position
)
?.
images
?.
get
(
index
)==
null
)
return
if
(
list
?.
get
(
position
)
?.
images
?.
get
(
index
)==
null
)
return
...
...
app/src/main/java/com/mints/street/bean/HistoryBean.kt
0 → 100644
View file @
3064de6c
package
com.mints.street.bean
/**
* Created by 冯瑞雨 on 2021/7/21.
*/
class
HistoryBean
(
var
name
:
String
?=
null
,
var
latitude
:
Double
?=
null
,
var
longitude
:
Double
?=
null
)
\ No newline at end of file
app/src/main/java/db/AppDatabase.kt
→
app/src/main/java/
com/mints/street/
db/AppDatabase.kt
View file @
3064de6c
package
db
package
com.mints.street.
db
import
androidx.room.Database
import
androidx.room.Database
import
androidx.room.Room
import
androidx.room.Room
...
@@ -22,7 +22,7 @@ abstract class AppDatabase : RoomDatabase() {
...
@@ -22,7 +22,7 @@ abstract class AppDatabase : RoomDatabase() {
_instance
=
Room
.
databaseBuilder
(
_instance
=
Room
.
databaseBuilder
(
Utils
.
getContext
()
Utils
.
getContext
()
,
AppDatabase
::
class
.
java
,
AppDatabase
::
class
.
java
,
"mints_room.db"
)
,
"mints_room.
com.mints.street.
db"
)
.
allowMainThreadQueries
()
//设置是否允许在主线程做查询操作
.
allowMainThreadQueries
()
//设置是否允许在主线程做查询操作
//.fallbackToDestructiveMigration()//设置迁移数据库如果发生错误,将会重新创建数据库,而不是发生崩溃
//.fallbackToDestructiveMigration()//设置迁移数据库如果发生错误,将会重新创建数据库,而不是发生崩溃
.
build
()
.
build
()
...
...
app/src/main/java/db/ScenicSpotDao.kt
→
app/src/main/java/
com/mints/street/
db/ScenicSpotDao.kt
View file @
3064de6c
package
db
package
com.mints.street.
db
import
androidx.room.Dao
import
androidx.room.Dao
import
androidx.room.Query
import
androidx.room.Query
import
java.util.*
/**
/**
* Created by 冯瑞雨 on 2021/7/20.
* Created by 冯瑞雨 on 2021/7/20.
...
...
app/src/main/java/db/TableBean.kt
→
app/src/main/java/
com/mints/street/
db/TableBean.kt
View file @
3064de6c
package
db
package
com.mints.street.
db
import
androidx.room.Entity
import
androidx.room.Entity
import
androidx.room.PrimaryKey
import
androidx.room.PrimaryKey
import
java.util.*
/**
/**
* Created by 冯瑞雨 on 2021/7/20.
* Created by 冯瑞雨 on 2021/7/20.
...
...
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
View file @
3064de6c
...
@@ -107,7 +107,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
...
@@ -107,7 +107,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
if
(
it
==
null
)
return
@Observer
if
(
it
==
null
)
return
@Observer
// 默认 天安门
// 默认 天安门
val
center
=
LatLng
(
it
[
"latitude"
]
?:
39.915071
,
it
[
"longitude"
]
?:
116.403907
)
val
center
=
LatLng
(
it
[
"latitude"
]
?:
39.915071
,
it
[
"longitude"
]
?:
116.403907
)
setNewMapStatus
(
center
)
})
})
}
}
...
@@ -115,7 +115,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
...
@@ -115,7 +115,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
mBaiduMap
=
binding
.
bmapView
.
map
mBaiduMap
=
binding
.
bmapView
.
map
mBaiduMap
?.
mapType
=
BaiduMap
.
MAP_TYPE_SATELLITE
mBaiduMap
?.
mapType
=
BaiduMap
.
MAP_TYPE_SATELLITE
//设置是否显示缩放控件
//设置是否显示缩放控件
binding
.
bmapView
.
showZoomControls
(
false
)
binding
.
bmapView
.
showZoomControls
(
false
)
// 构建地图状态
// 构建地图状态
...
@@ -353,4 +352,17 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
...
@@ -353,4 +352,17 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
override
fun
onAccuracyChanged
(
sensor
:
Sensor
?,
accuracy
:
Int
)
{
override
fun
onAccuracyChanged
(
sensor
:
Sensor
?,
accuracy
:
Int
)
{
}
}
/**
* 设置地图新状态
*
* @param v
*/
private
fun
setNewMapStatus
(
latLng
:
LatLng
)
{
val
builder
=
MapStatus
.
Builder
()
builder
.
target
(
latLng
).
zoom
(
18.5f
).
overlook
(-
21f
).
rotate
(
0f
)
// 更新地图状态
mBaiduMap
!!
.
setMapStatus
(
MapStatusUpdateFactory
.
newMapStatus
(
builder
.
build
()))
//mMarker.setPosition(latLng)
}
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/main/home/HomeViewModel.kt
View file @
3064de6c
...
@@ -61,6 +61,7 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
...
@@ -61,6 +61,7 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
if
(
requestCode
==
200
&&
resultCode
==
SearchMapActivity
.
REQUEST_CODE
){
if
(
requestCode
==
200
&&
resultCode
==
SearchMapActivity
.
REQUEST_CODE
){
KLog
.
a
(
"homeFragment onActivityResult"
)
data
?.
let
{
data
?.
let
{
val
map
=
HashMap
<
String
,
Double
>(
2
)
val
map
=
HashMap
<
String
,
Double
>(
2
)
map
[
"latitude"
]
=
it
.
getDoubleExtra
(
"latitude"
,
0.0
)
map
[
"latitude"
]
=
it
.
getDoubleExtra
(
"latitude"
,
0.0
)
...
...
app/src/main/java/com/mints/street/main/home/SearchAfterItem.kt
View file @
3064de6c
...
@@ -2,6 +2,7 @@ package com.mints.street.main.home
...
@@ -2,6 +2,7 @@ package com.mints.street.main.home
import
android.content.Intent
import
android.content.Intent
import
com.baidu.mapapi.model.LatLng
import
com.baidu.mapapi.model.LatLng
import
com.mints.street.bean.HistoryBean
import
me.goldze.mvvmhabit.base.AppManager
import
me.goldze.mvvmhabit.base.AppManager
import
me.goldze.mvvmhabit.base.ItemViewModel
import
me.goldze.mvvmhabit.base.ItemViewModel
import
me.goldze.mvvmhabit.binding.command.BindingAction
import
me.goldze.mvvmhabit.binding.command.BindingAction
...
@@ -18,12 +19,11 @@ class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
...
@@ -18,12 +19,11 @@ class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
* 点击名称回调回调
* 点击名称回调回调
*/
*/
val
onClick
=
BindingCommand
<
Any
>(
BindingAction
{
val
onClick
=
BindingCommand
<
Any
>(
BindingAction
{
viewModel
.
searchName
.
value
=
HistoryBean
(
name
=
this
.
name
,
latitude
=
pt
?.
latitude
,
longitude
=
pt
?.
longitude
)
val
intent
=
Intent
()
val
intent
=
Intent
()
intent
.
putExtra
(
"latitude"
,
pt
?.
latitude
)
intent
.
putExtra
(
"latitude"
,
pt
?.
latitude
)
intent
.
putExtra
(
"longitude"
,
pt
?.
longitude
)
intent
.
putExtra
(
"longitude"
,
pt
?.
longitude
)
viewModel
.
finishData
(
SearchMapActivity
.
REQUEST_CODE
,
intent
)
viewModel
.
finishData
(
SearchMapActivity
.
REQUEST_CODE
,
intent
)
// KLog.e("SearchAfterItem","key : $name")
// KLog.e("SearchAfterItem","latitude : ${pt?.latitude}")
// KLog.e("SearchAfterItem","longitude : ${pt?.longitude}")
})
})
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/main/home/SearchMapActivity.kt
View file @
3064de6c
...
@@ -18,9 +18,9 @@ import com.mints.street.BR
...
@@ -18,9 +18,9 @@ import com.mints.street.BR
import
com.mints.street.R
import
com.mints.street.R
import
com.mints.street.adapter.HistoryRecordAdapter
import
com.mints.street.adapter.HistoryRecordAdapter
import
com.mints.street.adapter.PopularSceneAdapter
import
com.mints.street.adapter.PopularSceneAdapter
import
com.mints.street.bean.HistoryBean
import
com.mints.street.bean.MapBean
import
com.mints.street.bean.MapBean
import
com.mints.street.databinding.ActivitySearchMapBinding
import
com.mints.street.databinding.ActivitySearchMapBinding
import
me.goldze.mvvmhabit.base.AppManager
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.KLog
/**
/**
...
@@ -30,9 +30,12 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
...
@@ -30,9 +30,12 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
OnGetSuggestionResultListener
{
OnGetSuggestionResultListener
{
companion
object
{
companion
object
{
const
val
HISTORY_NAME
=
"history_name"
const
val
HISTORY_NAME
=
"history_name"
const
val
REQUEST_CODE
=
201
const
val
REQUEST_CODE
=
201
fun
startSearchMapActivity
(
fragment
:
HomeFragment
)
{
fun
startSearchMapActivity
(
fragment
:
HomeFragment
)
{
fragment
.
startActivityForResult
(
Intent
(
fragment
.
context
,
SearchMapActivity
::
class
.
java
),
REQUEST_CODE
)
fragment
.
startActivityForResult
(
Intent
(
fragment
.
context
,
SearchMapActivity
::
class
.
java
),
200
)
}
}
}
}
...
@@ -75,19 +78,17 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
...
@@ -75,19 +78,17 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
viewModel
.
searchAfterOneItems
.
clear
()
viewModel
.
searchAfterOneItems
.
clear
()
return
return
}
}
// 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新
// 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新
mSuggestionSearch
?.
requestSuggestion
(
mSuggestionSearch
?.
requestSuggestion
(
SuggestionSearchOption
()
SuggestionSearchOption
()
.
keyword
(
s
.
toString
())
// 关键字
.
keyword
(
s
.
toString
())
// 关键字
.
city
(
viewModel
.
positioningBean
?.
city
?:
"北京"
)
.
city
(
viewModel
.
positioningBean
?.
city
?:
"北京"
)
)
// 城市
)
}
}
})
})
historyRecordAdapter
=
HistoryRecordAdapter
(
this
)
historyRecordAdapter
=
HistoryRecordAdapter
(
this
,
viewModel
)
popularSceneAdapter
=
PopularSceneAdapter
(
this
)
popularSceneAdapter
=
PopularSceneAdapter
(
this
)
...
@@ -107,24 +108,21 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
...
@@ -107,24 +108,21 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
}
}
fun
goTOSearch
(
text
:
String
?){
binding
.
et
.
setSelection
(
text
?.
length
?:
0
)
}
private
fun
update
()
{
private
fun
update
()
{
mAdapter
?.
clear
()
historyRecordAdapter
?.
apply
{
if
(
viewModel
.
index
==
0
)
{
this
.
type
=
viewModel
.
index
historyRecordAdapter
?.
apply
{
mAdapter
?.
addAdapter
(
historyRecordAdapter
)
}
}
else
{
mAdapter
?.
removeAdapter
(
historyRecordAdapter
)
}
}
popularSceneAdapter
?.
apply
{
popularSceneAdapter
?.
apply
{
if
(
viewModel
.
index
==
0
)
{
if
(
viewModel
.
index
==
0
)
{
this
.
list
=
viewModel
.
mapBean
.
value
?.
innerPlaces
?.
places
this
.
data
=
viewModel
.
mapBean
.
value
?.
innerPlaces
?.
places
}
else
{
}
else
{
this
.
list
=
viewModel
.
mapBean
.
value
?.
outerPlaces
?.
places
this
.
data
=
viewModel
.
mapBean
.
value
?.
outerPlaces
?.
places
}
}
mAdapter
?.
addAdapter
(
popularSceneAdapter
)
}
}
mAdapter
?.
notifyDataSetChanged
()
}
}
override
fun
initViewObservable
()
{
override
fun
initViewObservable
()
{
...
@@ -133,6 +131,12 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
...
@@ -133,6 +131,12 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
update
()
update
()
}
}
})
})
viewModel
.
searchName
.
observe
(
this
,
Observer
<
HistoryBean
>
{
if
(
TextUtils
.
isEmpty
(
it
.
name
)){
return
@Observer
}
historyRecordAdapter
?.
addHistoryData
(
it
)
})
}
}
private
fun
territory
()
{
private
fun
territory
()
{
...
@@ -166,12 +170,15 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
...
@@ -166,12 +170,15 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
}
}
viewModel
.
searchAfterOneItems
.
clear
()
viewModel
.
searchAfterOneItems
.
clear
()
if
(
TextUtils
.
isEmpty
(
binding
.
et
.
text
))
{
if
(
TextUtils
.
isEmpty
(
binding
.
et
.
text
))
{
return
return
}
}
for
(
info
in
suggestionResult
.
allSuggestions
)
{
for
(
info
in
suggestionResult
.
allSuggestions
)
{
viewModel
.
searchAfterOneItems
.
add
(
SearchAfterItem
(
viewModel
viewModel
.
searchAfterOneItems
.
add
(
,
info
.
key
,
info
.
address
,
info
.
pt
))
SearchAfterItem
(
viewModel
,
info
.
key
,
info
.
address
,
info
.
pt
)
)
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/main/home/SearchMapViewModel.kt
View file @
3064de6c
package
com.mints.street.main.home
package
com.mints.street.main.home
import
android.app.Application
import
android.app.Application
import
android.content.Intent
import
android.text.TextUtils
import
android.text.TextUtils
import
android.view.View
import
android.view.View
import
androidx.databinding.ObservableArrayList
import
androidx.databinding.ObservableArrayList
...
@@ -8,11 +9,13 @@ import androidx.lifecycle.MutableLiveData
...
@@ -8,11 +9,13 @@ import androidx.lifecycle.MutableLiveData
import
com.google.gson.Gson
import
com.google.gson.Gson
import
com.mints.street.BR
import
com.mints.street.BR
import
com.mints.street.R
import
com.mints.street.R
import
com.mints.street.bean.HistoryBean
import
com.mints.street.bean.MapBean
import
com.mints.street.bean.MapBean
import
com.mints.street.bean.Places
import
com.mints.street.bean.Places
import
com.mints.street.bean.PositioningBean
import
com.mints.street.bean.PositioningBean
import
me.goldze.mvvmhabit.base.AppManager
import
me.goldze.mvvmhabit.base.AppManager
import
me.goldze.mvvmhabit.base.BaseViewModel
import
me.goldze.mvvmhabit.base.BaseViewModel
import
me.goldze.mvvmhabit.binding.command.BindingAction
import
me.goldze.mvvmhabit.binding.command.BindingCommand
import
me.goldze.mvvmhabit.binding.command.BindingCommand
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.SPUtils
import
me.goldze.mvvmhabit.utils.SPUtils
...
@@ -28,6 +31,8 @@ class SearchMapViewModel(application: Application) : BaseViewModel(application)
...
@@ -28,6 +31,8 @@ class SearchMapViewModel(application: Application) : BaseViewModel(application)
val
searchAfterItemBinding
=
ItemBinding
.
of
<
SearchAfterItem
>(
BR
.
viewModel
,
R
.
layout
.
item_search_after
)
val
searchAfterItemBinding
=
ItemBinding
.
of
<
SearchAfterItem
>(
BR
.
viewModel
,
R
.
layout
.
item_search_after
)
val
searchAfterOneItems
=
ObservableArrayList
<
SearchAfterItem
>()
val
searchAfterOneItems
=
ObservableArrayList
<
SearchAfterItem
>()
//搜索的name
val
searchName
=
MutableLiveData
<
HistoryBean
>()
//定位位置
//定位位置
val
positioningBean
:
PositioningBean
?
=
getpositioningMap
()
val
positioningBean
:
PositioningBean
?
=
getpositioningMap
()
...
...
app/src/main/res/drawable/cursor_bg_shape.xml
View file @
3064de6c
...
@@ -4,5 +4,6 @@
...
@@ -4,5 +4,6 @@
<!-- 边框的颜色和粗细 -->
<!-- 边框的颜色和粗细 -->
<solid
android:color=
"#ffffffff"
/>
<solid
android:color=
"#ffffffff"
/>
<corners
android:radius=
"81dp"
/>
<corners
android:radius=
"81dp"
/>
<stroke
android:width=
"0.5dp"
android:color=
"#D1D1D1"
/>
</shape>
</shape>
\ No newline at end of file
app/src/main/res/layout/activity_search_map.xml
View file @
3064de6c
...
@@ -3,27 +3,35 @@
...
@@ -3,27 +3,35 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
<View
<View
android:id=
"@+id/view_bg"
android:id=
"@+id/view_bg"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"1
5
0dp"
android:layout_height=
"1
2
0dp"
android:background=
"#668BFF"
android:background=
"#668BFF"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<com.fry.base.ui.widget.CommonTitleBar
android:id=
"@+id/ctb_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:ctb_theme=
"dark"
app:layout_constraintTop_toTopOf=
"parent"
/>
<LinearLayout
<LinearLayout
android:layout_marginBottom=
"10dp"
android:id=
"@+id/ll_title_bg"
android:id=
"@+id/ll_title_bg"
android:layout_width=
"120dp"
android:layout_width=
"120dp"
android:layout_height=
"30dp"
android:layout_height=
"30dp"
android:gravity=
"center"
android:gravity=
"center"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"@id/ctb_title"
app:layout_constraintBottom_toBottomOf=
"@id/ctb_title"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"@id/ctb_title"
>
>
<com.coorchice.library.SuperTextView
<com.coorchice.library.SuperTextView
android:id=
"@+id/territory"
android:id=
"@+id/territory"
...
@@ -79,10 +87,12 @@
...
@@ -79,10 +87,12 @@
android:hint=
"请输入地址"
android:hint=
"请输入地址"
android:paddingStart=
"45dp"
android:paddingStart=
"45dp"
android:paddingEnd=
"10dp"
android:paddingEnd=
"10dp"
android:textColor=
"@color/color_
8F6D21
"
android:textColor=
"@color/color_
555
"
android:textColorHint=
"#E1E1E1"
android:textColorHint=
"#E1E1E1"
android:textCursorDrawable=
"@drawable/cursor_color"
android:textCursorDrawable=
"@drawable/cursor_color"
android:textSize=
"14sp"
android:textSize=
"14sp"
android:singleLine=
"true"
android:maxLines=
"1"
app:layout_constraintBottom_toBottomOf=
"@id/view_bg"
app:layout_constraintBottom_toBottomOf=
"@id/view_bg"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
@@ -98,12 +108,7 @@
...
@@ -98,12 +108,7 @@
app:layout_constraintStart_toStartOf=
"@id/et"
app:layout_constraintStart_toStartOf=
"@id/et"
app:layout_constraintTop_toTopOf=
"@id/et"
/>
app:layout_constraintTop_toTopOf=
"@id/et"
/>
<com.fry.base.ui.widget.CommonTitleBar
android:id=
"@+id/ctb_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:ctb_theme=
"dark"
app:layout_constraintTop_toTopOf=
"parent"
/>
<com.fry.base.ui.widget.CustomRecycleView
<com.fry.base.ui.widget.CustomRecycleView
android:id=
"@+id/recy_after_search"
android:id=
"@+id/recy_after_search"
...
...
app/src/main/res/layout/item_history_record_adapter.xml
View file @
3064de6c
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<layout
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
<data>
<variable
<variable
name=
"adpter"
name=
"adpter"
...
@@ -9,8 +10,10 @@
...
@@ -9,8 +10,10 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:id=
"@+id/bg"
>
>
<LinearLayout
<LinearLayout
android:id=
"@+id/history_bg"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
...
@@ -33,8 +36,9 @@
...
@@ -33,8 +36,9 @@
android:textSize=
"14sp"
android:textSize=
"14sp"
/>
/>
<TextView
<TextView
android:id=
"@+id/tv_clear"
android:padding=
"10dp"
android:padding=
"10dp"
android:drawableStart=
"@mipmap/
icon_search_history
"
android:drawableStart=
"@mipmap/
trash_can_icon
"
android:drawablePadding=
"5dp"
android:drawablePadding=
"5dp"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
@@ -52,5 +56,18 @@
...
@@ -52,5 +56,18 @@
app:useDivider=
"true"
app:useDivider=
"true"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
android:layout_height=
"wrap_content"
/>
<TextView
android:layout_marginTop=
"5dp"
android:layout_marginBottom=
"10dp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"热门景区"
android:textSize=
"15sp"
android:textColor=
"@color/color_323334"
android:textStyle=
"bold"
android:drawableStart=
"@mipmap/popular_scenic_spots_icon"
android:paddingStart=
"10dp"
android:drawablePadding=
"5dp"
/>
</LinearLayout>
</LinearLayout>
</layout>
</layout>
\ No newline at end of file
app/src/main/res/layout/item_history_record_name.xml
View file @
3064de6c
...
@@ -9,14 +9,15 @@
...
@@ -9,14 +9,15 @@
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"20dp"
android:layout_height=
"20dp"
android:textSize=
"1
4
sp"
android:textSize=
"1
2
sp"
android:gravity=
"center"
android:gravity=
"center"
android:text=
"@{vhm.name}"
android:text=
"@{vhm.
historyBean.
name}"
android:textColor=
"@color/color_555"
android:textColor=
"@color/color_555"
app:stv_stroke_color=
"@color/color_555"
app:stv_stroke_color=
"@color/color_555"
app:stv_stroke_width=
"
1
dp"
app:stv_stroke_width=
"
0.5
dp"
app:stv_corner=
"10dp"
app:stv_corner=
"10dp"
android:paddingStart=
"5dp"
android:paddingStart=
"10dp"
android:paddingEnd=
"5dp"
android:paddingEnd=
"10dp"
app:onClickCommand=
"@{vhm.onClick}"
/>
/>
</layout>
</layout>
\ No newline at end of file
app/src/main/res/layout/item_search_after.xml
View file @
3064de6c
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<layout
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
@@ -10,14 +11,17 @@
...
@@ -10,14 +11,17 @@
<ImageView
<ImageView
android:id=
"@+id/image"
android:id=
"@+id/image"
android:layout_width=
"wrap_content"
android:layout_marginStart=
"10dp"
android:layout_height=
"50dp"
android:layout_width=
"20dp"
android:src=
"@mipmap/map_history_icon"
android:layout_height=
"20dp"
android:src=
"@mipmap/positioning_small_icon"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
<TextView
android:layout_marginStart=
"10dp"
android:id=
"@+id/tv_name"
android:id=
"@+id/tv_name"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
...
@@ -32,20 +36,23 @@
...
@@ -32,20 +36,23 @@
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
<TextView
android:layout_marginStart=
"10dp"
android:id=
"@+id/tv_address"
android:id=
"@+id/tv_address"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:maxLines=
"1"
android:maxLines=
"1"
android:singleLine=
"true"
android:singleLine=
"true"
android:text=
"@{viewModel.address}"
android:text=
"@{viewModel.address}"
android:textColor=
"@color/color_
555
"
android:textColor=
"@color/color_
333
"
android:textSize=
"10sp"
android:textSize=
"10sp"
tools:text=
"dsfdsfds"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@id/image"
app:layout_constraintStart_toEndOf=
"@id/image"
app:layout_constraintTop_toBottomOf=
"@id/tv_name"
/>
app:layout_constraintTop_toBottomOf=
"@id/tv_name"
/>
<View
<View
android:layout_marginStart=
"10dp"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0.5dp"
android:layout_height=
"0.5dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
app/src/main/res/mipmap-xxhdpi/popular_scenic_spots_icon.png
0 → 100644
View file @
3064de6c
2.59 KB
app/src/main/res/mipmap-xxhdpi/positioning_small_icon.png
0 → 100644
View file @
3064de6c
9.18 KB
app/src/main/res/mipmap-xxhdpi/trash_can_icon.png
0 → 100644
View file @
3064de6c
495 Bytes
app/src/main/res/values/colors.xml
View file @
3064de6c
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
<color
name=
"color_668BFF"
>
#668BFF
</color>
<color
name=
"color_668BFF"
>
#668BFF
</color>
<color
name=
"color_7EE2FF"
>
#7EE2FF
</color>
<color
name=
"color_7EE2FF"
>
#7EE2FF
</color>
<color
name=
"color_A7BCFE"
>
#A7BCFE
</color>
<color
name=
"color_A7BCFE"
>
#A7BCFE
</color>
<color
name=
"color_323334"
>
#323334
</color>
<color
name=
"color_333"
>
#333333
</color>
<color
name=
"color_333"
>
#333333
</color>
<color
name=
"color_172B54"
>
#172B54
</color>
<color
name=
"color_172B54"
>
#172B54
</color>
<color
name=
"color_121B32"
>
#121B32
</color>
<color
name=
"color_121B32"
>
#121B32
</color>
...
...
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