Commit 9fa3b5fe authored by fengruiyu's avatar fengruiyu

1.首页的功能已完成

2.首页的底部移动布局已完成
3.数据填充已完成
4.搜索页面的数据和页面已完成
parent 6ef43e37
...@@ -173,6 +173,9 @@ ...@@ -173,6 +173,9 @@
android:screenOrientation="behind" android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" /> android:windowSoftInputMode="adjustResize|stateHidden" />
<activity android:name=".main.vr.PanoramicActivity" /> <activity android:name=".main.vr.PanoramicActivity" />
<activity android:name=".webview.MintsWebViewActivity">
</activity>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
{
"innerPlaces": {
"places": [
{
"images": [
"http://cdn.xinzhi.space/default/E2AAA744ED914646DC64478C5106FD7F.jpg",
"http://cdn.xinzhi.space/default/20F7B7684957D05F1CD10E3DFF58B967.jpg",
"http://cdn.xinzhi.space/default/F40219AA186856910BE7D1C4C482BA80.jpg"
],
"name": "北京天安门",
"latitude": 39.914018,
"longitude": 116.404092
},
{
"images": [
"http://cdn.xinzhi.space/default/E3DC5337FDD3876669AA77E3F6DDC0B7.jpg",
"http://cdn.xinzhi.space/default/CA2DB8F1EE181B8E87ED5480144AA668.jpg",
"http://cdn.xinzhi.space/default/39A5412BF562FB996E96FC91528C5E03.jpg"
],
"name": "广州新电视塔",
"latitude": 23.112908,
"longitude": 113.33107
},
{
"images": [
"http://cdn.xinzhi.space/default/03E0372260E4869D4EE1A7BE373359D8.jpg",
"http://cdn.xinzhi.space/default/6E7EC6F9CCF44EE23140EB4D986213A9.jpg",
"http://cdn.xinzhi.space/default/503FE08A95AA5B9B28FFBC598E32A787.jpg"
],
"name": "天津之眼",
"latitude": 39.159733,
"longitude": 117.192852
},
{
"images": [
"http://cdn.xinzhi.space/default/A2A00CD5DEB7E38876B74D9CA7C4255E.jpg",
"http://cdn.xinzhi.space/default/92DCE40BD30CA9E29B66DCCD48F1573D.jpg",
"http://cdn.xinzhi.space/default/83CDB0549D7A4501390DA3BD56B88EAB.jpg"
],
"name": "武汉长江大桥",
"latitude": 30.552037,
"longitude": 114.300509
},
{
"images": [
"http://cdn.xinzhi.space/default/13C72F98620713D970BBD4358BA63C61.jpg",
"http://cdn.xinzhi.space/default/46F5B678F38C85C6021BFDC26046A3FF.jpg",
"http://cdn.xinzhi.space/default/BB538C787458211661E2C1F48AA11E07.jpg"
],
"name": "上海外滩中心",
"latitude": 31.243627,
"longitude": 121.497028
},
{
"images": [
"http://cdn.xinzhi.space/default/B6E64CB2606BB5ED1855DDFE80CA55F1.jpg",
"http://cdn.xinzhi.space/default/9B7473907CA6403A5F65BFB12B162565.jpg",
"http://cdn.xinzhi.space/default/6C39DDC648F72FDF3ECD88AAE936EB72.jpg"
],
"name": "杭州灵隐寺",
"latitude":30.246009,
"longitude": 120.108616
},
{
"images": [
"http://cdn.xinzhi.space/default/26BD0988B08DED9550239D62E12C0243.jpg",
"http://cdn.xinzhi.space/default/E0EC6AC5AF99041D13C98C622DF19EFC.jpg",
"http://cdn.xinzhi.space/default/4DDF1BBF493EFC484E3F640CEF7AED72.jpg"
],
"name": "敦煌莫高窟",
"latitude": 40.049087,
"longitude": 94.81471
},
{
"images": [
"http://cdn.xinzhi.space/default/1C3C454A9EA79FBCC4027116D1D280A5.jpg",
"http://cdn.xinzhi.space/default/DFD557DB2242B99E9314D02407C10F18.jpg",
"http://cdn.xinzhi.space/default/8ACBA2D5DFFE96A56BD02E6F8DBB0319.jpg"
],
"name": "西安大唐不夜城",
"latitude": 34.210359,
"longitude": 108.970516
},
{
"images": [
"http://cdn.xinzhi.space/default/7A10F9C4B92BFEDAAA53D1EDDE742295.jpg",
"http://cdn.xinzhi.space/default/65980ADEF7CC15D4A923EC3999C3064B.jpg",
"http://cdn.xinzhi.space/default/8A84F8591F4C7FC1E15BDD1994F4FF91.jpg"
],
"name": "张家界天门山国家森林公园",
"latitude": 29.074901,
"longitude": 110.481974
},
{
"images": [
"http://cdn.xinzhi.space/default/E7AA699B96353E87E6C4B5DD4F2D244D.jpg",
"http://cdn.xinzhi.space/default/D326B45DEF5A5C42C3E77E5224A4E6AB.jpg",
"http://cdn.xinzhi.space/default/A1CF3C88A1452B5355B48B51C5DD7CFB.jpg"
],
"name": "苏州园林",
"latitude": 31.331247,
"longitude": 120.635782
}
],
"remark": "首页搜索-境内"
},
"homePlaces": {
"places": [
{
"images": [
"http://cdn.xinzhi.space/default/CBCAD69A2EC1401E479F0BFC36B69C4D.jpg",
"http://cdn.xinzhi.space/default/34C93B0DB6701B9521D2EE0C230C5281.jpg",
"http://cdn.xinzhi.space/default/CC6A745EFB4F04F1F5334112559B0F6F.jpg"
],
"name": "西藏布达拉宫",
"latitude": 29.658335,
"longitude": 91.126159
},
{
"images": [
"http://cdn.xinzhi.space/default/552A2CC59E3D478F811EC73B0FA5C58A.jpg",
"http://cdn.xinzhi.space/default/81E4B707B2657ECE848CA651E4469CDA.jpg",
"http://cdn.xinzhi.space/default/BB6A5F3DE940636273988464B796AC46.jpg"
],
"name": "长沙橘子洲景区",
"latitude":28.192888,
"longitude": 112.968618
},
{
"images": [
"http://cdn.xinzhi.space/default/30FE64076B4C9E06F544BF175AC65983.jpg",
"http://cdn.xinzhi.space/default/DA8F94CCEAC8659BE383E49770ADD0E7.jpg",
"http://cdn.xinzhi.space/default/5522899728A44CFF8D44F92BA76A9E85.jpg"
],
"name": "北京故宫博物馆",
"latitude": 39.913959,
"longitude": 116.40399
},
{
"images": [
"http://cdn.xinzhi.space/default/5BEF22B14C879F3F686F3EAE9AB7C508.jpg",
"http://cdn.xinzhi.space/default/A05AA0A6D76EADC41CBCED1F25C35152.jpg",
"http://cdn.xinzhi.space/default/BBEB5D77C3E1150939EA9A0549805A1F.jpg"
],
"name": "重庆洪崖洞",
"latitude": 29.568777,
"longitude": 106.585268
}
],
"remark": "首页展示"
},
"outerPlaces": {
"places": [
{
"images": [
"http://cdn.xinzhi.space/default/011A95312678636FF92507F95F96EBE4.jpg",
"http://cdn.xinzhi.space/default/FCBA6018725F1EF1BF24ED3EBC059DDD.jpg",
"http://cdn.xinzhi.space/default/DA41427ECA89D9D9BD9D92F317AB48B2.jpg"
],
"name": "俄罗斯莫斯科红场"
},
{
"images": [
"http://cdn.xinzhi.space/default/4A68426CBDCC770BA256EEBFD89CF720.jpg",
"http://cdn.xinzhi.space/default/07104B0C9D988EF028973B3F36DBD0D6.jpg",
"http://cdn.xinzhi.space/default/B4D7F331E85B86EE6337DFEB105EAB4E.jpg"
],
"name": "梵蒂冈城"
},
{
"images": [
"http://cdn.xinzhi.space/default/7246BC8FA5D27FD1AF5A2A675E72EF41.jpg",
"http://cdn.xinzhi.space/default/AFF9DE280B1AF7EEABB0604CBACE954F.jpg",
"http://cdn.xinzhi.space/default/CD06E6722BB80A520D91AF930D4AC9E2.jpg"
],
"name": "剑桥大学"
},
{
"images": [
"http://cdn.xinzhi.space/default/47A880B1DE0F310D205C13C1721606E9.jpg",
"http://cdn.xinzhi.space/default/3CEFCD51A615EEBFA25E3A5750524359.jpg",
"http://cdn.xinzhi.space/default/BF120E7A407908373DA6D325068E2FAA.jpg"
],
"name": "伦敦大本钟"
},
{
"images": [
"http://cdn.xinzhi.space/default/D5E81B9B5E278631A72B5BEFFA185202.jpg",
"http://cdn.xinzhi.space/default/3B8CDE28649E95500CAA9BE6274A3A49.jpg",
"http://cdn.xinzhi.space/default/849A8D36547D7B09BAF288317C37E8EA.jpg"
],
"name": "柏林大教堂"
},
{
"images": [
"http://cdn.xinzhi.space/default/A3E5599B4FED1A6ADC2FC28341B261EE.jpg",
"http://cdn.xinzhi.space/default/1A86E3AF4C95395B25E3763D7163D5A2.jpg",
"http://cdn.xinzhi.space/default/BCAB35365DE10FB96AD113EBC81BB708.jpg"
],
"name": "德国历史博物馆"
},
{
"images": [
"http://cdn.xinzhi.space/default/C01BC035BA6D42AF140A8A3961693C4E.jpg",
"http://cdn.xinzhi.space/default/D24A5AD9AD57B57F1A51BA32553E6BE8.jpg",
"http://cdn.xinzhi.space/default/C3BBE857A1F09EF76227361CF98E582D.jpg"
],
"name": "日本东京塔"
},
{
"images": [
"http://cdn.xinzhi.space/default/CFC22343831F6FFD90553254669D5F2D.jpg",
"http://cdn.xinzhi.space/default/7E773ACF24391CF3B1B3237BF16B734E.jpg",
"http://cdn.xinzhi.space/default/9B9BB9A5541D1524FF35AA4915CE8AD8.jpg"
],
"name": "罗马斗兽场"
},
{
"images": [
"http://cdn.xinzhi.space/default/9D7850C3895C33730BA3631C50B17FE8.jpg",
"http://cdn.xinzhi.space/default/1176E3732CAECD7F375F1D1CAD3F067F.jpg",
"http://cdn.xinzhi.space/default/BA119EAE3D700DEFF7E8BFCDBDECC4CC.jpg"
],
"name": "泰国清莱白庙"
},
{
"images": [
"http://cdn.xinzhi.space/default/98A4F38E8D9F32604FF6A0BB2A13CCEE.jpg",
"http://cdn.xinzhi.space/default/C3B531A95824B994FB73BA68B477CE8D.jpg",
"http://cdn.xinzhi.space/default/B8D9E0D0A0C3F34AA11F13B328C8B28E.jpg"
],
"name": "伦敦白金汉宫"
},
{
"images": [
"http://cdn.xinzhi.space/default/DA3C3FADC9993CA78C6425D4C90687B2.jpg",
"http://cdn.xinzhi.space/default/6E2EFFF19E46E2F12398DC7705B347F9.jpg",
"http://cdn.xinzhi.space/default/47C00B7CF073C9AFF2FFF2BDB77E0F0E.jpg"
],
"name": "美国阿灵顿公墓"
},
{
"images": [
"http://cdn.xinzhi.space/default/8D544E9FA482A5645084A6501FD969AF.jpg",
"http://cdn.xinzhi.space/default/5BC6215FEC91B8AB8EF748A4DCAC5084.jpg",
"http://cdn.xinzhi.space/default/B1A731FA331E02E131D2283E4A33ACB4.jpg"
],
"name": "加拿大国家电视塔"
}
],
"remark": "首页搜索-境外"
}
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
#panorama {width:100%; height: 100%;}
#result {width:100%;font-size:12px;}
</style>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=3P5XyK1HTYOONlRYqUGsqGLFKHcc1Onb"></script>
<title>显示/隐藏导航控件</title>
</head>
<body>
<div id="panorama"></div>
</body>
</html>
<script type="text/javascript">
//统计页面
var urlParams = new Array();
var urlParamslength = 0;
function setParams() {
var param = location.search;
if (param != null && param.length > 0) {
param = param.substring(1, param.length);
var allparam = param.split('&');
if (allparam != null && allparam.length > 0) {
for (var i = 0; i < allparam.length; i++) {
var oneparam = allparam[i].split('=');
if (oneparam != null && oneparam.length > 1) {
urlParams[oneparam[0]] = oneparam[1];
urlParamslength++;
}
}
}
}
}
setParams();
function getParam(key) {
if (urlParamslength == 0) {
setParams();
}
return (urlParams[key] == undefined || urlParams[key] == null || urlParams[key] == 'null') ? "" : urlParams[key];
}
var a=getParam("a");//其中116.404表示经度,
var b=getParam("b");//39.915表示纬度
var c=getParam("c");//39.915表示纬度
var panorama = new BMap.Panorama('panorama',{
linksControl: false, //显示道路指示控件
albumsControl: c==1 ,//默认为不显示相册控件,默认值为false
// anchor: BMAP_ANCHOR_TOP_RIGHT,
//设置偏移量,距离上面15px,距离左边100px(距离那边受anchor位置的影响)
offset: new BMap.Size(0, 0),
//设置相册的长度和图片大小,相册的最大宽度为60%,相册内图片的大小为80px
maxWidth: '100%',
imageHeight: 80
}); //默认为显示导航控件
// a=116.316169
// b=40.005567
panorama.setPosition(new BMap.Point(a,b));
// panorama.setPov({pitch: 5.04, heading: 343.92});
</script>
...@@ -46,10 +46,18 @@ class HistoryRecordAdapter(val context: Context, var name: String? = null) : ...@@ -46,10 +46,18 @@ class HistoryRecordAdapter(val context: Context, var name: String? = null) :
return Gson().fromJson<List<String>>(string, List::class.java) return Gson().fromJson<List<String>>(string, List::class.java)
} }
fun addHistoryData(list:List<String> ) { fun addHistoryData(addName:String) {
val instance = SPUtils.getInstance(SearchMapActivity.HISTORY_NAME) val instance = SPUtils.getInstance(SearchMapActivity.HISTORY_NAME)
instance.encode("name", Gson().toJson(list).toString()) if (listName ==null ){
listName = ArrayList<String>()
}
for (index in listName!!.indices){
if (listName!![index] == addName || addName == listName!![index]){
}
}
instance?.encode("name", Gson().toJson(listName).toString())
} }
override fun getItemCount() = 1 override fun getItemCount() = 1
......
...@@ -2,27 +2,64 @@ package com.mints.street.adapter ...@@ -2,27 +2,64 @@ package com.mints.street.adapter
import android.content.Context import android.content.Context
import com.alibaba.android.vlayout.layout.LinearLayoutHelper import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.bumptech.glide.GlideBuilder
import com.fry.base.adapter.AbstractVLayoutBaseAdapter import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder import com.fry.base.adapter.BindingViewHolder
import com.fry.base.utils.ImageLoader
import com.mints.street.R import com.mints.street.R
import com.mints.street.bean.Places
import com.mints.street.databinding.ItemPopularSceneAdapterBinding import com.mints.street.databinding.ItemPopularSceneAdapterBinding
import com.mints.street.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.utils.ImageUtils
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.RxUtils
/** /**
* Created by 冯瑞雨 on 2021/7/14. * Created by 冯瑞雨 on 2021/7/14.
* 热门景区的adapter * 热门景区的adapter
*/ */
class PopularSceneAdapter(val context: Context, var list: List<String>) : class PopularSceneAdapter(val context: Context, var list: List<Places>? = null) :
AbstractVLayoutBaseAdapter<ItemPopularSceneAdapterBinding, List<String>>(context, list, 2) { AbstractVLayoutBaseAdapter<ItemPopularSceneAdapterBinding, List<Places>>(context, list, 2) {
override fun onBindViewHolder( override fun onBindViewHolder(
holder: BindingViewHolder<ItemPopularSceneAdapterBinding>, holder: BindingViewHolder<ItemPopularSceneAdapterBinding>,
position: Int position: Int
) { ) {
KLog.e("PopularSceneAdapter",list.size) RxUtils.onMultiClick(holder.binding.bg){
MintsWebViewActivity.startWebView(list?.get(position)?.name
,latitude = list?.get(position)?.latitude.toString()
,longitude = list?.get(position)?.longitude.toString())
}
holder.binding.tvName.text = list?.get(position)?.name
if(list?.get(position)?.images!=null){
for ( index in list?.get(position)?.images!!.indices){
if (list?.get(position)?.images?.get(index)==null)return
when (index) {
0 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(list?.get(position)?.images?.get(index))
.setTargetView(holder.binding.image1).start()
}
1 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(list?.get(position)?.images?.get(index))
.setTargetView(holder.binding.image2).start()
}
else -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(list?.get(position)?.images?.get(index))
.setTargetView(holder.binding.image3).start()
}
}
}
}
} }
override fun getItemCount() = list.size override fun getItemCount() = if (list != null) {
list!!.size
} else {
0
}
override fun onCreateLayoutHelper() = LinearLayoutHelper() override fun onCreateLayoutHelper() = LinearLayoutHelper()
......
package com.mints.street.bean
/**
* Created by 冯瑞雨 on 2021/7/17.
*/
class MapBean(){
//首页搜索-境内
var innerPlaces:Attractions?=null
//首页展示
var homePlaces:Attractions?=null
//首页搜索-境外
var outerPlaces:Attractions?=null
}
/**
* 景点
*/
class Attractions(){
var places:List<Places>?=null
var remark:String? = null
}
/**
* 景点的名称和图片
*/
class Places(){
var images :List<String>?=null
var name :String?=null
var latitude:Double?=0.0
var longitude:Double?=0.0
}
\ No newline at end of file
package com.mints.street.main package com.mints.street.main
import android.Manifest import android.Manifest
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
...@@ -16,12 +17,14 @@ import com.mints.street.BR ...@@ -16,12 +17,14 @@ import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.databinding.ActivityMainBinding import com.mints.street.databinding.ActivityMainBinding
import com.mints.street.main.home.HomeFragment import com.mints.street.main.home.HomeFragment
import com.mints.street.main.home.SearchMapActivity
import com.mints.street.main.my.MyFragment import com.mints.street.main.my.MyFragment
import com.mints.street.main.vr.VRFragment import com.mints.street.main.vr.VRFragment
import com.mints.street.manager.UmengManager import com.mints.street.manager.UmengManager
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import com.umeng.analytics.MobclickAgent import com.umeng.analytics.MobclickAgent
import me.goldze.mvvmhabit.base.AppManager import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.ToastUtils import me.goldze.mvvmhabit.utils.ToastUtils
...@@ -58,6 +61,7 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() { ...@@ -58,6 +61,7 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
) )
// test // test
UmengManager.initUm() UmengManager.initUm()
...@@ -70,6 +74,7 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() { ...@@ -70,6 +74,7 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
......
package com.mints.street.main package com.mints.street.main
import android.app.Application import android.app.Application
import com.google.gson.Gson
import com.mints.street.bean.MapBean
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.base.BaseViewModel import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.io.BufferedReader
import java.io.InputStreamReader
/** /**
* Created by 冯瑞雨 on 2021/7/1. * Created by 冯瑞雨 on 2021/7/1.
*/ */
class MainViewModel(application : Application) :BaseViewModel(application) { class MainViewModel(application : Application) :BaseViewModel(application) {
fun getMapBean(){
val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder()
try {
//通过管理器打开文件并读取
val bf = BufferedReader(
InputStreamReader(
assets.open("map.json")))
var line: String?
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
}
KLog.e("json",stringBuilder.toString())
var mapBean = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e:Exception){
KLog.e("读取assets文件下的json出问题")
}
}
} }
\ No newline at end of file
package com.mints.street.main.home package com.mints.street.main.home
import com.mints.street.webview.MintsWebViewActivity
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
import me.goldze.mvvmhabit.binding.command.BindingCommand import me.goldze.mvvmhabit.binding.command.BindingCommand
...@@ -7,10 +8,12 @@ import me.goldze.mvvmhabit.binding.command.BindingCommand ...@@ -7,10 +8,12 @@ import me.goldze.mvvmhabit.binding.command.BindingCommand
/** /**
* Created by 冯瑞雨 on 2021/7/9. * Created by 冯瑞雨 on 2021/7/9.
*/ */
class HomeButtonItemVM(viewModel: HomeViewModel) : ItemViewModel<HomeViewModel?>(viewModel) { class HomeButtonItemVM(viewModel: HomeViewModel,val name:String?,val image1:String,
val image2:String,val image3:String,var latitude:String?,var longitude:String?) : ItemViewModel<HomeViewModel?>(viewModel) {
val onItemClick = BindingCommand<Any?>(BindingAction { val onItemClick = BindingCommand<Any?>(BindingAction {
SearchMapActivity.startSearchMapActivity() //SearchMapActivity.startSearchMapActivity()
MintsWebViewActivity.startWebView(name,latitude = latitude,longitude = longitude)
}) })
} }
\ No newline at end of file
...@@ -10,6 +10,7 @@ import android.os.Bundle ...@@ -10,6 +10,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import androidx.lifecycle.Observer
import com.baidu.location.BDLocation import com.baidu.location.BDLocation
import com.baidu.location.BDLocationListener import com.baidu.location.BDLocationListener
import com.baidu.location.LocationClient import com.baidu.location.LocationClient
...@@ -25,6 +26,7 @@ import com.mints.street.BR ...@@ -25,6 +26,7 @@ import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.bean.PositioningBean import com.mints.street.bean.PositioningBean
import com.mints.street.databinding.FragmentHomeBinding import com.mints.street.databinding.FragmentHomeBinding
import com.mints.street.webview.MintsWebViewActivity
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
...@@ -38,7 +40,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -38,7 +40,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
private var mBaiduMap: BaiduMap? = null private var mBaiduMap: BaiduMap? = null
private val mBitmapDescriptor = BitmapDescriptorFactory.fromResource(R.mipmap.icon_gcoding) private val mBitmapDescriptor = BitmapDescriptorFactory.fromResource(R.mipmap.positioning_icon)
private var mRecommendStopSearch: RecommendStopSearch? = null private var mRecommendStopSearch: RecommendStopSearch? = null
...@@ -49,12 +51,23 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -49,12 +51,23 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
private var mCurrentMode: MyLocationConfiguration.LocationMode? = null private var mCurrentMode: MyLocationConfiguration.LocationMode? = null
private var mSensorManager: SensorManager? = null private var mSensorManager: SensorManager? = null
private var lastX = 0.0 private var lastX = 0.0
//// 此处设置开发者获取到的方向信息,顺时针0-360 //// 此处设置开发者获取到的方向信息,顺时针0-360
private var mCurrentDirection = 0 private var mCurrentDirection = 0
//纬度 //纬度
private var mCurrentLat = 0.0 private var mCurrentLat = 0.0
//经度 //经度
private var mCurrentLon = 0.00 private var mCurrentLon = 0.00
//当前的经纬度
//纬度
private var currentLat = 0.0
//经度
private var currentLon = 0.0
//设置定位数据的精度信息,单位:米 //设置定位数据的精度信息,单位:米
private var mCurrentAccracy = 0f private var mCurrentAccracy = 0f
...@@ -79,8 +92,23 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -79,8 +92,23 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
override fun initData() { override fun initData() {
super.initData() super.initData()
RxUtils.onMultiClick(binding.stbBgSearch) {
SearchMapActivity.startSearchMapActivity(this)
}
RxUtils.onMultiClick(binding.ivClick){
MintsWebViewActivity.startWebView(""
,latitude = currentLat.toString(),longitude = currentLon.toString())
}
viewModel.getMapBean()
}
viewModel.add() override fun initViewObservable() {
viewModel.pt.observe(this, Observer<Map<String, Double>> {
if (it==null)return@Observer
// 默认 天安门
val center = LatLng(it["latitude"] ?:39.915071, it["longitude"] ?:116.403907)
})
} }
private fun initMap() { private fun initMap() {
...@@ -118,6 +146,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -118,6 +146,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
override fun onMapStatusChangeFinish(status: MapStatus?) { override fun onMapStatusChangeFinish(status: MapStatus?) {
// KLog.a("百度map", "移动结束") // KLog.a("百度map", "移动结束")
currentLat = status?.target?.latitude?:0.0
currentLon = status?.target?.longitude?:0.0
mRecommendStopSearch?.requestRecommendStop( mRecommendStopSearch?.requestRecommendStop(
RecommendStopSearchOption().location( RecommendStopSearchOption().location(
center center
...@@ -143,12 +174,13 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -143,12 +174,13 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
} }
mRecommendStopSearch = RecommendStopSearch.newInstance() mRecommendStopSearch = RecommendStopSearch.newInstance()
mRecommendStopSearch?.setOnGetRecommendStopResultListener { result -> mRecommendStopSearch?.setOnGetRecommendStopResultListener { result ->
result
if (result != null) { if (result != null) {
addMarkerToMap(result.recommendStopInfoList) addMarkerToMap(result.recommendStopInfoList)
} }
} }
//重新回到定位点 //重新回到定位点
RxUtils.onMultiClick(binding.imageLocationIcon){ RxUtils.onMultiClick(binding.imageLocationIcon) {
// 默认 天安门 // 默认 天安门
val center = LatLng(mCurrentLat, mCurrentLon) val center = LatLng(mCurrentLat, mCurrentLon)
// 默认 11级 // 默认 11级
...@@ -230,6 +262,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -230,6 +262,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
mBaiduMap?.clear() mBaiduMap?.clear()
for (stop in this) { for (stop in this) {
stop?.apply { stop?.apply {
KLog.e("addMarkerToMap", this.location.latitude)
KLog.e("addMarkerToMap", this.location.latitude)
val textView = TextView(context) val textView = TextView(context)
textView.text = stop.name textView.text = stop.name
textView.setBackgroundColor(Color.WHITE) textView.setBackgroundColor(Color.WHITE)
...@@ -251,14 +287,15 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -251,14 +287,15 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
/** /**
* 定位SDK监听函数 * 定位SDK监听函数
*/ */
var sp:SPUtils?=null var sp: SPUtils? = null
var positioningBean:PositioningBean?=null var positioningBean: PositioningBean? = null
inner class MyLocationListener : BDLocationListener { inner class MyLocationListener : BDLocationListener {
override fun onReceiveLocation(location: BDLocation) { override fun onReceiveLocation(location: BDLocation) {
if (sp==null){ if (sp == null) {
sp = SPUtils.getInstance(SPUtils.POSITIONING_MAP) sp = SPUtils.getInstance(SPUtils.POSITIONING_MAP)
} }
if (positioningBean == null){ if (positioningBean == null) {
positioningBean = PositioningBean() positioningBean = PositioningBean()
} }
positioningBean?.latitude = location.latitude positioningBean?.latitude = location.latitude
...@@ -272,7 +309,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE ...@@ -272,7 +309,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
positioningBean?.street = location.street positioningBean?.street = location.street
positioningBean?.addrStr = location.addrStr positioningBean?.addrStr = location.addrStr
sp?.encode(SPUtils.POSITIONING_MAP,Gson().toJson(positioningBean).toString()) sp?.encode(SPUtils.POSITIONING_MAP, Gson().toJson(positioningBean).toString())
// MapView 销毁后不在处理新接收的位置 // MapView 销毁后不在处理新接收的位置
mBaiduMap?.apply { mBaiduMap?.apply {
mCurrentLat = location.latitude mCurrentLat = location.latitude
......
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 androidx.databinding.ObservableArrayList import androidx.databinding.ObservableArrayList
import androidx.lifecycle.MutableLiveData
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.MapBean
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.utils.KLog
import me.tatarka.bindingcollectionadapter2.ItemBinding import me.tatarka.bindingcollectionadapter2.ItemBinding
import java.io.BufferedReader
import java.io.InputStreamReader
/** /**
* Created by 冯瑞雨 on 2021/7/2. * Created by 冯瑞雨 on 2021/7/2.
*/ */
class HomeViewModel(application: Application):BaseViewModel(application) { class HomeViewModel(application: Application):BaseViewModel(application) {
var addressList = ObservableArrayList<HomeButtonItemVM?>() var addressList = ObservableArrayList<HomeButtonItemVM?>()
var addressItemBinding = ItemBinding.of<HomeButtonItemVM>(BR.viewModel, R.layout.item_home_button) var addressItemBinding = ItemBinding.of<HomeButtonItemVM>(BR.viewModel, R.layout.item_home_button)
fun add(){ var pt = MutableLiveData<Map<String,Double>>()
for (index in 0..10){
addressList.add(HomeButtonItemVM(this)) fun getMapBean(){
val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder()
var mapBean:MapBean?=null
try {
//通过管理器打开文件并读取
val bf = BufferedReader(
InputStreamReader(
assets.open("map.json"))
)
var line: String?
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
}
mapBean = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e:Exception){
KLog.e("读取assets文件下的json出问题")
}
val bean = mapBean?.homePlaces?.places
bean?.iterator()?.forEach { item ->
if (item.images==null || item.images?.size!!<3){
return
}
addressList.add(HomeButtonItemVM(this, item.name
, item.images!![0],item.images!![1],item.images!![2]
,latitude = item.latitude.toString(),longitude = item.longitude.toString()
))
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == 200 && resultCode == SearchMapActivity.REQUEST_CODE){
data?.let {
val map = HashMap<String,Double>(2)
map["latitude"] = it.getDoubleExtra("latitude",0.0)
map["longitude"] = it.getDoubleExtra("longitude",0.0)
pt.value = map
}
} }
} }
} }
\ No newline at end of file
package com.mints.street.main.home package com.mints.street.main.home
import android.content.Intent
import com.baidu.mapapi.model.LatLng
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.BindingCommand
import me.goldze.mvvmhabit.utils.KLog
/** /**
* Created by 冯瑞雨 on 2021/7/15. * Created by 冯瑞雨 on 2021/7/15.
*/ */
class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?, val address:String?) : class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
, val address:String?,val pt: LatLng?=null) :
ItemViewModel<SearchMapViewModel>(viewModel) { ItemViewModel<SearchMapViewModel>(viewModel) {
/***
* 点击名称回调回调
*/
val onClick = BindingCommand<Any>(BindingAction {
val intent = Intent()
intent.putExtra("latitude",pt?.latitude)
intent.putExtra("longitude",pt?.longitude)
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
...@@ -5,6 +5,7 @@ import android.os.Bundle ...@@ -5,6 +5,7 @@ import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextUtils import android.text.TextUtils
import android.text.TextWatcher import android.text.TextWatcher
import androidx.lifecycle.Observer
import com.alibaba.android.vlayout.DelegateAdapter import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager import com.alibaba.android.vlayout.VirtualLayoutManager
import com.baidu.mapapi.search.sug.OnGetSuggestionResultListener import com.baidu.mapapi.search.sug.OnGetSuggestionResultListener
...@@ -17,6 +18,7 @@ import com.mints.street.BR ...@@ -17,6 +18,7 @@ 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.MapBean
import com.mints.street.databinding.ActivitySearchMapBinding import com.mints.street.databinding.ActivitySearchMapBinding
import me.goldze.mvvmhabit.base.AppManager import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
...@@ -28,16 +30,14 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -28,16 +30,14 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
OnGetSuggestionResultListener { OnGetSuggestionResultListener {
companion object { companion object {
const val HISTORY_NAME = "history_name" const val HISTORY_NAME = "history_name"
fun startSearchMapActivity() { const val REQUEST_CODE = 201
AppManager.getAppManager().currentActivity?.apply { fun startSearchMapActivity(fragment: HomeFragment) {
this.startActivity(Intent(this, SearchMapActivity::class.java)) fragment.startActivityForResult(Intent(fragment.context, SearchMapActivity::class.java),REQUEST_CODE)
}
} }
} }
private var vLayout: VirtualLayoutManager? = null private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null private var mAdapter: DelegateAdapter? = null
private var index = 0;//0=境内 1=境外
private var historyRecordAdapter: HistoryRecordAdapter? = null private var historyRecordAdapter: HistoryRecordAdapter? = null
private var popularSceneAdapter: PopularSceneAdapter? = null private var popularSceneAdapter: PopularSceneAdapter? = null
...@@ -89,7 +89,7 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -89,7 +89,7 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
historyRecordAdapter = HistoryRecordAdapter(this) historyRecordAdapter = HistoryRecordAdapter(this)
popularSceneAdapter = PopularSceneAdapter(this, listOf("1", "12")) popularSceneAdapter = PopularSceneAdapter(this)
mAdapter?.addAdapter(historyRecordAdapter) mAdapter?.addAdapter(historyRecordAdapter)
mAdapter?.addAdapter(popularSceneAdapter) mAdapter?.addAdapter(popularSceneAdapter)
...@@ -103,11 +103,13 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -103,11 +103,13 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
abroad() abroad()
} }
viewModel.getMapBean()
} }
private fun update() { private fun update() {
mAdapter?.clear() mAdapter?.clear()
if (index == 0) { if (viewModel.index == 0) {
historyRecordAdapter?.apply { historyRecordAdapter?.apply {
mAdapter?.addAdapter(historyRecordAdapter) mAdapter?.addAdapter(historyRecordAdapter)
} }
...@@ -115,28 +117,40 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -115,28 +117,40 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
mAdapter?.removeAdapter(historyRecordAdapter) mAdapter?.removeAdapter(historyRecordAdapter)
} }
popularSceneAdapter?.apply { popularSceneAdapter?.apply {
this.list = listOf("1", "12", "dfdsfsd") if (viewModel.index==0){
this.list = viewModel.mapBean.value?.innerPlaces?.places
}else{
this.list = viewModel.mapBean.value?.outerPlaces?.places
}
mAdapter?.addAdapter(popularSceneAdapter) mAdapter?.addAdapter(popularSceneAdapter)
} }
mAdapter?.notifyDataSetChanged() mAdapter?.notifyDataSetChanged()
} }
override fun initViewObservable() {
viewModel.mapBean.observe(this, Observer<MapBean> {
it?.let {
update()
}
})
}
private fun territory() { private fun territory() {
if (index == 0) return if (viewModel.index == 0) return
index = 0 viewModel.index = 0
binding.territory.setTextColor(ResourceUtils.getColor(R.color.blue)) binding.territory.setTextColor(ResourceUtils.getColor(R.color.color_668BFF))
binding.abroad.setTextColor(ResourceUtils.getColor(R.color.white)) binding.abroad.setTextColor(ResourceUtils.getColor(R.color.white))
binding.territory.solid = ResourceUtils.getColor(R.color.white) binding.territory.solid = ResourceUtils.getColor(R.color.white)
binding.abroad.solid = ResourceUtils.getColor(R.color.blue) binding.abroad.solid = ResourceUtils.getColor(R.color.color_668BFF)
update() update()
} }
private fun abroad() { private fun abroad() {
if (index == 1) return if (viewModel.index == 1) return
index = 1 viewModel.index = 1
binding.territory.setTextColor(ResourceUtils.getColor(R.color.white)) binding.territory.setTextColor(ResourceUtils.getColor(R.color.white))
binding.abroad.setTextColor(ResourceUtils.getColor(R.color.blue)) binding.abroad.setTextColor(ResourceUtils.getColor(R.color.color_668BFF))
binding.territory.solid = ResourceUtils.getColor(R.color.blue) binding.territory.solid = ResourceUtils.getColor(R.color.color_668BFF)
binding.abroad.solid = ResourceUtils.getColor(R.color.white) binding.abroad.solid = ResourceUtils.getColor(R.color.white)
update() update()
} }
...@@ -157,7 +171,7 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -157,7 +171,7 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
} }
for (info in suggestionResult.allSuggestions) { for (info in suggestionResult.allSuggestions) {
viewModel.searchAfterOneItems.add(SearchAfterItem(viewModel viewModel.searchAfterOneItems.add(SearchAfterItem(viewModel
,info.key,info.address)) ,info.key,info.address,info.pt))
} }
} }
} }
\ No newline at end of file
...@@ -4,19 +4,27 @@ import android.app.Application ...@@ -4,19 +4,27 @@ import android.app.Application
import android.text.TextUtils import android.text.TextUtils
import android.view.View import android.view.View
import androidx.databinding.ObservableArrayList import androidx.databinding.ObservableArrayList
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.MapBean
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.BaseViewModel import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.binding.command.BindingCommand
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.SPUtils import me.goldze.mvvmhabit.utils.SPUtils
import me.tatarka.bindingcollectionadapter2.ItemBinding import me.tatarka.bindingcollectionadapter2.ItemBinding
import java.io.BufferedReader
import java.io.InputStreamReader
/** /**
* Created by 冯瑞雨 on 2021/7/13. * Created by 冯瑞雨 on 2021/7/13.
*/ */
class SearchMapViewModel(application: Application) : BaseViewModel(application) { class SearchMapViewModel(application: Application) : BaseViewModel(application) {
var index = 0;//0=境内 1=境外
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>()
...@@ -32,6 +40,28 @@ class SearchMapViewModel(application: Application) : BaseViewModel(application) ...@@ -32,6 +40,28 @@ class SearchMapViewModel(application: Application) : BaseViewModel(application)
} }
return null return null
} }
val mapBean = MutableLiveData<MapBean>()
fun getMapBean(){
val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder()
try {
//通过管理器打开文件并读取
val bf = BufferedReader(
InputStreamReader(
assets.open("map.json"))
)
var line: String?
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
}
mapBean.value = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e:Exception){
KLog.e("读取assets文件下的json出问题")
}
}
} }
\ No newline at end of file
package com.mints.street.webview package com.mints.street.webview
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import com.fry.base.base.BaseActivity import com.fry.base.base.BaseActivity
import com.mints.street.BR import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.databinding.ActivityMintsWebViewBinding import com.mints.street.databinding.ActivityMintsWebViewBinding
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
/** /**
* Created by 冯瑞雨 on 2021/7/15. * Created by 冯瑞雨 on 2021/7/15.
*/ */
class MintsWebViewActivity:BaseActivity<ActivityMintsWebViewBinding,MintsWebViewModel>() { class MintsWebViewActivity : BaseActivity<ActivityMintsWebViewBinding, MintsWebViewModel>() {
companion object{
fun startWebView(name:String?,latitude:String?,longitude:String?){
AppManager.getAppManager().currentActivity?.apply {
val intent = Intent(this,MintsWebViewActivity::class.java)
intent.putExtra("name",name)
intent.putExtra("latitude",latitude)
intent.putExtra("longitude",longitude)
this.startActivity(intent)
}
}
}
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_mints_web_view override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_mints_web_view
override fun initVariableId() = BR.viewModel override fun initVariableId() = BR.viewModel
override fun initData() {
super.initData()
binding.ctbTitle.setTitle(intent.getStringExtra("name"))
KLog.e("MintsWebViewActivity","file:///android_asset/web/m.html?a=${intent.getStringExtra("longitude")}" +
"&b=${intent.getStringExtra("latitude")}&c=1")
binding.webview.loadUrl("file:///android_asset/web/m.html?a=${intent.getStringExtra("longitude")}" +
"&b=${intent.getStringExtra("latitude")}&c=1");//加载asset文件夹下html
binding.webview.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
//使用WebView加载显示url
if (url != null) {
view?.loadUrl(url)
return true
} else {
return false
}
}
}
val webSettings = binding.webview.settings
webSettings.setJavaScriptEnabled(true);//允许使用js
//支持屏幕缩放
webSettings.setSupportZoom(true);
webSettings.builtInZoomControls = true;
}
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/white" />
</shape>
</item>
<item > <item >
<bitmap <bitmap
android:src="@drawable/bg_splash" /> android:src="@drawable/bg" />
</item> </item>
</layer-list> </layer-list>
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:ctb_theme="dark" app:ctb_theme="dark"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>
......
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
android:id="@+id/view_bg" android:id="@+id/view_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="150dp" android:layout_height="150dp"
android:background="@color/color_8F6D21" 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" />
<LinearLayout <LinearLayout
android:visibility="gone"
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"
...@@ -29,7 +30,7 @@ ...@@ -29,7 +30,7 @@
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center"
android:text="境内" android:text="境内"
android:textColor="@color/blue" android:textColor="#668BFF"
android:textSize="14sp" android:textSize="14sp"
app:stv_corner="5dp" app:stv_corner="5dp"
app:stv_left_bottom_corner="true" app:stv_left_bottom_corner="true"
...@@ -50,7 +51,7 @@ ...@@ -50,7 +51,7 @@
app:stv_corner="5dp" app:stv_corner="5dp"
app:stv_right_bottom_corner="true" app:stv_right_bottom_corner="true"
app:stv_right_top_corner="true" app:stv_right_top_corner="true"
app:stv_solid="@color/blue" app:stv_solid="#668BFF"
app:stv_stroke_color="@color/white" app:stv_stroke_color="@color/white"
app:stv_stroke_width="1dp" /> app:stv_stroke_width="1dp" />
...@@ -66,16 +67,17 @@ ...@@ -66,16 +67,17 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_bg" /> app:layout_constraintTop_toBottomOf="@id/view_bg" />
<EditText <EditText
android:paddingStart="45dp"
android:id="@+id/et" android:id="@+id/et"
android:paddingStart="10dp"
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="37dp"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:background="@drawable/cursor_bg_shape" android:background="@drawable/cursor_bg_shape"
android:gravity="center_vertical" android:gravity="center_vertical"
android:hint="请输入地址" android:hint="请输入地址"
android:textColorHint="#E1E1E1"
android:textColor="@color/color_8F6D21" android:textColor="@color/color_8F6D21"
android:textCursorDrawable="@drawable/cursor_color" android:textCursorDrawable="@drawable/cursor_color"
android:textSize="14sp" android:textSize="14sp"
...@@ -83,6 +85,15 @@ ...@@ -83,6 +85,15 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_bg" /> app:layout_constraintTop_toBottomOf="@id/view_bg" />
<ImageView
android:layout_marginStart="16dp"
android:id="@+id/im_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/search_icon"
app:layout_constraintBottom_toBottomOf="@id/et"
app:layout_constraintStart_toStartOf="@id/et"
app:layout_constraintTop_toTopOf="@id/et" />
<com.fry.base.ui.widget.CommonTitleBar <com.fry.base.ui.widget.CommonTitleBar
android:id="@+id/ctb_title" android:id="@+id/ctb_title"
......
...@@ -2,98 +2,98 @@ ...@@ -2,98 +2,98 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android" <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="com.mints.street.main.home.HomeViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
>
<com.baidu.mapapi.map.MapView <com.baidu.mapapi.map.MapView
android:id="@+id/bmapView" android:id="@+id/bmapView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" /> android:layout_height="0dp"
<ImageView android:layout_marginBottom="40dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="40dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_height="40dp" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_click"
android:layout_marginBottom="40dp"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:src="@mipmap/water_drop"/> android:src="@mipmap/positioning_icon"
app:layout_constraintBottom_toBottomOf="@id/bmapView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/bmapView" />
<ImageView <ImageView
android:layout_marginTop="15dp"
android:id="@+id/image_map_change" android:id="@+id/image_map_change"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="35dp" android:layout_width="35dp"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginTop="15dp"
android:src="@mipmap/map_change_icon" android:src="@mipmap/map_change_icon"
android:visibility="gone" android:visibility="gone"
/> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:layout_marginTop="15dp"
android:id="@+id/image_map_history" android:id="@+id/image_map_history"
app:layout_constraintTop_toBottomOf="@id/image_map_change"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="35dp" android:layout_width="35dp"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginTop="15dp"
android:src="@mipmap/map_history_icon" android:src="@mipmap/map_history_icon"
/> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/image_map_change" />
<ImageView <ImageView
android:layout_marginTop="15dp"
android:id="@+id/image_location_icon" android:id="@+id/image_location_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="120dp"
android:layout_width="35dp" android:layout_width="35dp"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginBottom="120dp"
android:layout_marginTop="15dp"
android:src="@mipmap/location_icon" android:src="@mipmap/location_icon"
/> app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<LinearLayout <LinearLayout
android:id="@+id/map_a_d" android:id="@+id/map_a_d"
android:layout_width="31dp" android:layout_width="31dp"
android:layout_height="63dp" android:layout_height="63dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/image_location_icon"
android:orientation="vertical"
android:background="@drawable/shape_gold_card"
android:layout_marginEnd="2dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:layout_marginEnd="2dp"
android:background="@drawable/shape_gold_card"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@id/image_location_icon"
app:layout_constraintEnd_toEndOf="parent"
> >
<ImageView <ImageView
android:id="@+id/image_in" android:id="@+id/image_in"
android:padding="10dp"
android:layout_width="31dp" android:layout_width="31dp"
android:layout_height="31dp" android:layout_height="31dp"
android:src="@mipmap/scale_add_icon" android:padding="10dp"
/> android:src="@mipmap/scale_add_icon" />
<View
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_width="wrap_content"
android:layout_height="0.5dp"
android:background="@color/color_333"
/>
<ImageView <ImageView
android:id="@+id/image_out" android:id="@+id/image_out"
android:padding="10dp"
android:layout_width="31dp" android:layout_width="31dp"
android:layout_height="31dp" android:layout_height="31dp"
android:src="@mipmap/scale_shrink_icon" android:padding="10dp"
/> android:src="@mipmap/scale_shrink_icon" />
<View
android:layout_width="wrap_content"
android:layout_height="0.5dp"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:background="@color/color_333" />
</LinearLayout> </LinearLayout>
<com.mints.street.widget.ScrollLayout <com.mints.street.widget.ScrollLayout
android:id="@+id/scroll_layout" android:id="@+id/scroll_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -103,29 +103,75 @@ ...@@ -103,29 +103,75 @@
tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"> tools:layout_editor_absoluteY="0dp">
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/white" android:background="@color/white"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingBottom="10dp"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/image_under"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:padding="8dp"
android:src="@mipmap/icon_content_back" /> android:src="@mipmap/icon_content_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <com.coorchice.library.SuperTextView
android:id="@+id/stb_bg_search"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="37dp"
android:gravity="center" android:layout_marginEnd="10dp"
android:text="占位置" android:layout_marginStart="10dp"
android:textColor="@color/color_2B3238" /> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/image_under"
app:stv_corner="20dp"
app:stv_solid="#F5F9FA"
app:stv_stroke_color="#ffe1e1e1"
app:stv_stroke_width="1dp"
/>
</LinearLayout> <ImageView
android:layout_marginStart="16dp"
android:id="@+id/im_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/search_icon"
app:layout_constraintBottom_toBottomOf="@id/stb_bg_search"
app:layout_constraintStart_toStartOf="@id/stb_bg_search"
app:layout_constraintTop_toTopOf="@id/stb_bg_search" />
<View
android:background="#A1A3AF"
android:layout_width="0.5dp"
android:layout_height="14dp"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="@id/stb_bg_search"
app:layout_constraintStart_toEndOf="@id/im_search"
app:layout_constraintTop_toTopOf="@id/stb_bg_search" />
<TextView
android:layout_marginStart="27dp"
app:layout_constraintBottom_toBottomOf="@id/stb_bg_search"
app:layout_constraintStart_toEndOf="@id/im_search"
app:layout_constraintTop_toTopOf="@id/stb_bg_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="搜索境内、境外地址"
android:textColor="#A2A4B1"
android:textSize="14sp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.mints.street.widget.ScrollRecyclerView <com.mints.street.widget.ScrollRecyclerView
android:background="@color/white"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:itemBinding="@{viewModel.addressItemBinding}" app:itemBinding="@{viewModel.addressItemBinding}"
...@@ -138,4 +184,11 @@ ...@@ -138,4 +184,11 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<data>
<variable
name="viewModel"
type="com.mints.street.main.home.HomeViewModel" />
</data>
</layout> </layout>
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</data> </data>
<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="120dp" android:layout_height="138dp"
android:background="@mipmap/abc_popup_background_mtrl_mult" android:background="@mipmap/abc_popup_background_mtrl_mult"
android:padding="15dp" android:padding="15dp"
app:onClickCommand="@{viewModel.onItemClick}" app:onClickCommand="@{viewModel.onItemClick}"
...@@ -20,41 +20,43 @@ ...@@ -20,41 +20,43 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="sdfasd" android:text="@{viewModel.name}"
android:textSize="16sp" android:textSize="15sp"
android:singleLine="true" android:singleLine="true"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/color_2B3238" android:textColor="#323334"
/> />
<ImageView <ImageView
android:id="@+id/image1" android:id="@+id/image1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="65dp" android:layout_height="79dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image2" app:layout_constraintEnd_toStartOf="@id/image2"
tools:src="@mipmap/bg_fl" app:url="@{viewModel.image1}"
/> />
<ImageView <ImageView
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:id="@+id/image2" android:id="@+id/image2"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="65dp" android:layout_height="79dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/image1" app:layout_constraintStart_toEndOf="@id/image1"
app:layout_constraintEnd_toStartOf="@id/image3" app:layout_constraintEnd_toStartOf="@id/image3"
tools:src="@mipmap/bg_fl" app:url="@{viewModel.image2}"
/> />
<ImageView <ImageView
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:id="@+id/image3" android:id="@+id/image3"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="65dp" android:layout_height="79dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/image2" app:layout_constraintStart_toEndOf="@id/image2"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
tools:src="@mipmap/bg_fl" app:url="@{viewModel.image3}"
/> />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<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:id="@+id/bg" android:id="@+id/bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="140dp" android:layout_height="138dp"
android:background="@mipmap/vip_google_bg" android:background="@mipmap/vip_google_bg"
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
<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="50dp" android:layout_height="50dp"
android:layout_marginBottom="10dp"> android:layout_marginBottom="10dp"
app:onClickCommand="@{viewModel.onClick}"
>
<ImageView <ImageView
android:id="@+id/image" android:id="@+id/image"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<color name="color_3D5AFE">#3D5AFE</color> <color name="color_3D5AFE">#3D5AFE</color>
<color name="color_cb4a39">#cb4a39</color> <color name="color_cb4a39">#cb4a39</color>
<color name="color_0000FF">#0000FF</color> <color name="color_0000FF">#0000FF</color>
<color name="color_668BFF">#668BFF</color>
<color name="color_ccc">#cccccc</color> <color name="color_ccc">#cccccc</color>
<color name="color_AAA">#AAAAAA</color> <color name="color_AAA">#AAAAAA</color>
<color name="color_0000">#00000000</color> <color name="color_0000">#00000000</color>
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<color name="color_E6E6E6">#E6E6E6</color> <color name="color_E6E6E6">#E6E6E6</color>
<color name="color_E6E2E2">#E6E2E2</color> <color name="color_E6E2E2">#E6E2E2</color>
<color name="color_E1E1E1">#E1E1E1</color>
<color name="color_121B32">#121B32</color> <color name="color_121B32">#121B32</color>
<color name="color_FF9837">#FF9837</color> <color name="color_FF9837">#FF9837</color>
<color name="color_50FF9837">#50FF9837</color> <color name="color_50FF9837">#50FF9837</color>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment