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
a36b1330
Commit
a36b1330
authored
Aug 03, 2021
by
张释方
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加新人福利弹出逻辑
parent
6c1c6389
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
30 deletions
+13
-30
HomeFragment.kt
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
+5
-1
HomeViewModel.kt
...src/main/java/com/mints/street/main/home/HomeViewModel.kt
+8
-29
No files found.
app/src/main/java/com/mints/street/main/home/HomeFragment.kt
View file @
a36b1330
...
...
@@ -41,6 +41,10 @@ import me.goldze.mvvmhabit.utils.SPUtils
*/
class
HomeFragment
:
BaseFragment
<
FragmentHomeBinding
,
HomeViewModel
>(),
SensorEventListener
{
companion
object
{
val
IS_FIRST_OPEN
:
String
=
"isFirstOpen"
}
private
var
mBaiduMap
:
BaiduMap
?
=
null
// 定位相关
...
...
@@ -122,7 +126,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
})
viewModel
.
mapbeanData
.
observe
(
this
,
Observer
<
MapBean
>
{
DialogUtils
.
showbennfitsDialog
(
context
!!
,
viewModel
,
it
.
innerPlaces
?.
places
)
DialogUtils
.
showbennfitsDialog
(
context
!!
,
viewModel
,
it
.
innerPlaces
?.
places
)
})
}
...
...
app/src/main/java/com/mints/street/main/home/HomeViewModel.kt
View file @
a36b1330
...
...
@@ -20,6 +20,7 @@ import com.mints.street.webview.MintsWebViewActivity
import
me.goldze.mvvmhabit.base.AppManager
import
me.goldze.mvvmhabit.base.BaseViewModel
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.SPUtils
import
me.tatarka.bindingcollectionadapter2.ItemBinding
import
java.io.BufferedReader
import
java.io.InputStreamReader
...
...
@@ -77,11 +78,11 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}
var
mapbeanData
=
MutableLiveData
<
MapBean
>()
var
mapbeanData
=
MutableLiveData
<
MapBean
>()
fun
getMapBean
()
{
val
assets
=
AppManager
.
getAppManager
().
currentActivity
.
assets
val
stringBuilder
=
StringBuilder
()
var
mapBean
:
MapBean
?=
null
var
mapBean
:
MapBean
?
=
null
try
{
//通过管理器打开文件并读取
val
bf
=
BufferedReader
(
...
...
@@ -92,7 +93,11 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
while
(
bf
.
readLine
().
also
{
line
=
it
}
!=
null
)
{
stringBuilder
.
append
(
line
)
}
mapbeanData
.
value
=
Gson
().
fromJson
(
stringBuilder
.
toString
(),
MapBean
::
class
.
java
)
if
(
SPUtils
.
getInstance
().
decodeBoolean
(
HomeFragment
.
IS_FIRST_OPEN
,
true
)){
mapbeanData
.
value
=
Gson
().
fromJson
(
stringBuilder
.
toString
(),
MapBean
::
class
.
java
)
SPUtils
.
getInstance
().
encode
(
HomeFragment
.
IS_FIRST_OPEN
,
false
)
}
mapBean
=
Gson
().
fromJson
(
stringBuilder
.
toString
(),
MapBean
::
class
.
java
)
}
catch
(
e
:
Exception
)
{
...
...
@@ -148,30 +153,4 @@ class HomeViewModel(application: Application) : BaseViewModel(application) {
}
}
}
//获取vr街景数据
val
VrmapBean
:
MutableLiveData
<
VrmapBean
>
=
MutableLiveData
()
fun
vrPlaces
()
{
//无参数传递
ApiModel
.
vrPlaces
(
lifecycleProvider
).
safeSubscribe
(
object
:
HttpSubscribeImpl
<
BaseResponse
<
VrmapBean
>>(
this
@HomeViewModel
,
true
)
{
override
fun
onBusinessSuccess
(
response
:
BaseResponse
<
VrmapBean
>)
{
VrmapBean
.
value
=
response
.
result
val
a
:
MutableList
<
ScenicSpotBean
>
=
ArrayList
()
for
(
item
in
response
.
result
.
internal
!!
)
{
a
.
add
(
ScenicSpotBean
(
name
=
item
.
name
,
url
=
item
.
url
,
starRating
=
item
.
stars
,
images
=
item
.
img
))
}
// AppDatabase.instance().scenicSpotDao().addVRFreeZoneAll(a)
// for(item in AppDatabase.instance().scenicSpotDao().getVRFreeZoneAll()){
// KLog.e("AppDatabase.instance().scenicSpotDao().getVRFreeZoneAll()",item.toString())
// }
}
override
fun
onError
(
e
:
Throwable
)
{
KLog
.
e
(
"vrPlaces"
,
"请求失败 : $e"
)
}
}
)
}
}
\ 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