GLDriver/app/src/main/java/com/arpa/hndahesudintocctmsdriver/utils/CommonPopUtils.kt
2024-04-28 16:24:08 +08:00

193 lines
5.6 KiB
Kotlin

package com.arpa.hndahesudintocctmsdriver.utils
import android.content.Context
import android.graphics.Color
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.arpa.hndahesudintocctmsdriver.R
import com.arpa.hndahesudintocctmsdriver.bean.AppVersion
import com.arpa.hndahesudintocctmsdriver.bean.CarBean
import com.arpa.hndahesudintocctmsdriver.callback.OnResultListener
import com.arpa.hndahesudintocctmsdriver.mypop.AgreementAlert
import com.arpa.hndahesudintocctmsdriver.mypop.OnCarSelectListener
import com.arpa.hndahesudintocctmsdriver.mypop.PopBottomCar
import com.arpa.hndahesudintocctmsdriver.weight.pop.InputMoneyPop
import com.arpa.hndahesudintocctmsdriver.weight.pop.UpAppPop
import com.arpa.glex.bean.UserDetail
import com.arpa.mylibrary.base.SingletonNoPHolder
import com.arpa.mylibrary.utils.ConvertUtils
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.interfaces.OnConfirmListener
import com.lxj.xpopup.interfaces.OnInputConfirmListener
import com.lxj.xpopup.util.SmartGlideImageLoader
/**
* @ClassName CommonPopUtils
* @Author john
* @Date 2024/3/5 15:48
* @Description TODO
*/
class CommonPopUtils private constructor() {
companion object : SingletonNoPHolder<CommonPopUtils>(::CommonPopUtils)
/**
* 选择车辆
* */
fun showCarList(
context: Context,
cars: MutableList<CarBean>,
isCap: Boolean = false,
selDriverId: String = "",
selCarId: String = "",
listener: OnCarSelectListener
) {
XPopup.Builder(context)
.isViewMode(true)
// .isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
.asCustom(PopBottomCar(context, cars, isCap,selDriverId,selCarId, listener))
.show()
}
/**
* 首次打开app弹窗
* @param context Context
* @param listener OnResultListener
*/
fun showCenterAgreement(context: Context, listener: OnResultListener) {
XPopup.Builder(context)
.dismissOnBackPressed(false)
.dismissOnTouchOutside(false)
.asCustom(
AgreementAlert(
context, "http://agreement.dahehuoyun.com/huawei/#/private",
"http://agreement.dahehuoyun.com/#/user", listener
)
)
.show()
}
/**
* 装货弹框
* */
fun showLoadPop(context: Context, carBean: CarBean, listener: OnConfirmListener) {
XPopup.Builder(context)
.isDestroyOnDismiss(true)
.asConfirm(
"去装货", """已选择:${carBean.vehicleNum},是否立即装货""",
"取消", "确定",
listener, null, false
)
.show()
}
/**
*
* @param context Context
* @param title String
* @param content String
* @param listener OnConfirmListener
*/
fun showCommCenterPop(
context: Context,
title: String = "提示",
content: String,
listener: OnConfirmListener,
) {
XPopup.Builder(context)
.isDestroyOnDismiss(true)
.asConfirm(
title, content,
"取消", "确定",
listener, null, false
)
.show()
}
/**
* 弹出带有输入框的
* @param context Context
* @param title String
* @param listener OnInputConfirmListener
*/
fun showCenterInputPop(context: Context, title: String, listener: OnInputConfirmListener) {
XPopup.Builder(context)
.hasStatusBarShadow(false)
.hasNavigationBar(false)
.autoOpenSoftInput(true)
.asInputConfirm(title, "", "请输入拒绝原因", listener)
.show()
}
/**
* 展示图片
* @param context Context
* @param position Int
* @param recyclerView RecyclerView
* @param mutableList MutableList<Any>
*/
fun showPics(
context: Context,
imageView: ImageView? = null,
position: Int,
recyclerView: RecyclerView,
mutableList: List<Any>
) {
XPopup.Builder(context) //.animationDuration(1000)
.isTouchThrough(true)
.asImageViewer(
imageView, position, mutableList,
false, true, -1, -1, ConvertUtils.dp2px(10F), false,
Color.rgb(32, 36, 46),
{ popupView, position ->
popupView.updateSrcView(recyclerView.getChildAt(position) as ImageView)
}, SmartGlideImageLoader(true, R.mipmap.ic_launcher), null
)
.show()
}
/**
* app版本检查
* @param context Context
* @param appVersion AppVersion
*/
fun showUpApp(context: Context, appVersion: AppVersion) {
XPopup.Builder(context)
.dismissOnBackPressed(false)
.dismissOnTouchOutside(false)
.asCustom(
UpAppPop(
context,
appVersion
)
)
.show()
}
/**
* 提现弹窗
* @param context Context
* @param userInfo UserDetail
* @param listener OnInputConfirmListener
*/
fun showPickMoney(context: Context, userInfo: UserDetail, listener: OnInputConfirmListener) {
XPopup.Builder(context)
.dismissOnBackPressed(true)
.dismissOnTouchOutside(true)
.asCustom(
InputMoneyPop(
context, userInfo, listener
)
)
.show()
}
}