Commit 81125099 authored by fengruiyu's avatar fengruiyu

搜索页面已完成

功能完成百分之80
parent 1440498b
...@@ -83,17 +83,7 @@ ...@@ -83,17 +83,7 @@
<activity android:name="com.mints.street.splash.SplashActivity" <activity android:name="com.mints.street.splash.SplashActivity"
android:theme="@style/NormalSplash"> android:theme="@style/NormalSplash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="um.60e80209a6f90557b7b19aa7" />
</intent-filter>
</activity> </activity>
<activity android:name="com.mints.street.login.LoginActivity"> <activity android:name="com.mints.street.login.LoginActivity">
...@@ -197,6 +187,19 @@ ...@@ -197,6 +187,19 @@
android:screenOrientation="sensor" android:screenOrientation="sensor"
android:configChanges="orientation|keyboardHidden" android:configChanges="orientation|keyboardHidden"
/> />
<activity android:name=".main.home.SearchMapActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="um.60e80209a6f90557b7b19aa7" />
</intent-filter>
</activity>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package com.mints.street.adapter
import android.content.Context
import androidx.databinding.ViewDataBinding
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.blankj.utilcode.util.SPUtils
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.recycler_view.VHMAdapter
import com.fry.base.recycler_view.VHModel
import com.google.gson.Gson
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ItemHistoryRecordAdapterBinding
import com.mints.street.main.home.SearchMapActivity
/**
* Created by 冯瑞雨 on 2021/7/14.
* 历史记录的adapter
*/
class HistoryRecordAdapter(val context: Context, var name: String? = null) :
AbstractVLayoutBaseAdapter<ItemHistoryRecordAdapterBinding, String>(context, name, 1) {
var listName: List<String>? = getHistoryData()
override fun onBindViewHolder(
holder: BindingViewHolder<ItemHistoryRecordAdapterBinding>,
position: Int
) {
val adapter = VHMAdapter<HistoryRecordItemVHM>()
listName?.apply {
for (items in this) {
adapter.add(HistoryRecordItemVHM(items))
}
}
holder.binding.listView.adapter = adapter
}
private fun getHistoryData(): List<String> {
val instance = SPUtils.getInstance(SearchMapActivity.HISTORY_NAME)
val string = instance.getString("name")
return Gson().fromJson<List<String>>(string, List::class.java)
}
fun addHistoryData(list:List<String> ) {
val instance = SPUtils.getInstance(SearchMapActivity.HISTORY_NAME)
instance.put("name", Gson().toJson(list).toString())
}
override fun getItemCount() = 1
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_history_record_adapter
}
class HistoryRecordItemVHM(
var name: String
) : VHModel() {
override fun getLayoutId() = R.layout.item_history_record_name
override fun getVariableId() = BR.vhm
override fun onBind(binding: ViewDataBinding) {
super.onBind(binding)
}
}
\ No newline at end of file
package com.mints.street.adapter
import android.content.Context
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.street.R
import com.mints.street.databinding.ItemPopularSceneAdapterBinding
import me.goldze.mvvmhabit.utils.KLog
/**
* Created by 冯瑞雨 on 2021/7/14.
* 热门景区的adapter
*/
class PopularSceneAdapter(val context: Context, var list: List<String>) :
AbstractVLayoutBaseAdapter<ItemPopularSceneAdapterBinding, List<String>>(context, list, 2) {
override fun onBindViewHolder(
holder: BindingViewHolder<ItemPopularSceneAdapterBinding>,
position: Int
) {
KLog.e("PopularSceneAdapter",list.size)
}
override fun getItemCount() = list.size
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_popular_scene_adapter
}
package com.mints.street.main.home package com.mints.street.main.home
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
/** /**
* Created by 冯瑞雨 on 2021/7/9. * Created by 冯瑞雨 on 2021/7/9.
*/ */
class HomeButtonItemVM (viewModel: HomeViewModel): ItemViewModel<HomeViewModel?>(viewModel) { class HomeButtonItemVM(viewModel: HomeViewModel) : ItemViewModel<HomeViewModel?>(viewModel) {
val onItemClick = BindingCommand<Any?>(BindingAction {
SearchMapActivity.startSearchMapActivity()
})
} }
\ No newline at end of file
package com.mints.street.main.home
import android.content.Intent
import android.os.Bundle
import androidx.lifecycle.Observer
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.fry.base.base.BaseActivity
import com.fry.base.utils.ResourceUtils
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.adapter.HistoryRecordAdapter
import com.mints.street.adapter.PopularSceneAdapter
import com.mints.street.databinding.ActivitySearchMapBinding
import me.goldze.mvvmhabit.base.AppManager
/**
* Created by 冯瑞雨 on 2021/7/13.
*/
class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewModel>() {
companion object {
const val HISTORY_NAME = "history_name"
fun startSearchMapActivity() {
AppManager.getAppManager().currentActivity?.apply {
this.startActivity(Intent(this, SearchMapActivity::class.java))
}
}
}
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
private var index = 0;//0=境内 1=境外
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_search_map
override fun initVariableId() = BR.viewModel
private var historyRecordAdapter: HistoryRecordAdapter? = null
private var popularSceneAdapter: PopularSceneAdapter? = null
override fun initData() {
super.initData()
//初始化布局管理器
vLayout = VirtualLayoutManager(this)
mAdapter = DelegateAdapter(vLayout, false)
binding.recyList.layoutManager = vLayout
binding.recyList.adapter = mAdapter
historyRecordAdapter = HistoryRecordAdapter(this);
popularSceneAdapter = PopularSceneAdapter(this, listOf("1", "12"))
mAdapter?.addAdapter(historyRecordAdapter)
mAdapter?.addAdapter(popularSceneAdapter)
//境内
binding.territory.setOnClickListener {
territory()
}
//境外
binding.abroad.setOnClickListener {
abroad()
}
}
private fun update() {
mAdapter?.clear()
if (index == 0) {
historyRecordAdapter?.apply {
mAdapter?.addAdapter(historyRecordAdapter)
}
} else {
mAdapter?.removeAdapter(historyRecordAdapter)
}
popularSceneAdapter?.apply {
this.list = listOf("1", "12", "dfdsfsd")
mAdapter?.addAdapter(popularSceneAdapter)
}
mAdapter?.notifyDataSetChanged()
}
private fun territory() {
if (index == 0) return
index = 0
binding.territory.setTextColor(ResourceUtils.getColor(R.color.blue))
binding.abroad.setTextColor(ResourceUtils.getColor(R.color.white))
binding.territory.solid = ResourceUtils.getColor(R.color.white)
binding.abroad.solid = ResourceUtils.getColor(R.color.blue)
update()
}
private fun abroad() {
if (index == 1) return
index = 1
binding.territory.setTextColor(ResourceUtils.getColor(R.color.white))
binding.abroad.setTextColor(ResourceUtils.getColor(R.color.blue))
binding.territory.solid = ResourceUtils.getColor(R.color.blue)
binding.abroad.solid = ResourceUtils.getColor(R.color.white)
update()
}
}
\ No newline at end of file
package com.mints.street.main.home
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.SPUtils
import com.google.gson.Gson
import me.goldze.mvvmhabit.base.BaseViewModel
/**
* Created by 冯瑞雨 on 2021/7/13.
*/
class SearchMapViewModel(application: Application) : BaseViewModel(application) {
}
\ No newline at end of file
...@@ -148,6 +148,8 @@ class PanoramicActivity : BaseActivity<ActivityPanoramicBinding, PanoramicViewMo ...@@ -148,6 +148,8 @@ class PanoramicActivity : BaseActivity<ActivityPanoramicBinding, PanoramicViewMo
} }
override fun onLoadPanoramaError(p0: String?) { override fun onLoadPanoramaError(p0: String?) {
KLog.i("PanoramicActivity", "onLoadPanoramaError...$p0")
} }
override fun onMessage(p0: String?, p1: Int) { override fun onMessage(p0: String?, p1: Int) {
...@@ -200,9 +202,9 @@ class PanoramicActivity : BaseActivity<ActivityPanoramicBinding, PanoramicViewMo ...@@ -200,9 +202,9 @@ class PanoramicActivity : BaseActivity<ActivityPanoramicBinding, PanoramicViewMo
return return
} }
binding.panorama.setPanoramaImageLevel( binding.panorama.setPanoramaImageLevel(
PanoramaView.ImageDefinition.ImageDefinitionMiddle PanoramaView.ImageDefinition.ImageDefinitionLow
) )
binding.panorama.setPanorama(lon, lat, PanoramaView.COORDTYPE_BD09LL) binding.panorama.setPanorama(lon, lat)
} }
//通过百度墨卡托坐标(BD09MC)获取全景 //通过百度墨卡托坐标(BD09MC)获取全景
MERCATOR -> { MERCATOR -> {
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 边框的颜色和粗细 -->
<solid android:color="#ffffffff" />
<corners android:radius="81dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00bb9c"/>
<size android:width="1dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_gold_card" android:state_checked="true"/>
<item android:drawable="@drawable/shape_gold" android:state_checked="false"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:drawable="@color/blue" />
<item android:state_checked="true" android:drawable="@color/black" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/view_bg"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@color/color_8F6D21"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/ll_title_bg"
android:layout_width="120dp"
android:layout_height="30dp"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="@id/ctb_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/ctb_title">
<com.coorchice.library.SuperTextView
android:id="@+id/territory"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="境内"
android:textColor="@color/blue"
android:textSize="14sp"
app:stv_corner="5dp"
app:stv_left_bottom_corner="true"
app:stv_left_top_corner="true"
app:stv_solid="@color/white"
app:stv_stroke_color="@color/white"
app:stv_stroke_width="1dp" />
<com.coorchice.library.SuperTextView
android:id="@+id/abroad"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="境外"
android:textColor="@color/white"
android:textSize="14sp"
app:stv_corner="5dp"
app:stv_right_bottom_corner="true"
app:stv_right_top_corner="true"
app:stv_solid="@color/blue"
app:stv_stroke_color="@color/white"
app:stv_stroke_width="1dp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recy_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingTop="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_bg" />
<EditText
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:background="@drawable/cursor_bg_shape"
android:gravity="center_vertical"
android:hint="请输入地址"
android:textColor="@color/color_8F6D21"
android:textCursorDrawable="@drawable/cursor_color"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="@id/view_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_bg" />
<com.fry.base.ui.widget.CommonTitleBar
android:id="@+id/ctb_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ctb_theme="dark"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<data>
<variable
name="viewModel"
type="com.mints.street.main.home.SearchMapViewModel" />
</data>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="adpter"
type="com.mints.street.adapter.HistoryRecordAdapter" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<ImageView
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/icon_search_history"
/>
<TextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="历史记录"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="14sp"
/>
<TextView
android:padding="10dp"
android:drawableStart="@mipmap/icon_search_history"
android:drawablePadding="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="清空"
android:textColor="@color/color_555"
android:textSize="12sp"
/>
</LinearLayout>
<com.fry.base.ui.widget.CustomRecycleView
android:id="@+id/list_view"
app:dividerColor="#00000000"
app:dividerHeight="10dp"
app:dividerMarginEnd="10dp"
app:layoutManagerType="flow"
app:useDivider="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="vhm"
type="com.mints.street.adapter.HistoryRecordItemVHM" />
</data>
<com.coorchice.library.SuperTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:textSize="14sp"
android:gravity="center"
android:text="@{vhm.name}"
android:textColor="@color/color_555"
app:stv_stroke_color="@color/color_555"
app:stv_stroke_width="1dp"
app:stv_corner="10dp"
android:paddingStart="5dp"
android:paddingEnd="5dp"
/>
</layout>
\ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
android:layout_height="120dp" android:layout_height="120dp"
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}"
> >
<TextView <TextView
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bg"
android:layout_width="match_parent"
android:layout_height="140dp"
android:background="@mipmap/vip_google_bg"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:padding="10dp"
>
<TextView
android:id="@+id/tv_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="测试"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold"
/>
<ImageView
android:id="@+id/image1"
android:layout_width="0dp"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image2"
android:src="@mipmap/bg_fl"
/>
<ImageView
android:layout_marginStart="10dp"
android:id="@+id/image2"
android:layout_width="0dp"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/image1"
app:layout_constraintEnd_toStartOf="@id/image3"
android:src="@mipmap/bg_fl"
/>
<ImageView
android:layout_marginStart="10dp"
android:id="@+id/image3"
android:layout_width="0dp"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/image2"
app:layout_constraintEnd_toEndOf="parent"
android:src="@mipmap/bg_fl"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
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