Skip to content

Commit

Permalink
添加xpopup弹窗优先级事例
Browse files Browse the repository at this point in the history
  • Loading branch information
puyang1017 committed Apr 22, 2021
1 parent 2416cfd commit 2e9bbbd
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "com.android.puy.mvpkotlin"
minSdkVersion 19
Expand Down Expand Up @@ -49,4 +49,5 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation rootProject.ext.dependencies["multidex"]
api project(':puymvpjava')
// implementation 'com.lxj:xpopup:2.2.12'
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:requestLegacyExternalStorage = "true"
android:theme="@style/AppTheme">
<activity android:name=".TestActivity"></activity>
<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//package com.android.puy.mvpkotlin
//
//import android.app.Activity
//import com.lxj.xpopup.core.CenterPopupView
//
///**
// * Created by puy on 2021/4/22 15:56
// */
//class CenterPopupForIpSetting(val context: Activity) : CenterPopupView(context) {
//
// override fun getImplLayoutId(): Int = R.layout.dialog_ip_setting_loading
//}
10 changes: 7 additions & 3 deletions app/src/main/java/com/android/puy/mvpkotlin/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import android.os.Build.VERSION_CODES
import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.view.View
import androidx.annotation.RequiresApi
import androidx.fragment.app.Fragment
import com.android.puy.puymvpjava.dialogmanager.DialogManager
import com.android.puy.puymvpjava.dialogmanager.DialogParam
import com.android.puy.puymvpjava.dialogmanager.OnDismissListener
import com.android.puy.puymvpjava.event.BusProvider
import com.android.puy.puymvpjava.mvp.XFragmentationActivity
import kotlinx.android.synthetic.main.activity_main.*
Expand Down Expand Up @@ -59,7 +57,7 @@ class MainActivity : XFragmentationActivity<Pmain>(), IVmain {
val alertDialog2: DialogSample
val alertDialog3: DialogSample
val alertDialog4: DialogSample
val prioritys = intArrayOf(3, 1, 2, 4)
val prioritys = intArrayOf(3, 1, 2, 4,5)
alertDialog4 = DialogSample(context)
alertDialog4.setTitle("温馨提示")
alertDialog4.setMessage("第四个弹窗,优先级:" + prioritys[3])
Expand Down Expand Up @@ -96,11 +94,17 @@ class MainActivity : XFragmentationActivity<Pmain>(), IVmain {
DialogManager.getInstance().add(DialogParam.Builder().dialog(alertDialog2).priority(prioritys[1]).build())
DialogManager.getInstance().add(DialogParam.Builder().dialog(alertDialog3).priority(prioritys[2]).build())
DialogManager.getInstance().show()

// val alertDialog5 = XpopupPriorityDialog(XPopup.Builder(context).dismissOnTouchOutside(true).dismissOnBackPressed(false))
// alertDialog5.asCustom(CenterPopupForIpSetting(context))
Handler().postDelayed({
val dialogParam = DialogParam.Builder().dialog(alertDialog4).priority(prioritys[3]).build()
// val dialogParamXPopup = DialogParam.Builder().dialog(alertDialog5).priority(prioritys[4]).build()
DialogManager.getInstance().add(dialogParam)
// DialogManager.getInstance().add(dialogParamXPopup)
// DialogManager.getInstance().show()
DialogManager.getInstance().show(dialogParam)
// DialogManager.getInstance().show(dialogParamXPopup)
},3000)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//package com.android.puy.mvpkotlin
//
//import com.android.puy.puymvpjava.dialogmanager.OnDismissListener
//import com.android.puy.puymvpjava.dialogmanager.OnShowListener
//import com.android.puy.puymvpjava.dialogmanager.PriorityDialog
//import com.lxj.xpopup.XPopup
//import com.lxj.xpopup.core.BasePopupView
//import com.lxj.xpopup.interfaces.XPopupCallback
//
///**
// * Created by puy on 2021/4/22 15:40
// */
//class XpopupPriorityDialog(val xPopup: XPopup.Builder) : PriorityDialog {
// var mBasepopupView: BasePopupView? = null
// var mDismissListener: OnDismissListener? = null
// var mShowListener: OnShowListener? = null
//
// init {
// xPopup.setPopupCallback(object :XPopupCallback{
// override fun onBackPressed(popupView: BasePopupView?): Boolean {
// return false
// }
//
// override fun onDrag(popupView: BasePopupView?, value: Int, percent: Float, upOrLeft: Boolean) {
// }
//
// override fun onDismiss(popupView: BasePopupView?) {
// mDismissListener?.onDismiss(isCrowdOut)
// }
//
// override fun onKeyBoardStateChanged(popupView: BasePopupView?, height: Int) {
// }
//
// override fun beforeShow(popupView: BasePopupView?) {
// }
//
// override fun onCreated(popupView: BasePopupView?) {
// }
//
// override fun beforeDismiss(popupView: BasePopupView?) {
// }
//
// override fun onShow(popupView: BasePopupView?) {
// mShowListener?.onShow()
// }
// })
// }
//
// fun asCustom(popupView: BasePopupView): BasePopupView?{
// mBasepopupView = xPopup.asCustom(popupView)
// return mBasepopupView
// }
//
// /**
// * 是否被挤出(每个实现DialogManager.Dialog的窗口类都需要新建该变量)
// */
// private var isCrowdOut = false
// override fun dismiss(boolean: Boolean) {
// isCrowdOut = boolean
// }
//
// override fun show() {
// mBasepopupView?.show()
// }
//
// override fun setOnDismissListener(listener: OnDismissListener?) {
// mDismissListener = listener
// }
//
// override fun setOnShowListener(listener: OnShowListener?) {
// mShowListener = listener
// }
//
// override fun isCanShow(): Boolean {
// return true
// }
//}

0 comments on commit 2e9bbbd

Please sign in to comment.