Commit d1e3e3d7 authored by 张释方's avatar 张释方

提交国内外搜索接口

parent c5f29fca
package com.mints.street.api package com.mints.street.api
import com.google.gson.JsonObject import com.google.gson.JsonObject
import com.mints.street.bean.BaseArrayResponse
import com.mints.street.bean.BaseResponse import com.mints.street.bean.BaseResponse
import com.mints.street.bean.PositionBean
import com.mints.street.netwrok.baidu.BaiduHttpManager import com.mints.street.netwrok.baidu.BaiduHttpManager
import io.reactivex.Observable import io.reactivex.Observable
import retrofit2.Response import retrofit2.Response
...@@ -27,15 +29,20 @@ interface BaiduApi { ...@@ -27,15 +29,20 @@ interface BaiduApi {
/** /**
* 国外 * 国外
*
*
* vo["region"] = "全球" * vo["region"] = "全球"
vo["output"] = "json" vo["output"] = "json"
vo["ak"] = "tnFhCM9cTeTDZqNjRPVHbfzOz6AUPoEq"@return vo["ak"] = "tnFhCM9cTeTDZqNjRPVHbfzOz6AUPoEq"@return
*/ */
@GET("place_abroad/v1/suggestion") @GET("place_abroad/v1/suggestion")
// fun suggestionPlaceAbroad(@Query vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>> // fun suggestionPlaceAbroad(@Query vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
fun suggestionPlaceAbroad(@Query("query") vo: String,@Query("region") vo2: String, fun suggestionPlaceAbroad(@Query("query") vo: String,@Query("region") vo2: String,
@Query("output") vo3: String,@Query("ak") vo4: String): Observable<Response<BaseResponse<Any>>> @Query("output") vo3: String,@Query("ak") vo4: String):
Observable<Response<BaseArrayResponse<PositionBean>>>
@GET("place/v2/suggestion")
fun suggestionPlaceDomestic(@Query("query") vo: String,@Query("region") vo2: String,
@Query("output") vo3: String,@Query("ak") vo4: String):
Observable<Response<BaseArrayResponse<PositionBean>>>
} }
\ No newline at end of file
package com.mints.street.bean;
import java.util.List;
/**
* Created by goldze on 2017/5/10.
* 该类仅供参考,实际业务返回的固定字段, 根据需求来定义,
*/
public class BaseArrayResponse<T> extends BaseResponse<List<T>>{
@Override
public List<T> getResult() {
return result;
}
@Override
public void setResult(List<T> result) {
this.result = result;
}
}
...@@ -16,16 +16,19 @@ public class BaseResponse<T> implements Serializable { ...@@ -16,16 +16,19 @@ public class BaseResponse<T> implements Serializable {
private String message=""; private String message="";
// @JsonAdapter(value = JsonAdapterGsonDeserializer.class) // @JsonAdapter(value = JsonAdapterGsonDeserializer.class)
@SerializedName("data")
private T data;
protected @Nullable T result; protected @Nullable T result;
public BaseResponse() { public BaseResponse() {
} }
public BaseResponse(int status, String message, T result) { public BaseResponse(int status, String message, T result,T data) {
this.status = status; this.status = status;
this.message = message; this.message = message;
this.result = result; this.result = result;
this.data = data;
} }
...@@ -45,12 +48,21 @@ public class BaseResponse<T> implements Serializable { ...@@ -45,12 +48,21 @@ public class BaseResponse<T> implements Serializable {
return result; return result;
} }
public void setData(T data) {
this.data = data;
}
public T getData() {
return data;
}
public void setResult(T result) { public void setResult(T result) {
this.result = result; this.result = result;
} }
public boolean isOk() { public boolean isOk() {
return status == 200 && status < 700; return status == 200 || status == 0;
} }
public String getMessage() { public String getMessage() {
...@@ -67,6 +79,7 @@ public class BaseResponse<T> implements Serializable { ...@@ -67,6 +79,7 @@ public class BaseResponse<T> implements Serializable {
"status=" + status + "status=" + status +
", message='" + message + '\'' + ", message='" + message + '\'' +
", result=" + result + ", result=" + result +
", data=" + data +
'}'; '}';
} }
} }
package com.mints.street.bean
import java.io.Serializable
/**
* Created by 冯瑞雨 on 2021/7/15.
*/
data class PositionBean(
val address: String,
val business: String,
val city: String,
val cityid: String,
val district: String,
val location: Location,
val name: String,
val tag: String,
val uid: String
/**
* public String key;
public String city;
public String district;
public LatLng pt;
public String uid;
public String tag;
public String address;
*/
)
data class Location(
val lat: Double,
val lng: Double
)
\ No newline at end of file
...@@ -27,7 +27,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View ...@@ -27,7 +27,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
private val userManager by lazy { UserManager.INSTANCE } private val userManager by lazy { UserManager.INSTANCE }
override fun getStatusBarHeightView(): View? { override fun getStatusBarHeightView(): View? {
return null return binding.tvName
} }
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_login override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_login
...@@ -35,7 +35,6 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View ...@@ -35,7 +35,6 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
override fun initData() { override fun initData() {
super.initData() super.initData()
StatusBarUtil.setHeightAndPadding(this, binding.tvName)
initView() initView()
initListener() initListener()
} }
......
...@@ -3,6 +3,7 @@ package com.mints.street.main.home ...@@ -3,6 +3,7 @@ package com.mints.street.main.home
import android.content.Intent import android.content.Intent
import com.baidu.mapapi.model.LatLng import com.baidu.mapapi.model.LatLng
import com.mints.street.bean.HistoryBean import com.mints.street.bean.HistoryBean
import com.mints.street.bean.Location
import me.goldze.mvvmhabit.base.AppManager 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.BindingAction
...@@ -11,19 +12,36 @@ import me.goldze.mvvmhabit.utils.KLog ...@@ -11,19 +12,36 @@ 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? class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
, val address:String?,val pt: LatLng?=null) : , val address:String?,val pt: Location?=null) :
ItemViewModel<SearchMapViewModel>(viewModel) { ItemViewModel<SearchMapViewModel>(viewModel) {
/*** /***
* 点击名称回调回调 * 点击名称回调回调
*/ */
val onClick = BindingCommand<Any>(BindingAction { val onClick = BindingCommand<Any>(BindingAction {
viewModel.searchName.value = HistoryBean(name = this.name, viewModel.searchName.value = HistoryBean(name = this.name,
latitude = pt?.latitude,longitude = pt?.longitude) latitude = pt?.lat,longitude = pt?.lat)
val intent = Intent() val intent = Intent()
intent.putExtra("latitude",pt?.latitude) intent.putExtra("latitude",pt?.lat)
intent.putExtra("longitude",pt?.longitude) intent.putExtra("longitude",pt?.lat)
viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent) viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent)
}) })
} }
/*class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
, val address:String?,val pt: LatLng?=null) :
ItemViewModel<SearchMapViewModel>(viewModel) {
*//***
* 点击名称回调回调
*//*
val onClick = BindingCommand<Any>(BindingAction {
viewModel.searchName.value = HistoryBean(name = this.name,
latitude = pt?.latitude,longitude = pt?.longitude)
//不带参数、不跳转
// val intent = Intent()
// intent.putExtra("latitude",pt?.latitude)
// intent.putExtra("longitude",pt?.longitude)
// viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent)
})
}*/
\ No newline at end of file
...@@ -8,10 +8,6 @@ import android.text.TextWatcher ...@@ -8,10 +8,6 @@ import android.text.TextWatcher
import androidx.lifecycle.Observer 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.SuggestionResult
import com.baidu.mapapi.search.sug.SuggestionSearch
import com.baidu.mapapi.search.sug.SuggestionSearchOption
import com.fry.base.base.BaseActivity import com.fry.base.base.BaseActivity
import com.fry.base.utils.ResourceUtils import com.fry.base.utils.ResourceUtils
import com.mints.street.BR import com.mints.street.BR
...@@ -20,14 +16,14 @@ import com.mints.street.adapter.HistoryRecordAdapter ...@@ -20,14 +16,14 @@ import com.mints.street.adapter.HistoryRecordAdapter
import com.mints.street.adapter.PopularSceneAdapter import com.mints.street.adapter.PopularSceneAdapter
import com.mints.street.bean.HistoryBean import com.mints.street.bean.HistoryBean
import com.mints.street.bean.MapBean import com.mints.street.bean.MapBean
import com.mints.street.bean.PositionBean
import com.mints.street.databinding.ActivitySearchMapBinding import com.mints.street.databinding.ActivitySearchMapBinding
import me.goldze.mvvmhabit.utils.KLog
/** /**
* Created by 冯瑞雨 on 2021/7/13. * Created by 冯瑞雨 on 2021/7/13.
*/ */
class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewModel>(), class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewModel>(){
OnGetSuggestionResultListener { // OnGetSuggestionResultListener {
companion object { companion object {
const val HISTORY_NAME = "history_name" const val HISTORY_NAME = "history_name"
const val REQUEST_CODE = 201 const val REQUEST_CODE = 201
...@@ -44,9 +40,9 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -44,9 +40,9 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
private var historyRecordAdapter: HistoryRecordAdapter? = null private var historyRecordAdapter: HistoryRecordAdapter? = null
private var popularSceneAdapter: PopularSceneAdapter? = null private var popularSceneAdapter: PopularSceneAdapter? = null
//
//检索模块 // //检索模块
private var mSuggestionSearch: SuggestionSearch? = null // private var mSuggestionSearch: SuggestionSearch? = null
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_search_map override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_search_map
...@@ -62,10 +58,11 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -62,10 +58,11 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
binding.recyList.layoutManager = vLayout binding.recyList.layoutManager = vLayout
binding.recyList.adapter = mAdapter binding.recyList.adapter = mAdapter
//
// // 初始化建议搜索模块,注册建议搜索事件监听
// mSuggestionSearch = SuggestionSearch.newInstance()
// mSuggestionSearch?.setOnGetSuggestionResultListener(this)
// 初始化建议搜索模块,注册建议搜索事件监听
mSuggestionSearch = SuggestionSearch.newInstance()
mSuggestionSearch?.setOnGetSuggestionResultListener(this)
binding.et.addTextChangedListener(object : TextWatcher { binding.et.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
} }
...@@ -78,18 +75,32 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -78,18 +75,32 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
viewModel.searchAfterOneItems.clear() viewModel.searchAfterOneItems.clear()
return return
} }
// 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新 if (viewModel.index==0){
mSuggestionSearch?.requestSuggestion( //国外
SuggestionSearchOption() viewModel.searchdomestic(s.toString())
.keyword(s.toString()) // 关键字 }else{
.city(viewModel.positioningBean?.city ?: "北京") //传入参数【这里是可以获取到参数的】【国外】
) viewModel.searchabroad(s.toString())
}
// onGetSuggestionResult(postionConfig)
// // 使用建议搜索服务获取建议列表,结果在onSuggestionResult()中更新【这里也是百度三方的东西】
// mSuggestionSearch?.requestSuggestion(
// SuggestionSearchOption().keyword(s.toString()) // 关键字
// .city(viewModel.positioningBean?.city ?: "北京")
// )
} }
}) })
historyRecordAdapter = HistoryRecordAdapter(this,viewModel)
//历史记录
historyRecordAdapter = HistoryRecordAdapter(this, viewModel)
//热门景点
popularSceneAdapter = PopularSceneAdapter(this) popularSceneAdapter = PopularSceneAdapter(this)
mAdapter?.addAdapter(historyRecordAdapter) mAdapter?.addAdapter(historyRecordAdapter)
...@@ -130,11 +141,18 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -130,11 +141,18 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
} }
}) })
viewModel.searchName.observe(this, Observer<HistoryBean> { viewModel.searchName.observe(this, Observer<HistoryBean> {
if (TextUtils.isEmpty(it.name)){ if (TextUtils.isEmpty(it.name)) {
return@Observer return@Observer
} }
historyRecordAdapter?.addHistoryData(it) historyRecordAdapter?.addHistoryData(it)
}) })
viewModel.positiondata.observe(this@SearchMapActivity, Observer {
//srl_my.finishRefresh(true)
it?.apply {
onGetSuggestionResult(this)
}
})
} }
private fun territory() { private fun territory() {
...@@ -157,12 +175,32 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -157,12 +175,32 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
update() update()
} }
fun onGetSuggestionResult(postionConfig: List<PositionBean>?) {
if (postionConfig == null) {
return
}
viewModel.searchAfterOneItems.clear()
if (TextUtils.isEmpty(binding.et.text)) {
return
}
for (info in postionConfig!!) {
viewModel.searchAfterOneItems.add(
SearchAfterItem(
viewModel, info.name, info.address, info.location
)
)
}
}
/** /**
* 获取在线建议搜索结果,得到requestSuggestion返回的搜索结果 * 获取在线建议搜索结果,得到requestSuggestion返回的搜索结果
* * 【这里是第三方百度的东西】
* @param suggestionResult Sug检索结果 * @param suggestionResult Sug检索结果
*/ */
override fun onGetSuggestionResult(suggestionResult: SuggestionResult?) { /* override fun onGetSuggestionResult(suggestionResult: SuggestionResult?) {
if (suggestionResult == null || suggestionResult.allSuggestions == null) { if (suggestionResult == null || suggestionResult.allSuggestions == null) {
return return
} }
...@@ -178,5 +216,5 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo ...@@ -178,5 +216,5 @@ class SearchMapActivity : BaseActivity<ActivitySearchMapBinding, SearchMapViewMo
) )
) )
} }
} }*/
} }
\ No newline at end of file
...@@ -9,10 +9,9 @@ import androidx.lifecycle.MutableLiveData ...@@ -9,10 +9,9 @@ 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.HistoryBean import com.mints.street.bean.*
import com.mints.street.bean.MapBean import com.mints.street.model.BaiduModel
import com.mints.street.bean.Places import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.bean.PositioningBean
import me.goldze.mvvmhabit.base.AppManager 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.BindingAction
...@@ -28,14 +27,18 @@ import java.io.InputStreamReader ...@@ -28,14 +27,18 @@ import java.io.InputStreamReader
*/ */
class SearchMapViewModel(application: Application) : BaseViewModel(application) { class SearchMapViewModel(application: Application) : BaseViewModel(application) {
var index = 0;//0=境内 1=境外 var index = 0;//0=境内 1=境外
val positiondata: MutableLiveData<List<PositionBean>> = MutableLiveData()
//这里是走的一个点击回调,能够打开首页进行定位
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>()
//搜索的name //搜索的name
val searchName = MutableLiveData<HistoryBean>() val searchName = MutableLiveData<HistoryBean>()
//定位位置 //定位位置
val positioningBean: PositioningBean? =getpositioningMap() val positioningBean: PositioningBean? =getpositioningMap()
private fun getpositioningMap():PositioningBean?{ private fun getpositioningMap():PositioningBean?{
SPUtils.getInstance(SPUtils.POSITIONING_MAP) SPUtils.getInstance(SPUtils.POSITIONING_MAP)
.decodeString(SPUtils.POSITIONING_MAP)?.apply { .decodeString(SPUtils.POSITIONING_MAP)?.apply {
...@@ -45,6 +48,8 @@ class SearchMapViewModel(application: Application) : BaseViewModel(application) ...@@ -45,6 +48,8 @@ class SearchMapViewModel(application: Application) : BaseViewModel(application)
} }
return null return null
} }
val mapBean = MutableLiveData<MapBean>() val mapBean = MutableLiveData<MapBean>()
fun getMapBean(){ fun getMapBean(){
...@@ -67,6 +72,64 @@ class SearchMapViewModel(application: Application) : BaseViewModel(application) ...@@ -67,6 +72,64 @@ class SearchMapViewModel(application: Application) : BaseViewModel(application)
} }
/**
* 获取国外搜索信息【通过搜索内容进行查找】
*/
fun searchabroad(position:String) {
val vo = hashMapOf<String, Any>()
vo["query"] = "澳大利亚 海岸"
vo["region"] = "全球"
vo["output"] = "json"
vo["ak"] = "tnFhCM9cTeTDZqNjRPVHbfzOz6AUPoEq"
// BaiduModel.suggestionPlaceAbroad(lifecycleProvider,vo).safeSubscribe(
BaiduModel.suggestionPlaceAbroad(lifecycleProvider,position,"全球","json","tnFhCM9cTeTDZqNjRPVHbfzOz6AUPoEq").safeSubscribe(
object : HttpSubscribeImpl<BaseArrayResponse<PositionBean>>(
this@SearchMapViewModel, true) {
override fun onBusinessSuccess(response: BaseArrayResponse<PositionBean>) {
positiondata.value = response.result
println("mcg __ "+response.result)
}
override fun onError(e: Throwable) {
}
}
)
}
/**
* 获取国内搜索信息
*/
fun searchdomestic(position:String) {
val vo = hashMapOf<String, Any>()
vo["query"] = "北京"
vo["region"] = "中国"
vo["output"] = "json"
vo["ak"] = "C56Qdc560TQKtQaavS0NTPUYupsZHspI"
// BaiduModel.suggestionPlaceAbroad(lifecycleProvider,vo).safeSubscribe(
/*
http://api.map.baidu.com/place/v2/suggestion?
query=%E5%8C%97%E4%BA%AC
&region=%E5%85%A8%E5%9B%BD
&output=json
&page_size=50&
ak=C56Qdc560TQKtQaavS0NTPUYupsZHspI
*/
BaiduModel.suggestionPlaceDomestic(lifecycleProvider,position,"中国","json","C56Qdc560TQKtQaavS0NTPUYupsZHspI").safeSubscribe(
object : HttpSubscribeImpl<BaseArrayResponse<PositionBean>>(
this@SearchMapViewModel, true) {
override fun onBusinessSuccess(response: BaseArrayResponse<PositionBean>) {
positiondata.value = response.result
println("mcg __ "+response.result)
}
override fun onError(e: Throwable) {
}
}
)
}
} }
\ No newline at end of file
package com.mints.street.main.home
import com.baidu.mapapi.search.sug.SuggestionResult
import com.mints.street.bean.PositionBean
interface onGetSuggestionPositionsLister {
fun onGetSuggestionResult(var1: PositionBean?)
}
...@@ -21,11 +21,10 @@ class AboutusActivity : BaseActivity<ActivityAboutusBinding, AboutusViewModel>() ...@@ -21,11 +21,10 @@ class AboutusActivity : BaseActivity<ActivityAboutusBinding, AboutusViewModel>()
override fun initVariableId() = BR.viewModel override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_aboutus override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_aboutus
override fun getStatusBarHeightView(): View? { override fun getStatusBarHeightView(): View? {
return null return binding.tvText
} }
override fun initData() { override fun initData() {
super.initData() super.initData()
StatusBarUtil.setHeightAndPadding(this, binding.tvText)
initView() initView()
initListener() initListener()
} }
......
...@@ -27,12 +27,11 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti ...@@ -27,12 +27,11 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
override fun initVariableId() = BR.viewModel override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_moresettings override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_moresettings
override fun getStatusBarHeightView(): View? { override fun getStatusBarHeightView(): View? {
return null return binding.elView
} }
override fun initData() { override fun initData() {
super.initData() super.initData()
StatusBarUtil.setHeightAndPadding(this, binding.elView)
initView() initView()
initListener() initListener()
......
package com.mints.street.main.my package com.mints.street.main.my
import android.Manifest import android.Manifest
import android.app.Dialog
import android.content.Context import android.content.Context
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
...@@ -31,6 +32,8 @@ import com.mints.street.manager.UserManager ...@@ -31,6 +32,8 @@ import com.mints.street.manager.UserManager
import com.mints.street.manager.oaid.OaidManager import com.mints.street.manager.oaid.OaidManager
import com.mints.street.utils.json.JsonUtil import com.mints.street.utils.json.JsonUtil
import com.mints.street.webview.MintsWebViewActivity import com.mints.street.webview.MintsWebViewActivity
import com.mints.street.widget.dialog.DialogListener
import com.mints.street.widget.dialog.DialogUtils
import com.scwang.smartrefresh.layout.api.RefreshLayout import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
...@@ -91,10 +94,10 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -91,10 +94,10 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
private fun initListener() { private fun initListener() {
//设置登录点击事件 //设置登录点击事件
RxUtils.onMultiClick(binding.llMyLogin) { RxUtils.onMultiClick(binding.llMyLogin) {
// binding.llMyLogin.setOnClickListener {
if (!userManager.userIsLogin()) { if (!userManager.userIsLogin()) {
//显示登录弹窗 //显示登录弹窗
showlogindialog(context) showlogindialog(context)
// backvipDialog()
} }
} }
//设置立即领取点击事件 //设置立即领取点击事件
...@@ -105,6 +108,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -105,6 +108,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
} else { } else {
//打开登录弹框 //打开登录弹框
showlogindialog(context) showlogindialog(context)
// backvipDialog()
} }
} }
...@@ -149,6 +153,59 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -149,6 +153,59 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
} }
} }
/*private fun backvipDialog() {
//显示登录弹窗
DialogUtils.showloginDialog(context!!, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
if (dialog != null && dialog.isShowing) {
dialog.dismiss()
}
//点击事件响应
when (v?.id) {
R.id.iv_weixin -> {
if (cb_checked!!.isChecked) {//判断是否选中条款
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {//是否安装微信
ToastUtils.showShort("请先安装微信")
return
}
RxPermissions(this@MyFragment)
.request(Manifest.permission.READ_PHONE_STATE)
.subscribe { granted: Boolean ->
if (granted) {
loginApi.setOnLoginListener(this@MyFragment)
loginApi.setPlatform(Wechat.NAME)
loginApi.login(context)
} else {
// showMissingPermissionDialog("设备")
}
}
// dialog?.dismiss()
} else {
ToastUtils.showShort("请先同意用户协议与隐私政策")
}
}
R.id.ly_phone -> {
if (cb_checked!!.isChecked) {
startActivity(LoginActivity::class.java)
// dialog?.dismiss()
} else {
ToastUtils.showShort("请先同意用户协议与隐私政策")
} }
R.id.tv_private -> {//取消
MintsWebViewActivity.startWebView(name = "隐私协议", url = "http://test.mints-id.com/map-api/map/privacy.html")
}
R.id.tv_regist -> {//取消
MintsWebViewActivity.startWebView(name = "用户协议", url = "http://test.mints-id.com/map-api/map/register.html")
}
}
}
})
}*/
private fun initView() { private fun initView() {
aboutus.findViewById<TextView>(R.id.tv_title).text = "关于我们" aboutus.findViewById<TextView>(R.id.tv_title).text = "关于我们"
val userAgree = ContextCompat.getDrawable(context!!, R.mipmap.iv_about_us) val userAgree = ContextCompat.getDrawable(context!!, R.mipmap.iv_about_us)
......
...@@ -3,6 +3,7 @@ package com.mints.street.main.my ...@@ -3,6 +3,7 @@ package com.mints.street.main.my
import android.app.Application import android.app.Application
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import com.mints.street.bean.BaseResponse import com.mints.street.bean.BaseResponse
import com.mints.street.bean.PositionBean
import com.mints.street.bean.UserBean import com.mints.street.bean.UserBean
import com.mints.street.common.DeviceInfo import com.mints.street.common.DeviceInfo
import com.mints.street.manager.UserManager import com.mints.street.manager.UserManager
...@@ -104,29 +105,5 @@ class MyViewModel(application: Application) : BaseViewModel(application) { ...@@ -104,29 +105,5 @@ class MyViewModel(application: Application) : BaseViewModel(application) {
/**
* 获取个人信息
*/
fun test() {
val vo = hashMapOf<String, Any>()
vo["query"] = "澳大利亚 海岸"
vo["region"] = "全球"
vo["output"] = "json"
vo["ak"] = "tnFhCM9cTeTDZqNjRPVHbfzOz6AUPoEq"
// BaiduModel.suggestionPlaceAbroad(lifecycleProvider,vo).safeSubscribe(
BaiduModel.suggestionPlaceAbroad(lifecycleProvider,"澳大利亚 海岸","全球","json","tnFhCM9cTeTDZqNjRPVHbfzOz6AUPoEq").safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@MyViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
println("mcg __ "+response.result)
}
override fun onError(e: Throwable) {
}
}
)
}
} }
\ No newline at end of file
...@@ -46,7 +46,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -46,7 +46,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_openvip override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_openvip
override fun getStatusBarHeightView(): View? { override fun getStatusBarHeightView(): View? {
return null return binding.viewBg
} }
override fun initData() { override fun initData() {
...@@ -58,7 +58,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -58,7 +58,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
viewModel.getpaymentwey("android") viewModel.getpaymentwey("android")
} }
StatusBarUtil.setHeightAndPadding(this, binding.viewBg)
initView() initView()
initListener() initListener()
} }
......
...@@ -20,8 +20,12 @@ object BaiduModel { ...@@ -20,8 +20,12 @@ object BaiduModel {
// .execute(lifecycleProvider, BaiduApi.newInstance().suggestionPlaceAbroad(map)) // .execute(lifecycleProvider, BaiduApi.newInstance().suggestionPlaceAbroad(map))
// } // }
fun suggestionPlaceAbroad(lifecycleProvider: LifecycleProvider<Any>?, map: String,map2 :String,map3: String,map4: String): Observable<Response<BaseResponse<Any>>> { fun suggestionPlaceAbroad(lifecycleProvider: LifecycleProvider<Any>?, map: String,map2 :String,map3: String,map4: String): Observable<Response<BaseArrayResponse<PositionBean>>> {
return BaiduHttpManager.getInstance() return BaiduHttpManager.getInstance()
.execute(lifecycleProvider, BaiduApi.newInstance().suggestionPlaceAbroad(map,map2,map3,map4)) .execute(lifecycleProvider, BaiduApi.newInstance().suggestionPlaceAbroad(map,map2,map3,map4))
} }
fun suggestionPlaceDomestic(lifecycleProvider: LifecycleProvider<Any>?, map: String,map2 :String,map3: String,map4: String): Observable<Response<BaseArrayResponse<PositionBean>>> {
return BaiduHttpManager.getInstance()
.execute(lifecycleProvider, BaiduApi.newInstance().suggestionPlaceDomestic(map,map2,map3,map4))
}
} }
\ No newline at end of file
...@@ -24,4 +24,14 @@ object DialogUtils{ ...@@ -24,4 +24,14 @@ object DialogUtils{
dialogListener.setDialog(bonusDialog) dialogListener.setDialog(bonusDialog)
} }
/**
* 登录弹窗
*/
fun showloginDialog(ctx: Context,dialogListener: DialogListener){
val weakReference=WeakReference<Context>(ctx)
val baseDialog=ShowLoginDialog(weakReference.get()!!,dialogListener)
baseDialog.show()
dialogListener.setDialog(baseDialog)
}
} }
\ No newline at end of file
...@@ -21,7 +21,7 @@ class ShowBenfitDialog(context: Context, private val listener: DialogListener) : ...@@ -21,7 +21,7 @@ class ShowBenfitDialog(context: Context, private val listener: DialogListener) :
private var gridbenfitAdapter: GridBenfitAdapter? = null private var gridbenfitAdapter: GridBenfitAdapter? = null
init { init {
setContentView(R.layout.dialog_showbenfit) setContentView(R.layout.layout_popupwindow)
// 设置window属性 // 设置window属性
lp = window!!.attributes lp = window!!.attributes
lp.gravity = Gravity.CENTER lp.gravity = Gravity.CENTER
......
package com.mints.street.widget.dialog
import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.KeyEvent
import android.view.WindowManager
import android.widget.CheckBox
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.mints.street.R
import com.mints.street.adapter.GridBenfitAdapter
import com.mints.street.login.LoginActivity
import me.goldze.mvvmhabit.utils.RxUtils
import me.goldze.mvvmhabit.utils.ToastUtils
class ShowLoginDialog(context: Context, private val listener: DialogListener) :
BottomSheetDialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams
//弹窗
private var iv_weixin: ImageView? = null
private var ly_phone: LinearLayoutCompat? = null
private var cb_checked: CheckBox? = null
private var tv_regist: TextView? = null
private var tv_private: TextView? = null
init {
setContentView(R.layout.layout_popupwindow)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.WRAP_CONTENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(true)
setCanceledOnTouchOutside(false)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
initView();
tv_regist?.setOnClickListener {
listener.onClick(it)
}
tv_private?.setOnClickListener {
listener.onClick(it)
}
iv_weixin?.setOnClickListener {
listener.onClick(it)
}
ly_phone?.setOnClickListener {
listener.onClick(it)
}
}
private fun initView() {
iv_weixin = findViewById(R.id.iv_weixin)
ly_phone =findViewById(R.id.ly_phone)
cb_checked = findViewById(R.id.cb_checked)
tv_private = findViewById(R.id.tv_private)
tv_regist = findViewById(R.id.tv_regist)
// ly_phone?.setOnClickListener(this)
// RxUtils.onMultiClick(ly_phone) {
// if (cb_checked!!.isChecked) {
// startActivity(LoginActivity::class.java)
// mBottomSheetDialog!!.dismiss()
// } else {
// ToastUtils.showShort("请先同意用户协议与隐私政策")
// }
// }
}
}
\ No newline at end of file
...@@ -164,9 +164,7 @@ ...@@ -164,9 +164,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="搜索境内、境外地址" android:text="搜索境内、境外地址"
android:textColor="#A2A4B1" android:textColor="#A2A4B1"
android:textSize="14sp" android:textSize="14sp" />
/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
......
//package me.goldze.mvvmhabit.http;
//
//import java.util.List;
//
///**
// * Created by goldze on 2017/5/10.
// * 该类仅供参考,实际业务返回的固定字段, 根据需求来定义,
// */
//public class BaseArrayResponse<T> extends BaseResponse<List<T>>{
//
//
// @Override
// public List<T> getResult() {
// return result;
// }
//
// @Override
// public void setResult(List<T> result) {
// this.result = result;
// }
//
//}
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