Commit f3c1651d authored by fengruiyu's avatar fengruiyu

Merge branch 'branche_zsf' of http://39.97.65.143:81/android/android_street into fry_dev

 Conflicts:
	app/src/main/java/com/mints/street/main/home/HomeViewModel.kt
parents d7975c25 6c1c6389
package com.mints.street.adapter
import android.content.Context
import android.graphics.Paint
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.bumptech.glide.Glide
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin
import com.mints.street.R
import com.mints.street.bean.Places
import com.mints.street.databinding.ItemGridBenfitAdpaterBinding
import com.mints.street.databinding.ItemGridPaymentAdpaterBinding
import com.mints.street.main.home.HomeViewModel
import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.RxUtils
class GridBenfitAdapter(val context: Context, val list: List<String>) :
class GridBenfitAdapter(val context: Context, val viewMode: HomeViewModel?, places: List<Places>?) :
AbstractVLayoutBaseAdapter<ItemGridBenfitAdpaterBinding,
List<String>>(context, list, 3) {
List<Places>>(context, places, 3) {
private var datalist: List<String>? = list
private var datalist: List<Places>? = places
private var mposition: Int = 0//设置首次进来默认选中第一个
override fun onBindViewHolder(holder: BindingViewHolder<ItemGridBenfitAdpaterBinding>, position: Int) {
//设置 view边距
......@@ -31,8 +33,19 @@ class GridBenfitAdapter(val context: Context, val list: List<String>) :
AppUtils.dp2Px(context, 20F), 0, null, null, null)
}
// holder.binding.bg.setMargin(AppUtils.dp2Px(context, 20F), AppUtils.dp2Px(context, 10F),
// 0, 0, null, null, null)
datalist?.get(position)?.apply {
//设置图片
Glide.with(mContext).load(images?.get(0)).into(holder.binding.imageView3)
//设置标题
holder.binding.textView.text = name
//设置点击跳转
RxUtils.onMultiClick(holder.itemView) {
//页面跳转
// MintsWebViewActivity.startWebView(name, url = url)
viewMode?.authorized(name, latitude.toString(), longitude.toString(), true)
}
}
}
......
package com.mints.street.adapter
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.mints.street.bean.AuthorizedBean
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.MapBean
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.io.BufferedReader
import java.io.InputStreamReader
class GridBenfitViewModel (application: Application) : BaseViewModel(application) {
val mapBean = MutableLiveData<MapBean>()
//0=境内 1=境外
val index = MutableLiveData(0)
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出问题")
}
}
fun authorized(name:String?=null,lat:String?,lng:String?) {
ApiModel.authorized().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
this@GridBenfitViewModel,false
) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
if(index.value == 0){
MintsWebViewActivity.startWebView(name,
MintsWebViewActivity.toBaduVR(lat,lng,response.result?.bk))
}else{
MintsWebViewActivity.startWebView(name,
MintsWebViewActivity.toGoogleVR(
response.result.u,
response.result.gk,
response.result.base,
lat,
lng,
response.result.ut
))
}
}
})
}
}
......@@ -12,7 +12,6 @@ import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.utils.DeviceUuidFactory
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.ToastUtils
import java.util.HashMap
/**
......
......@@ -15,7 +15,6 @@ import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
/**
* Created by 冯瑞雨 on 2021/7/1.
......
package com.mints.street.main.home
import android.app.Dialog
import android.content.Context.SENSOR_SERVICE
import android.hardware.Sensor
import android.hardware.SensorEvent
......@@ -8,6 +9,7 @@ import android.hardware.SensorManager
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import com.baidu.location.BDLocation
......@@ -20,11 +22,14 @@ import com.fry.base.base.BaseFragment
import com.google.gson.Gson
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.bean.MapBean
import com.mints.street.bean.PositioningBean
import com.mints.street.databinding.FragmentHomeBinding
import com.mints.street.manager.UmengManager
import com.mints.street.utils.GPSConverterUtils
import com.mints.street.widget.ScrollLayout
import com.mints.street.widget.dialog.DialogListener
import com.mints.street.widget.dialog.DialogUtils
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.RxUtils
......@@ -41,7 +46,8 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
// 定位相关
private var mLocClient: LocationClient? = null
private var isScrollLayoutClose:Boolean= false
private var isScrollLayoutClose: Boolean = false
// 定位图层显示方式
private var mCurrentMode: MyLocationConfiguration.LocationMode? = null
private var mSensorManager: SensorManager? = null
......@@ -59,6 +65,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
//当前的经纬度
//纬度
private var currentLat = 0.0
//经度
private var currentLon = 0.0
......@@ -72,9 +79,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
override fun initContentView(
inflater: LayoutInflater?,
container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater?,
container: ViewGroup?,
savedInstanceState: Bundle?
) = R.layout.fragment_home
override fun initVariableId() = BR.viewModel
......@@ -94,25 +101,29 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
override fun initData() {
super.initData()
Handler().postDelayed({ isScrollLayoutClose = true },2000)
Handler().postDelayed({ isScrollLayoutClose = true }, 2000)
RxUtils.onMultiClick(binding.stbBgSearch) {
SearchMapActivity.startSearchMapActivity(this)
}
RxUtils.onMultiClick(binding.ivClick){
viewModel.authorized("",currentLat.toString(), currentLon.toString(),false)
RxUtils.onMultiClick(binding.ivClick) {
viewModel.authorized("", currentLat.toString(), currentLon.toString(), false)
}
viewModel.getMapBean()
}
override fun initViewObservable() {
viewModel.pt.observe(this, Observer {
if (it==null)return@Observer
if (it == null) return@Observer
// 默认 天安门
val gps = GPSConverterUtils.gcj02_To_Bd09(it.lat,it.lng)
val gps = GPSConverterUtils.gcj02_To_Bd09(it.lat, it.lng)
val center = LatLng(gps.lat, gps.lng)
setNewMapStatus(center)
binding.scrollLayout.toggle(ScrollLayout.STATUS_CLOSE)
})
viewModel.mapbeanData.observe(this, Observer<MapBean> {
DialogUtils.showbennfitsDialog(context!!,viewModel,it.innerPlaces?.places)
})
}
private fun initMap() {
......@@ -127,7 +138,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
val center = LatLng(39.915071, 116.403907)
// 默认 11级
val zoom = 11.0f
builder.target(center).zoom(zoom)
builder.target(center).zoom(zoom)
val mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(builder.build())
// 设置地图状态
......@@ -138,23 +149,23 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
}
override fun onMapStatusChangeStart(status: MapStatus?, reason: Int) {
KLog.a("百度map", "移动开始,两个参数")
KLog.a("百度map", "移动开始,两个参数")
}
override fun onMapStatusChange(status: MapStatus?) {
KLog.a("百度map", "移动改变")
if (!binding.scrollLayout.isClose&& isScrollLayoutClose){
binding.scrollLayout.post {
binding.scrollLayout.toggle(ScrollLayout.STATUS_CLOSE)
}
if (!binding.scrollLayout.isClose && isScrollLayoutClose) {
binding.scrollLayout.post {
binding.scrollLayout.toggle(ScrollLayout.STATUS_CLOSE)
}
}
}
override fun onMapStatusChangeFinish(status: MapStatus?) {
KLog.a("百度map", "移动结束")
currentLat = status?.target?.latitude?:0.0
currentLon = status?.target?.longitude?:0.0
KLog.a("百度map", "移动结束")
currentLat = status?.target?.latitude ?: 0.0
currentLon = status?.target?.longitude ?: 0.0
}
})
//使地图缩放级别增大一级
......@@ -191,13 +202,13 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
private fun initLocation() {
// 获取传感器管理服务
mSensorManager = AppManager.getAppManager().currentActivity
.getSystemService(SENSOR_SERVICE) as SensorManager
.getSystemService(SENSOR_SERVICE) as SensorManager
mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL
// 为系统的方向传感器注册监听器
mSensorManager?.registerListener(
this,
mSensorManager?.getDefaultSensor(Sensor.TYPE_ORIENTATION),
SensorManager.SENSOR_DELAY_UI
this,
mSensorManager?.getDefaultSensor(Sensor.TYPE_ORIENTATION),
SensorManager.SENSOR_DELAY_UI
)
// 开启定位图层
......@@ -275,11 +286,11 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
mCurrentLon = location.longitude
mCurrentAccracy = location.radius
myLocationData = MyLocationData.Builder()
.accuracy(location.radius) // 设置定位数据的精度信息,单位:米
.direction(mCurrentDirection.toFloat()) // 此处设置开发者获取到的方向信息,顺时针0-360
.latitude(location.latitude)
.longitude(location.longitude)
.build()
.accuracy(location.radius) // 设置定位数据的精度信息,单位:米
.direction(mCurrentDirection.toFloat()) // 此处设置开发者获取到的方向信息,顺时针0-360
.latitude(location.latitude)
.longitude(location.longitude)
.build()
this.setMyLocationData(myLocationData)
if (isFirstLoc) {
isFirstLoc = false
......@@ -295,15 +306,15 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
override fun onSensorChanged(sensorEvent: SensorEvent?) {
val x: Double =
sensorEvent?.values?.get(SensorManager.DATA_X)?.toDouble() ?: 0.0
sensorEvent?.values?.get(SensorManager.DATA_X)?.toDouble() ?: 0.0
if (kotlin.math.abs(x - lastX) > 1.0) {
mCurrentDirection = x.toInt()
myLocationData = MyLocationData.Builder()
.accuracy(mCurrentAccracy) // 设置定位数据的精度信息,单位:米
.direction(mCurrentDirection.toFloat()) // 此处设置开发者获取到的方向信息,顺时针0-360
.latitude(mCurrentLat)
.longitude(mCurrentLon)
.build()
.accuracy(mCurrentAccracy) // 设置定位数据的精度信息,单位:米
.direction(mCurrentDirection.toFloat()) // 此处设置开发者获取到的方向信息,顺时针0-360
.latitude(mCurrentLat)
.longitude(mCurrentLon)
.build()
mBaiduMap?.setMyLocationData(myLocationData)
}
lastX = x
......@@ -318,7 +329,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
*
* @param v
*/
private fun setNewMapStatus(latLng :LatLng) {
private fun setNewMapStatus(latLng: LatLng) {
val builder = MapStatus.Builder()
builder.target(latLng).zoom(18.5f).overlook(-21f).rotate(0f)
// 更新地图状态
......
......@@ -9,6 +9,7 @@ import com.mints.street.BR
import com.mints.street.R
import com.mints.street.bean.*
import com.mints.street.common.DeviceInfo
import com.mints.street.db.ScenicSpotBean
import com.mints.street.main.my.OpenvipActivity
import com.mints.street.manager.UserManager
import com.mints.street.manager.oaid.OaidManager
......@@ -18,8 +19,6 @@ import com.mints.street.utils.DeviceUuidFactory
import com.mints.street.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.base.AppManager
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 java.io.BufferedReader
......@@ -28,7 +27,7 @@ import java.io.InputStreamReader
/**
* Created by 冯瑞雨 on 2021/7/2.
*/
class HomeViewModel(application: Application):BaseViewModel(application) {
class HomeViewModel(application: Application) : BaseViewModel(application) {
var addressList = ObservableArrayList<HomeButtonItemVM?>()
......@@ -38,7 +37,6 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
val authorizedBean = MutableLiveData<AuthorizedBean>()
fun authorized() {
ApiModel.authorized().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
......@@ -93,7 +91,10 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
}
fun getMapBean(){
var mapbeanData=MutableLiveData<MapBean>()
fun getMapBean() {
val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder()
var mapBean:MapBean?=null
......@@ -107,8 +108,10 @@ class HomeViewModel(application: Application):BaseViewModel(application) {
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
}
mapBean = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e:Exception){
mapbeanData.value= Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
mapBean = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e: Exception) {
KLog.e("读取assets文件下的json出问题")
}
val bean = mapBean?.homePlaces?.places
......
package com.mints.street.main.home
import android.app.Application
import android.content.Intent
import android.text.TextUtils
import android.view.View
import androidx.databinding.ObservableArrayList
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
......@@ -16,8 +14,6 @@ import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.base.AppManager
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.goldze.mvvmhabit.utils.SPUtils
import me.tatarka.bindingcollectionadapter2.ItemBinding
......
......@@ -3,13 +3,11 @@ package com.mints.street.main.my
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.PositionBean
import com.mints.street.bean.UserBean
import com.mints.street.common.DeviceInfo
import com.mints.street.manager.UserManager
import com.mints.street.manager.oaid.OaidManager
import com.mints.street.model.ApiModel
import com.mints.street.model.BaiduModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.utils.DeviceUuidFactory
import me.goldze.mvvmhabit.base.BaseViewModel
......
package com.mints.street.main.my
import android.app.Application
import androidx.core.graphics.PathParser
import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.ToastUtils
import com.mints.street.bean.*
......
......@@ -2,11 +2,9 @@ package com.mints.street.main.vr
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.mints.street.bean.AuthorizedBean
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.DetailedBean
import com.mints.street.bean.VipBean
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.webview.MintsWebViewActivity
......
......@@ -2,7 +2,6 @@ package com.mints.street.main.vr
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.street.bean.BaseArrayResponse
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.VreperienceBean
import com.mints.street.bean.VrmapBean
......
......@@ -3,15 +3,12 @@ package com.mints.street.main.vr
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.VipBean
import com.mints.street.bean.VrmapBean
import com.mints.street.db.AppDatabase
import com.mints.street.db.ScenicSpotBean
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap
/**
* Created by 冯瑞雨 on 2021/7/9.
......
package com.mints.street.netwrok.base
import androidx.lifecycle.ViewModel
import com.mints.street.adapter.GridBenfitViewModel
import com.mints.street.bean.BaseResponse
import com.mints.street.main.home.SearchMapViewModel
import me.goldze.mvvmhabit._enum.ViewStatus
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.ExceptionHandle
......
package com.mints.street.widget;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
@SuppressLint("AppCompatCustomView")
public class RoundRectImageView extends ImageView {
private Paint paint;
public RoundRectImageView(Context context) {
this(context, null);
}
public RoundRectImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public RoundRectImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
paint = new Paint();
}
/**
* 绘制圆角矩形图片
*
* @author caizhiming
*/
@Override
protected void onDraw(Canvas canvas) {
Drawable drawable = getDrawable();
if (null != drawable) {
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
Bitmap b = toRoundBitmap(bitmap);
final Rect rectSrc = new Rect(0, 0, b.getWidth(), b.getHeight());
final Rect rectDest = new Rect(0, 0, getWidth(), getHeight());
paint.reset();
canvas.drawBitmap(b, rectSrc, rectDest, paint);
} else {
super.onDraw(canvas);
}
}
/**
* 获取圆角矩形图片方法
*
* @param bitmap
* @param roundPx,一般设置成14
* @return Bitmap
* @author caizhiming
*/
private Bitmap getRoundBitmap(Bitmap bitmap, int roundPx) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
int x = bitmap.getWidth();
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
/**
* 将长方形图片裁剪成圆形
* @param bitmap
* @return
*/
private Bitmap toRoundBitmap(Bitmap bitmap) {
final int STROKE_WIDTH = 4;
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float roundPx;
float left, top, right, bottom, dst_left, dst_top, dst_right, dst_bottom;
if (width <= height) {
roundPx = width / 2;
top = 0;
left = 0;
bottom = width;
right = width;
height = width;
dst_left = 0;
dst_top = 0;
dst_right = width;
dst_bottom = width;
} else {
roundPx = height / 2;
float clip = (width - height) / 2;
left = clip;
right = width - clip;
top = 0;
bottom = height;
width = height;
dst_left = 0;
dst_top = 0;
dst_right = height;
dst_bottom = height;
}
Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect src = new Rect((int) left, (int) top, (int) right, (int) bottom);
final Rect dst = new Rect((int) dst_left, (int) dst_top, (int) dst_right, (int) dst_bottom);
final RectF rectF = new RectF(dst);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(Color.WHITE);
paint.setStrokeWidth(4);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, src, dst, paint);
// 画白色圆圈
paint.reset();
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(STROKE_WIDTH);
paint.setAntiAlias(true);
canvas.drawCircle(width / 2, width / 2, width / 2 - STROKE_WIDTH / 2, paint);
return output;
}
}
package com.mints.street.widget.dialog
import androidx.fragment.app.FragmentActivity
import com.mints.street.login.OnLoginListener
class BenfitDialog(context: FragmentActivity){
}
\ No newline at end of file
......@@ -6,6 +6,9 @@ import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import com.mints.street.adapter.GridBenfitViewModel
import com.mints.street.bean.Places
import com.mints.street.main.home.HomeViewModel
import java.lang.ref.WeakReference
object DialogUtils {
......@@ -46,11 +49,10 @@ object DialogUtils {
/**
* 打开展示的限时福利弹框
*/
fun showbennfitsDialog(ctx: Context, dialogListener: DialogListener) {
fun showbennfitsDialog(ctx: Context, viewMode: HomeViewModel, places: List<Places>?) {
val weakReference = WeakReference<Context>(ctx)
val bonusDialog = ShowBenfitDialog(weakReference.get()!!, dialogListener)
val bonusDialog = ShowBenfitDialog(weakReference.get()!!,viewMode,places)
bonusDialog.show()
dialogListener.setDialog(bonusDialog)
}
}
\ No newline at end of file
......@@ -5,23 +5,31 @@ import android.content.Context
import android.view.Gravity
import android.view.KeyEvent
import android.view.WindowManager
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.mints.street.R
import com.mints.street.adapter.GridBenfitViewModel
import com.mints.street.bean.Places
import com.mints.street.main.home.HomeViewModel
import me.goldze.mvvmhabit.utils.RxUtils
import com.mints.street.adapter.GridBenfitAdapter as GridBenfitAdapter
class ShowBenfitDialog(context: Context, private val listener: DialogListener) :
class ShowBenfitDialog(context: Context, val viewMode: HomeViewModel, places: List<Places>?) :
Dialog(context, R.style.dialog) {
private val lp: WindowManager.LayoutParams
private var recycleView: RecyclerView? = null
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
private var gridbenfitAdapter: GridBenfitAdapter? = null
private var places:List<Places>?=places
private var iv_close: ImageView?=null
init {
setContentView(R.layout.layout_popupwindow)
setContentView(R.layout.dialog_showbenfit)
// 设置window属性
lp = window!!.attributes
lp.gravity = Gravity.CENTER
......@@ -35,7 +43,7 @@ class ShowBenfitDialog(context: Context, private val listener: DialogListener) :
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
initView();
initView()
}
private fun initView() {
......@@ -46,8 +54,20 @@ class ShowBenfitDialog(context: Context, private val listener: DialogListener) :
recycleView?.adapter = mAdapter
recycleView?.layoutManager = vLayout
//展示 推荐套餐内容
gridbenfitAdapter= GridBenfitAdapter(context, listOf("1","2","3","1","2","3"))
mAdapter?.addAdapter(gridbenfitAdapter)
iv_close=findViewById(R.id.iv_close)
if (gridbenfitAdapter == null){
//展示 推荐套餐内容
gridbenfitAdapter= GridBenfitAdapter(context,viewMode,places?.shuffled()?.take(6))
mAdapter?.addAdapter(gridbenfitAdapter)
}
RxUtils.onMultiClick(iv_close){
dismiss()
}
// gridbenfitAdapter?.getPosition() = places!!
mAdapter?.notifyDataSetChanged()
}
}
\ No newline at end of file
......@@ -52,6 +52,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/iv_close"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_gravity="center"
......
......@@ -15,7 +15,7 @@
android:layout_height="wrap_content">
<ImageView
<com.mints.street.widget.RoundRectImageView
android:id="@+id/imageView3"
android:layout_width="66dp"
android:layout_height="66dp"
......@@ -41,7 +41,7 @@
android:layout_height="wrap_content"
android:text="北京故宫"
android:textColor="@color/black"
android:textSize="14sp"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="@+id/imageView3"
app:layout_constraintStart_toStartOf="@+id/imageView3"
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
......
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