Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_freeworld
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_freeworld
Commits
133881c9
Commit
133881c9
authored
Aug 10, 2021
by
张释方
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加景点推荐弹窗、景点推荐接口
parent
59409d26
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
219 additions
and
18 deletions
+219
-18
ItemHotViewAdapter.kt
.../main/java/com/mints/street/adapter/ItemHotViewAdapter.kt
+1
-1
MainApi.kt
app/src/main/java/com/mints/street/api/MainApi.kt
+7
-1
HotViewBean.kt
app/src/main/java/com/mints/street/bean/HotViewBean.kt
+0
-6
ViewRecommed.kt
app/src/main/java/com/mints/street/bean/ViewRecommed.kt
+15
-0
HomeFragment.kt
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
+2
-2
HomeViewModel.kt
...src/main/java/com/mints/street/main/home/HomeViewModel.kt
+31
-2
ApiModel.kt
app/src/main/java/com/mints/street/model/ApiModel.kt
+11
-3
HttpSubscribeImpl.kt
...n/java/com/mints/street/netwrok/base/HttpSubscribeImpl.kt
+2
-1
HotViewDialog.kt
...main/java/com/mints/street/widget/dialog/HotViewDialog.kt
+0
-2
ViewRecommedDialog.kt
...java/com/mints/street/widget/dialog/ViewRecommedDialog.kt
+65
-0
layout_viewrecommed.xml
app/src/main/res/layout/layout_viewrecommed.xml
+85
-0
No files found.
app/src/main/java/com/mints/street/adapter/ItemHotViewAdapter.kt
View file @
133881c9
...
@@ -29,7 +29,7 @@ class ItemHotViewAdapter(val context: Context, var list: List<HotViewBean.datasl
...
@@ -29,7 +29,7 @@ class ItemHotViewAdapter(val context: Context, var list: List<HotViewBean.datasl
//设置名称
//设置名称
holder
.
binding
.
viewname
.
text
=
name
holder
.
binding
.
viewname
.
text
=
name
//设置距离
//设置距离
holder
.
binding
.
tvDistance
.
text
=
distance
.
toString
()
//
holder.binding.tvDistance.text= distance.toString()
//设置景点简介
//设置景点简介
holder
.
binding
.
tvDescribe
.
text
=
desc
holder
.
binding
.
tvDescribe
.
text
=
desc
//设置点击事件
//设置点击事件
...
...
app/src/main/java/com/mints/street/api/MainApi.kt
View file @
133881c9
...
@@ -143,5 +143,11 @@ interface MainApi {
...
@@ -143,5 +143,11 @@ interface MainApi {
* 热门景点
* 热门景点
*/
*/
@POST
(
"na/getAttractionsList"
)
@POST
(
"na/getAttractionsList"
)
fun
getHotView
():
Observable
<
Response
<
BaseResponse
<
HotViewBean
>>>
fun
getHotView
(
@Body
vo
:
@JvmSuppressWildcards
Map
<
String
,
Any
>):
Observable
<
Response
<
BaseResponse
<
HotViewBean
>>>
/**
* 景点推荐
*/
@POST
(
"na/getAttractionsList"
)
fun
getViewRecommed
(
@Body
vo
:
@JvmSuppressWildcards
Map
<
String
,
Any
>):
Observable
<
Response
<
BaseResponse
<
ViewRecommed
>>>
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/bean/HotViewBean.kt
View file @
133881c9
...
@@ -3,16 +3,10 @@ package com.mints.street.bean
...
@@ -3,16 +3,10 @@ package com.mints.street.bean
import
java.io.Serializable
import
java.io.Serializable
class
HotViewBean
:
Serializable
{
class
HotViewBean
:
Serializable
{
val
list
:
List
<
dataslist
>?
=
null
val
list
:
List
<
dataslist
>?
=
null
inner
class
dataslist
:
Serializable
{
inner
class
dataslist
:
Serializable
{
//景点简介
val
desc
:
String
?
=
null
val
desc
:
String
?
=
null
//距离
val
distance
:
Double
?
=
null
val
id
:
String
?
=
null
val
img
:
String
?
=
null
val
img
:
String
?
=
null
val
lat
:
String
?
=
null
val
lat
:
String
?
=
null
val
lng
:
String
?
=
null
val
lng
:
String
?
=
null
...
...
app/src/main/java/com/mints/street/bean/ViewRecommed.kt
0 → 100644
View file @
133881c9
package
com.mints.street.bean
import
java.io.Serializable
class
ViewRecommed
:
Serializable
{
val
list
:
List
<
dataslist
>?
=
null
inner
class
dataslist
:
Serializable
{
val
desc
:
String
?
=
null
val
img
:
String
?
=
null
val
lat
:
String
?
=
null
val
lng
:
String
?
=
null
val
name
:
String
?
=
null
}
}
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
View file @
133881c9
...
@@ -31,6 +31,7 @@ import com.mints.street.widget.ScrollLayout
...
@@ -31,6 +31,7 @@ import com.mints.street.widget.ScrollLayout
import
com.mints.street.widget.dialog.DialogUtils
import
com.mints.street.widget.dialog.DialogUtils
import
com.mints.street.widget.dialog.DialogUtils.showupgradevipDialog
import
com.mints.street.widget.dialog.DialogUtils.showupgradevipDialog
import
com.mints.street.widget.dialog.HotViewDialog
import
com.mints.street.widget.dialog.HotViewDialog
import
com.mints.street.widget.dialog.ViewRecommedDialog
import
me.goldze.mvvmhabit.base.AppManager
import
me.goldze.mvvmhabit.base.AppManager
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.RxUtils
import
me.goldze.mvvmhabit.utils.RxUtils
...
@@ -43,7 +44,7 @@ import me.goldze.mvvmhabit.utils.ToastUtils
...
@@ -43,7 +44,7 @@ import me.goldze.mvvmhabit.utils.ToastUtils
*/
*/
class
HomeFragment
()
:
BaseFragment
<
FragmentHomeBinding
,
HomeViewModel
>(),
SensorEventListener
{
class
HomeFragment
()
:
BaseFragment
<
FragmentHomeBinding
,
HomeViewModel
>(),
SensorEventListener
{
private
val
hotViewDialog
by
lazy
{
HotViewDialog
(
requireActivity
(),
viewModel
,
this
).
init
()
}
private
val
hotViewDialog
by
lazy
{
HotViewDialog
(
requireActivity
(),
viewModel
,
this
).
init
()
}
private
val
viewrecommedDialog
by
lazy
{
ViewRecommedDialog
(
requireActivity
(),
viewModel
,
this
).
init
()
}
companion
object
{
companion
object
{
val
IS_FIRST_OPEN
:
String
=
"isFirstOpen"
val
IS_FIRST_OPEN
:
String
=
"isFirstOpen"
}
}
...
@@ -167,7 +168,6 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
...
@@ -167,7 +168,6 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
override
fun
onMapStatusChangeStart
(
status
:
MapStatus
?,
reason
:
Int
)
{
override
fun
onMapStatusChangeStart
(
status
:
MapStatus
?,
reason
:
Int
)
{
KLog
.
a
(
"百度map"
,
"移动开始,两个参数"
)
KLog
.
a
(
"百度map"
,
"移动开始,两个参数"
)
}
}
override
fun
onMapStatusChange
(
status
:
MapStatus
?)
{
override
fun
onMapStatusChange
(
status
:
MapStatus
?)
{
...
...
app/src/main/java/com/mints/street/main/home/HomeViewModel.kt
View file @
133881c9
...
@@ -184,11 +184,14 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
...
@@ -184,11 +184,14 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}
}
}
}
/**
/**
* 获取
人们
景点数据
* 获取
热门
景点数据
*/
*/
var
hotviewData
=
MutableLiveData
<
HotViewBean
>()
var
hotviewData
=
MutableLiveData
<
HotViewBean
>()
fun
getHotView
()
{
fun
getHotView
()
{
ApiModel
.
getHotView
(
lifecycleProvider
).
safeSubscribe
(
val
vo
=
HashMap
<
String
,
Any
>()
//2-景点推荐 3-热门景点
vo
[
"type"
]
=
3
ApiModel
.
getHotView
(
lifecycleProvider
,
vo
).
safeSubscribe
(
object
:
HttpSubscribeImpl
<
BaseResponse
<
HotViewBean
>>(
object
:
HttpSubscribeImpl
<
BaseResponse
<
HotViewBean
>>(
this
@HomeViewModel
,
true
)
{
this
@HomeViewModel
,
true
)
{
...
@@ -205,4 +208,30 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
...
@@ -205,4 +208,30 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}
}
)
)
}
}
/**
* 获取景点推荐数据
*/
var
viewRecommed
=
MutableLiveData
<
ViewRecommed
>()
fun
getviewrecommend
(){
val
vo
=
HashMap
<
String
,
Any
>()
//2-景点推荐 3-热门景点
vo
[
"type"
]
=
2
ApiModel
.
getViewRecommed
(
lifecycleProvider
,
vo
).
safeSubscribe
(
object
:
HttpSubscribeImpl
<
BaseResponse
<
ViewRecommed
>>(
this
@HomeViewModel
,
true
)
{
override
fun
onBusinessSuccess
(
response
:
BaseResponse
<
ViewRecommed
>)
{
viewRecommed
.
value
=
response
.
result
KLog
.
e
(
"getmyInfo"
,
response
.
result
.
toString
())
}
override
fun
onError
(
e
:
Throwable
)
{
super
.
onError
(
e
)
KLog
.
e
(
"getmyInfo"
,
"用户登录信息请求失败"
)
}
}
)
}
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/model/ApiModel.kt
View file @
133881c9
...
@@ -6,7 +6,6 @@ import com.mints.street.netwrok.common.HttpManager
...
@@ -6,7 +6,6 @@ import com.mints.street.netwrok.common.HttpManager
import
com.trello.rxlifecycle2.LifecycleProvider
import
com.trello.rxlifecycle2.LifecycleProvider
import
io.reactivex.Observable
import
io.reactivex.Observable
import
retrofit2.Response
import
retrofit2.Response
import
retrofit2.http.Body
/**
/**
* Created by 冯瑞雨 on 2021/7/2.
* Created by 冯瑞雨 on 2021/7/2.
...
@@ -147,8 +146,17 @@ object ApiModel {
...
@@ -147,8 +146,17 @@ object ApiModel {
return
HttpManager
.
getInstance
().
execute
(
null
,
MainApi
.
newInstance
().
authorizedA
())
return
HttpManager
.
getInstance
().
execute
(
null
,
MainApi
.
newInstance
().
authorizedA
())
}
}
/**
* 请求热门景点数据
*/
fun
getHotView
(
lifecycleProvider
:
LifecycleProvider
<
Any
>?,
map
:
HashMap
<
String
,
Any
>):
Observable
<
Response
<
BaseResponse
<
HotViewBean
>>>{
return
HttpManager
.
getInstance
().
execute
(
lifecycleProvider
,
MainApi
.
newInstance
().
getHotView
(
map
))
}
fun
getHotView
(
lifecycleProvider
:
LifecycleProvider
<
Any
>?):
Observable
<
Response
<
BaseResponse
<
HotViewBean
>>>{
/**
return
HttpManager
.
getInstance
().
execute
(
lifecycleProvider
,
MainApi
.
newInstance
().
getHotView
())
* 请求景点推荐数据
*/
fun
getViewRecommed
(
lifecycleProvider
:
LifecycleProvider
<
Any
>?,
map
:
Map
<
String
,
Any
>):
Observable
<
Response
<
BaseResponse
<
ViewRecommed
>>>{
return
HttpManager
.
getInstance
().
execute
(
lifecycleProvider
,
MainApi
.
newInstance
().
getViewRecommed
(
map
))
}
}
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/netwrok/base/HttpSubscribeImpl.kt
View file @
133881c9
...
@@ -18,7 +18,8 @@ import retrofit2.Response
...
@@ -18,7 +18,8 @@ import retrofit2.Response
* @date 2020/1/10
* @date 2020/1/10
*/
*/
abstract
class
HttpSubscribeImpl
<
T
:
BaseResponse
<*>>(
viewModel
:
BaseViewModel
?,
val
needToast
:
Boolean
=
true
)
:
IHttpSubscribe
<
T
>(
viewModel
)
{
abstract
class
HttpSubscribeImpl
<
T
:
BaseResponse
<*>>(
viewModel
:
BaseViewModel
?,
val
needToast
:
Boolean
=
true
)
:
IHttpSubscribe
<
T
>(
viewModel
)
{
constructor
(
viewModel
:
BaseViewModel
?)
:
this
(
viewModel
,
true
)
constructor
(
viewModel
:
BaseViewModel
?)
:
this
(
viewModel
,
true
)
...
...
app/src/main/java/com/mints/street/widget/dialog/HotViewDialog.kt
View file @
133881c9
...
@@ -60,11 +60,9 @@ class HotViewDialog(context: FragmentActivity, viewModel: HomeViewModel, homeFra
...
@@ -60,11 +60,9 @@ class HotViewDialog(context: FragmentActivity, viewModel: HomeViewModel, homeFra
viewModel
?.
getHotView
()
viewModel
?.
getHotView
()
viewModel
?.
hotviewData
?.
observe
(
homeFragment
!!
,
androidx
.
lifecycle
.
Observer
{
viewModel
?.
hotviewData
?.
observe
(
homeFragment
!!
,
androidx
.
lifecycle
.
Observer
{
if
(
itemHotViewAdapter
==
null
){
if
(
itemHotViewAdapter
==
null
){
// itemHotViewAdapter = ItemEnterDestinationAdapter(context!!, false,it?.data)
itemHotViewAdapter
=
ItemHotViewAdapter
(
context
!!
,
it
.
list
)
itemHotViewAdapter
=
ItemHotViewAdapter
(
context
!!
,
it
.
list
)
mAdapter
?.
addAdapter
(
itemHotViewAdapter
)
mAdapter
?.
addAdapter
(
itemHotViewAdapter
)
}
}
itemHotViewAdapter
?.
list
=
it
?.
list
!!
mAdapter
?.
notifyDataSetChanged
()
mAdapter
?.
notifyDataSetChanged
()
})
})
iv_close
.
setOnClickListener
{
iv_close
.
setOnClickListener
{
...
...
app/src/main/java/com/mints/street/widget/dialog/ViewRecommedDialog.kt
0 → 100644
View file @
133881c9
package
com.mints.street.widget.dialog
import
android.graphics.Color
import
android.view.LayoutInflater
import
android.view.View
import
android.widget.ImageView
import
androidx.fragment.app.FragmentActivity
import
androidx.recyclerview.widget.DividerItemDecoration
import
androidx.recyclerview.widget.RecyclerView
import
com.alibaba.android.vlayout.DelegateAdapter
import
com.alibaba.android.vlayout.VirtualLayoutManager
import
com.google.android.material.bottomsheet.BottomSheetDialog
import
com.mints.street.R
import
com.mints.street.adapter.ItemHotViewAdapter
import
com.mints.street.main.home.HomeFragment
import
com.mints.street.main.home.HomeViewModel
import
com.mints.street.widget.GridItemDecoration
class
ViewRecommedDialog
(
context
:
FragmentActivity
,
viewModel
:
HomeViewModel
,
homeFragment
:
HomeFragment
)
{
private
var
mBottomSheetDialog
:
BottomSheetDialog
?=
null
private
var
context
:
FragmentActivity
private
var
viewModel
:
HomeViewModel
?=
null
private
var
homeFragment
:
HomeFragment
?=
null
init
{
this
.
context
=
context
this
.
viewModel
=
viewModel
this
.
homeFragment
=
homeFragment
}
//
fun
init
():
ViewRecommedDialog
{
//创建弹窗
if
(
mBottomSheetDialog
!=
null
)
return
this
mBottomSheetDialog
=
BottomSheetDialog
(
context
)
val
view1
:
View
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
layout_viewrecommed
,
null
)
mBottomSheetDialog
!!
.
setContentView
(
view1
)
mBottomSheetDialog
!!
.
window
!!
.
findViewById
<
View
>(
R
.
id
.
design_bottom_sheet
).
setBackgroundColor
(
Color
.
TRANSPARENT
)
val
iv_close
:
ImageView
=
view1
.
findViewById
(
R
.
id
.
iv_close
)
val
recycler_view
:
RecyclerView
=
view1
.
findViewById
(
R
.
id
.
recycler_view
)
viewModel
?.
getHotView
()
viewModel
?.
hotviewData
?.
observe
(
homeFragment
!!
,
androidx
.
lifecycle
.
Observer
{
})
iv_close
.
setOnClickListener
{
mBottomSheetDialog
!!
.
dismiss
()
}
return
this
}
/**
* 展示
*/
fun
show
()
{
mBottomSheetDialog
!!
.
show
()
}
fun
onDestroy
()
{
mBottomSheetDialog
=
null
}
}
app/src/main/res/layout/layout_viewrecommed.xml
0 → 100644
View file @
133881c9
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/shape_dialog_bg"
>
<TextView
android:id=
"@+id/viewname"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"10dp"
android:layout_marginTop=
"10dp"
android:text=
"景点名称"
android:textColor=
"@color/black"
android:textSize=
"18dp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<View
android:id=
"@+id/view"
android:layout_width=
"1dp"
android:layout_height=
"14dp"
android:layout_marginLeft=
"5dp"
android:background=
"@color/black"
app:layout_constraintBottom_toBottomOf=
"@+id/tv_distance"
app:layout_constraintStart_toEndOf=
"@+id/viewname"
app:layout_constraintTop_toTopOf=
"@+id/tv_distance"
tools:ignore=
"MissingConstraints"
/>
<TextView
android:id=
"@+id/tv_distance"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"距离"
android:textColor=
"#99000000"
android:textSize=
"14dp"
app:layout_constraintBottom_toBottomOf=
"@+id/viewname"
app:layout_constraintStart_toEndOf=
"@+id/view"
app:layout_constraintTop_toTopOf=
"@+id/viewname"
tools:text=
"距离"
/>
<TextView
android:id=
"@+id/textView5"
android:layout_width=
"70dp"
android:layout_height=
"30dp"
android:layout_marginEnd=
"10dp"
android:background=
"@drawable/shape_btn_friends_unenabled"
android:gravity=
"center"
android:text=
"看街景"
android:textColor=
"@color/black"
android:textSize=
"12sp"
app:layout_constraintBottom_toBottomOf=
"@+id/viewname"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/viewname"
tools:text=
"看街景"
/>
<com.mints.street.widget.XCRoundRectImageView
android:id=
"@+id/image1"
android:layout_width=
"0dp"
android:layout_height=
"120dp"
android:layout_marginTop=
"10dp"
android:src=
"@mipmap/icon_card6"
app:layout_constraintEnd_toEndOf=
"@+id/textView5"
app:layout_constraintStart_toStartOf=
"@+id/viewname"
app:layout_constraintTop_toBottomOf=
"@+id/viewname"
tools:src=
"@mipmap/icon_card6"
/>
<TextView
android:id=
"@+id/tv_describe"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:layout_marginBottom=
"10dp"
android:text=
"景点介绍。。。"
android:maxLines=
"2"
android:ellipsize=
"end"
android:textColor=
"#99000000"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"@+id/image1"
app:layout_constraintStart_toStartOf=
"@+id/image1"
app:layout_constraintTop_toBottomOf=
"@+id/image1"
tools:text=
"景点介绍。。。"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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