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
49584319
Commit
49584319
authored
Aug 11, 2021
by
张释方
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化热门景点弹窗
parent
71ab39c9
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
159 additions
and
96 deletions
+159
-96
ItemEnterDestinationAdapter.kt
...a/com/mints/street/adapter/ItemEnterDestinationAdapter.kt
+0
-1
ItemHotViewAdapter.kt
.../main/java/com/mints/street/adapter/ItemHotViewAdapter.kt
+16
-11
HotViewBean.kt
app/src/main/java/com/mints/street/bean/HotViewBean.kt
+1
-0
MainActivity.kt
app/src/main/java/com/mints/street/main/MainActivity.kt
+0
-1
HomeFragment.kt
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
+34
-29
HomeViewModel.kt
...src/main/java/com/mints/street/main/home/HomeViewModel.kt
+22
-0
GetJuLiUtils.java
app/src/main/java/com/mints/street/utils/GetJuLiUtils.java
+18
-0
HotViewDialog.kt
...main/java/com/mints/street/widget/dialog/HotViewDialog.kt
+28
-26
fragment_home.xml
app/src/main/res/layout/fragment_home.xml
+2
-1
item_hot_view_adapter.xml
app/src/main/res/layout/item_hot_view_adapter.xml
+36
-25
layout_hotview.xml
app/src/main/res/layout/layout_hotview.xml
+2
-2
No files found.
app/src/main/java/com/mints/street/adapter/ItemEnterDestinationAdapter.kt
View file @
49584319
...
...
@@ -10,7 +10,6 @@ import com.mints.street.R
import
com.mints.street.bean.VreperienceBean
import
com.mints.street.databinding.ItemEnterDestinationAdapterBinding
import
com.mints.street.main.vr.DetailedActivity
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.RxUtils
...
...
app/src/main/java/com/mints/street/adapter/ItemHotViewAdapter.kt
View file @
49584319
...
...
@@ -2,6 +2,8 @@ package com.mints.street.adapter
import
android.content.Context
import
com.alibaba.android.vlayout.layout.LinearLayoutHelper
import
com.baidu.mapapi.model.LatLng
import
com.baidu.mapapi.utils.DistanceUtil.getDistance
import
com.blankj.utilcode.util.ActivityUtils.startActivity
import
com.bumptech.glide.Glide
import
com.fry.base.adapter.AbstractVLayoutBaseAdapter
...
...
@@ -9,14 +11,15 @@ import com.fry.base.adapter.BindingViewHolder
import
com.mints.street.R
import
com.mints.street.bean.HotViewBean
import
com.mints.street.databinding.ItemHotViewAdapterBinding
import
com.mints.street.main.home.HomeViewModel
import
com.mints.street.main.my.OpenvipActivity
import
com.mints.street.manager.UserManager
import
com.mints.street.webview.MintsWebViewActivity
import
me.goldze.mvvmhabit.utils.RxUtils
import
java.text.DecimalFormat
class
ItemHotViewAdapter
(
val
context
:
Context
,
var
list
:
List
<
HotViewBean
.
dataslist
>?)
:
class
ItemHotViewAdapter
(
val
context
:
Context
,
var
list
:
List
<
HotViewBean
.
dataslist
>?
,
val
viewModel
:
HomeViewModel
,
val
mCurrentLat
:
Double
,
val
mCurrentLon
:
Double
)
:
AbstractVLayoutBaseAdapter
<
ItemHotViewAdapterBinding
,
List
<
HotViewBean
.
dataslist
>?>(
context
,
list
,
1
context
,
list
,
1
)
{
override
fun
onBindViewHolder
(
holder
:
BindingViewHolder
<
ItemHotViewAdapterBinding
>,
position
:
Int
)
{
...
...
@@ -27,26 +30,28 @@ class ItemHotViewAdapter(val context: Context, var list: List<HotViewBean.datasl
//设置图片
Glide
.
with
(
mContext
).
load
(
img
).
into
(
holder
.
binding
.
image1
)
//设置名称
holder
.
binding
.
viewname
.
text
=
name
holder
.
binding
.
viewname
.
text
=
name
//设置距离
// holder.binding.tvDistance.text= distance.toString()
var
distance
:
Double
=
getDistance
(
LatLng
(
lat
!!
.
toDouble
(),
lng
!!
.
toDouble
()),
LatLng
(
mCurrentLat
,
mCurrentLon
))
holder
.
binding
.
tvDistance
.
text
=
"距离${DecimalFormat("
0.00
").format(distance/1000).toString()}km"
//设置景点简介
holder
.
binding
.
tvDescribe
.
text
=
desc
holder
.
binding
.
tvDescribe
.
text
=
desc
//设置点击事件
RxUtils
.
onMultiClick
(
holder
.
itemView
){
RxUtils
.
onMultiClick
(
holder
.
itemView
)
{
//判断是否当前是否是会员,
if
(!
UserManager
.
INSTANCE
.
userIsLogin
()){
if
(!
UserManager
.
INSTANCE
.
userIsLogin
())
{
//否-跳转到开通vip界面
startActivity
(
OpenvipActivity
::
class
.
java
)
}
else
{
//是-继续浏览,
}
else
{
viewModel
.
authorized
(
list
?.
get
(
position
)
?.
name
,
list
?.
get
(
position
)
?.
lat
?.
toDouble
(),
list
?.
get
(
position
)
?.
lng
?.
toDouble
())
}
}
}
}
override
fun
getItemCount
()
=
list
?.
size
?:
0
override
fun
getItemCount
()
=
list
?.
size
?:
0
override
fun
onCreateLayoutHelper
()
=
LinearLayoutHelper
()
override
fun
getLayoutId
(
viewType
:
Int
)
=
R
.
layout
.
item_hot_view_adapter
...
...
app/src/main/java/com/mints/street/bean/HotViewBean.kt
View file @
49584319
...
...
@@ -11,5 +11,6 @@ class HotViewBean : Serializable {
val
lat
:
String
?
=
null
val
lng
:
String
?
=
null
val
name
:
String
?
=
null
val
distance
:
Double
?
=
null
}
}
app/src/main/java/com/mints/street/main/MainActivity.kt
View file @
49584319
...
...
@@ -51,7 +51,6 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
R
.
id
.
menu_home
->
{
if
(
UserManager
.
INSTANCE
.
userIsLogin
()
&&
UserManager
.
INSTANCE
.
getVipFlag
())
{
binding
.
mainViewpager
.
setCurrentItem
(
3
,
false
)
}
else
{
binding
.
mainViewpager
.
setCurrentItem
(
0
,
false
)
}
...
...
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
View file @
49584319
...
...
@@ -42,8 +42,9 @@ import me.goldze.mvvmhabit.utils.SPUtils
* 首页页面
*/
class
HomeFragment
()
:
BaseFragment
<
FragmentHomeBinding
,
HomeViewModel
>(),
SensorEventListener
{
private
val
hotViewDialog
by
lazy
{
HotViewDialog
(
requireActivity
(),
viewModel
,
this
).
init
()
}
private
val
viewrecommedDialog
by
lazy
{
ViewRecommedDialog
(
requireActivity
(),
viewModel
,
this
).
init
()
}
private
val
viewrecommedDialog
by
lazy
{
ViewRecommedDialog
(
requireActivity
(),
viewModel
,
this
).
init
()
}
companion
object
{
val
IS_FIRST_OPEN
:
String
=
"isFirstOpen"
}
...
...
@@ -116,6 +117,8 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
override
fun
initData
()
{
super
.
initData
()
geoCoder
()
Handler
().
postDelayed
({
isScrollLayoutClose
=
true
},
2000
)
RxUtils
.
onMultiClick
(
binding
.
stbBgSearch
)
{
...
...
@@ -140,9 +143,10 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
}
//点击热门景点
RxUtils
.
onMultiClick
(
binding
.
lyHotview
)
{
hotViewDialog
.
show
()
}
RxUtils
.
onMultiClick
(
binding
.
lyHotview
,
{
val
hotViewDialog
:
HotViewDialog
?=
HotViewDialog
(
requireActivity
(),
viewModel
,
currentLat
,
currentLon
,
this
)
hotViewDialog
?.
init
()
?.
show
()
})
viewModel
.
getMapBean
()
}
...
...
@@ -205,6 +209,8 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
KLog
.
a
(
"百度map"
,
"移动结束"
)
currentLat
=
status
?.
target
?.
latitude
?:
0.0
currentLon
=
status
?.
target
?.
longitude
?:
0.0
KLog
.
e
(
"zsf__"
,
"=======移动结束=======${currentLat}================${currentLon}===================="
)
currentMapZoom
=
status
?.
zoom
?:
0f
// 发起反地理编码请求
mSearch
.
reverseGeoCode
(
ReverseGeoCodeOption
().
location
(
status
?.
target
))
...
...
@@ -354,7 +360,6 @@ class HomeFragment() : BaseFragment<FragmentHomeBinding, HomeViewModel>(), Senso
*/
fun
updateGesture
(
isMove
:
Boolean
)
{
if
(
isMove
)
{
mUiSettings
?.
isZoomGesturesEnabled
=
false
}
else
{
...
...
app/src/main/java/com/mints/street/main/home/HomeViewModel.kt
View file @
49584319
...
...
@@ -234,4 +234,26 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}
)
}
fun
authorized
(
name
:
String
?,
lat
:
Double
?=
0.0
,
lng
:
Double
?=
0.0
)
{
ApiModel
.
authorized
().
safeSubscribe
(
object
:
HttpSubscribeImpl
<
BaseResponse
<
AuthorizedBean
>>(
this
@HomeViewModel
,
false
)
{
override
fun
onBusinessSuccess
(
response
:
BaseResponse
<
AuthorizedBean
>)
{
MintsWebViewActivity
.
startWebView
(
name
,
MintsWebViewActivity
.
toGoogleVR
(
response
.
result
.
u
,
response
.
result
.
gk
,
response
.
result
.
base
,
lat
.
toString
(),
lng
.
toString
(),
response
.
result
.
ut
)
)
}
})
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/utils/GetJuLiUtils.java
0 → 100644
View file @
49584319
package
com
.
mints
.
street
.
utils
;
public
class
GetJuLiUtils
{
private
static
final
double
EARTH_RADIUS
=
6378137.0
;
public
static
double
getDistance
(
double
longitude
,
double
latitue
,
double
longitude2
,
double
latitue2
){
double
lat1
=
rad
(
latitue
);
double
lat2
=
rad
(
latitue2
);
double
a
=
lat1
-
lat2
;
double
b
=
rad
(
longitude
)-
rad
(
longitude2
);
double
s
=
2
*
Math
.
asin
(
Math
.
sqrt
(
Math
.
pow
(
Math
.
sin
(
a
/
2
),
2
)+
Math
.
cos
(
lat1
)*
Math
.
cos
(
lat2
)*
Math
.
pow
(
Math
.
sin
(
b
/
2
),
2
)));
s
=
s
*
EARTH_RADIUS
;
s
=
Math
.
round
(
s
*
10000
)/
10000
;
return
s
;
}
private
static
double
rad
(
double
d
){
return
d
*
Math
.
PI
/
180.0
;
}
}
app/src/main/java/com/mints/street/widget/dialog/HotViewDialog.kt
View file @
49584319
...
...
@@ -16,58 +16,60 @@ import com.mints.street.main.home.HomeFragment
import
com.mints.street.main.home.HomeViewModel
import
com.mints.street.widget.GridItemDecoration
class
HotViewDialog
(
context
:
FragmentActivity
,
viewModel
:
HomeViewModel
,
homeFragment
:
HomeFragment
)
{
class
HotViewDialog
(
context
:
FragmentActivity
,
viewModel
:
HomeViewModel
,
mCurrentLat
:
Double
,
mCurrentLon
:
Double
,
homeFragment
:
HomeFragment
)
{
private
var
mBottomSheetDialog
:
BottomSheetDialog
?=
null
private
var
context
:
FragmentActivity
private
var
viewModel
:
HomeViewModel
?=
null
private
var
homeFragment
:
HomeFragment
?=
null
private
var
mBottomSheetDialog
:
BottomSheetDialog
?
=
null
private
var
context
:
FragmentActivity
private
var
viewModel
:
HomeViewModel
?
=
null
private
var
homeFragment
:
HomeFragment
?
=
null
private
var
mCurrentLat
:
Double
?
=
null
private
var
mCurrentLon
:
Double
?
=
null
private
var
vLayout
:
VirtualLayoutManager
?
=
null
private
var
mAdapter
:
DelegateAdapter
?
=
null
private
var
itemHotViewAdapter
:
ItemHotViewAdapter
?=
null
// private var itemHotViewAdapter: ItemEnterDestinationAdapter?=null
private
var
itemHotViewAdapter
:
ItemHotViewAdapter
?
=
null
// private var itemHotViewAdapter: ItemEnterDestinationAdapter?=null
init
{
this
.
context
=
context
this
.
viewModel
=
viewModel
this
.
homeFragment
=
homeFragment
this
.
context
=
context
this
.
viewModel
=
viewModel
this
.
homeFragment
=
homeFragment
this
.
mCurrentLat
=
mCurrentLat
this
.
mCurrentLon
=
mCurrentLon
}
//
fun
init
():
HotViewDialog
{
fun
init
():
HotViewDialog
{
//创建弹窗
if
(
mBottomSheetDialog
!=
null
)
return
this
mBottomSheetDialog
=
BottomSheetDialog
(
context
)
val
view1
:
View
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
layout_hotview
,
null
)
if
(
mBottomSheetDialog
!=
null
)
return
this
mBottomSheetDialog
=
BottomSheetDialog
(
context
)
val
view1
:
View
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
layout_hotview
,
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
)
val
iv_close
:
ImageView
=
view1
.
findViewById
(
R
.
id
.
iv_close
)
val
recycler_view
:
RecyclerView
=
view1
.
findViewById
(
R
.
id
.
recycler_view
)
//添加下划线
view1
.
findViewById
<
RecyclerView
>(
R
.
id
.
recycler_view
)
.
addItemDecoration
(
GridItemDecoration
(
context
,
DividerItemDecoration
.
VERTICAL
))
vLayout
=
VirtualLayoutManager
(
context
!!
);
mAdapter
=
DelegateAdapter
(
vLayout
,
false
)
mAdapter
=
DelegateAdapter
(
vLayout
,
false
)
recycler_view
.
layoutManager
=
vLayout
recycler_view
.
adapter
=
mAdapter
// if (itemHotViewAdapter == null){
// itemHotViewAdapter = ItemHotViewAdapter(context!!, listOf("1","3","1","3","1","3","1","3"))
// mAdapter?.addAdapter(itemHotViewAdapter)
// }
// itemHotViewAdapter!!.list=listOf("1","3","1","3","1","3","1","3")
viewModel
?.
getHotView
()
viewModel
?.
hotviewData
?.
observe
(
homeFragment
!!
,
androidx
.
lifecycle
.
Observer
{
if
(
itemHotViewAdapter
==
null
){
itemHotViewAdapter
=
ItemHotViewAdapter
(
context
!!
,
it
.
list
)
if
(
itemHotViewAdapter
==
null
)
{
itemHotViewAdapter
=
ItemHotViewAdapter
(
context
!!
,
it
.
list
,
viewModel
!!
,
mCurrentLat
!!
,
mCurrentLon
!!
)
mAdapter
?.
addAdapter
(
itemHotViewAdapter
)
}
mAdapter
?.
notifyDataSetChanged
()
})
iv_close
.
setOnClickListener
{
iv_close
.
setOnClickListener
{
mBottomSheetDialog
!!
.
dismiss
()
}
return
this
}
...
...
app/src/main/res/layout/fragment_home.xml
View file @
49584319
...
...
@@ -53,10 +53,11 @@
android:id=
"@+id/ly_hotview"
android:layout_width=
"35dp"
android:layout_height=
"35dp"
android:padding=
"3dp"
android:layout_marginTop=
"15dp"
android:src=
"@mipmap/icon_hotview"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/image_map_
history
"
/>
app:layout_constraintTop_toBottomOf=
"@id/image_map_
change_icon
"
/>
<ImageView
android:id=
"@+id/image_location_icon"
...
...
app/src/main/res/layout/item_hot_view_adapter.xml
View file @
49584319
...
...
@@ -43,6 +43,9 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"10dp"
android:ellipsize=
"end"
android:maxEms=
"5"
android:maxLines=
"1"
android:text=
"景点名称"
android:textColor=
"@color/black"
android:textSize=
"18dp"
...
...
@@ -54,10 +57,9 @@
android:layout_width=
"1dp"
android:layout_height=
"14dp"
android:background=
"@color/black"
app:layout_constraintBottom_toBottomOf=
"@+id/tv_distance"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"@+id/viewname"
app:layout_constraintStart_toEndOf=
"@+id/viewname"
app:layout_constraintTop_toTopOf=
"@+id/
tv_distanc
e"
app:layout_constraintTop_toTopOf=
"@+id/
viewnam
e"
tools:ignore=
"MissingConstraints"
/>
<TextView
...
...
@@ -65,37 +67,46 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"2dp"
android:text=
"距离"
android:text=
"距离
1897.8km
"
android:textColor=
"#99000000"
android:textSize=
"14dp"
android:textSize=
"12dp"
app:layout_constraintBottom_toBottomOf=
"@+id/viewname"
app:layout_constraintStart_toEndOf=
"@+id/view"
app:layout_constraintTop_toTopOf=
"@+id/viewname"
tools:text=
"距离"
/>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:orientation=
"vertical"
app:layout_constraintBottom_toBottomOf=
"@+id/image1"
app:layout_constraintStart_toStartOf=
"@+id/viewname"
app:layout_constraintTop_toBottomOf=
"@+id/viewname"
tools:ignore=
"MissingConstraints"
>
<TextView
android:id=
"@+id/tv_describe"
android:layout_width=
"wrap_content
"
android:layout_width=
"200dp
"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"10dp"
android:layout_marginBottom=
"5dp"
android:text=
"景点介绍。。。"
android:textColor=
"#99000000"
app:layout_constraintStart_toEndOf=
"@+id/image1"
app:layout_constraintTop_toBottomOf=
"@+id/viewname"
tools:text=
"景点介绍。。。"
/>
android:textSize=
"12sp"
/>
<TextView
android:id=
"@+id/textView5"
android:layout_width=
"7
0dp"
android:layout_width=
"10
0dp"
android:layout_height=
"30dp"
android:layout_marginLeft=
"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/image1"
app:layout_constraintStart_toEndOf=
"@+id/image1"
tools:text=
"看街景"
/>
android:textSize=
"12sp"
/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>
...
...
app/src/main/res/layout/layout_hotview.xml
View file @
49584319
...
...
@@ -8,8 +8,8 @@
android:id=
"@+id/iv_close"
android:layout_width=
"20dp"
android:layout_height=
"20dp"
android:layout_marginTop=
"
8
dp"
android:layout_marginRight=
"
8
dp"
android:layout_marginTop=
"
10
dp"
android:layout_marginRight=
"
10
dp"
android:layout_marginBottom=
"5dp"
android:src=
"@mipmap/icon_hot_view_close"
android:layout_gravity=
"end"
/>
...
...
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