diff --git a/Quick/src/main/java/com/wpf/app/quick/ability/QuickActivity.kt b/Quick/src/main/java/com/wpf/app/quick/ability/QuickActivity.kt index 433cb6f7..f9e333ee 100644 --- a/Quick/src/main/java/com/wpf/app/quick/ability/QuickActivity.kt +++ b/Quick/src/main/java/com/wpf/app/quick/ability/QuickActivity.kt @@ -3,6 +3,7 @@ package com.wpf.app.quick.ability import android.content.Intent import android.os.Bundle import android.view.View +import android.widget.FrameLayout import androidx.annotation.CallSuper import androidx.lifecycle.ViewModel import com.wpf.app.base.ability.base.QuickAbility @@ -20,14 +21,20 @@ open class QuickActivity( private val abilityList: MutableList = mutableListOf(), ) : QuickBaseActivity( layoutViewCreate = { - val inflateAbility = abilityList.first { ability -> ability is QuickInflateViewAbility } - .forceTo() - InitViewHelper.init( - this, - inflateAbility.layoutId(), - inflateAbility.layoutView(), - inflateAbility.layoutViewCreate() - ) + val inflateAbility = + abilityList.firstOrNull { ability -> ability is QuickInflateViewAbility } + ?.forceTo() + if (inflateAbility != null) { + InitViewHelper.init( + this, + inflateAbility.layoutId(), + inflateAbility.layoutView(), + inflateAbility.layoutViewCreate() + ) + } else { + //恢复时能力丢失返回空页面 + FrameLayout(this) + } } ), BindViewModel { @Suppress("unused") diff --git a/Quick/src/main/java/com/wpf/app/quick/ability/QuickBottomSheetDialog.kt b/Quick/src/main/java/com/wpf/app/quick/ability/QuickBottomSheetDialog.kt index 6778864f..13df0401 100644 --- a/Quick/src/main/java/com/wpf/app/quick/ability/QuickBottomSheetDialog.kt +++ b/Quick/src/main/java/com/wpf/app/quick/ability/QuickBottomSheetDialog.kt @@ -3,6 +3,7 @@ package com.wpf.app.quick.ability import android.content.Context import android.os.Bundle import android.view.View +import android.widget.FrameLayout import androidx.annotation.CallSuper import androidx.annotation.StyleRes import com.wpf.app.base.ability.base.QuickAbility @@ -19,14 +20,20 @@ open class QuickBottomSheetDialog( @StyleRes themeId: Int = 0, private val abilityList: MutableList = mutableListOf(), ) : QuickBaseBottomSheetDialog(context = context, themeId = themeId, layoutViewCreate = { - val inflateAbility = abilityList.first { ability -> ability is QuickInflateViewAbility } - .forceTo() - InitViewHelper.init( - this, - inflateAbility.layoutId(), - inflateAbility.layoutView(), - inflateAbility.layoutViewCreate() - ) + val inflateAbility = + abilityList.firstOrNull { ability -> ability is QuickInflateViewAbility } + ?.forceTo() + if (inflateAbility != null) { + InitViewHelper.init( + this, + inflateAbility.layoutId(), + inflateAbility.layoutView(), + inflateAbility.layoutViewCreate() + ) + } else { + //恢复时能力丢失返回空页面 + FrameLayout(this) + } }) { @Suppress("unused") val extraParameter: LinkedHashMap = linkedMapOf() diff --git a/Quick/src/main/java/com/wpf/app/quick/ability/QuickBottomSheetDialogFragment.kt b/Quick/src/main/java/com/wpf/app/quick/ability/QuickBottomSheetDialogFragment.kt index c3aef724..58f36a91 100644 --- a/Quick/src/main/java/com/wpf/app/quick/ability/QuickBottomSheetDialogFragment.kt +++ b/Quick/src/main/java/com/wpf/app/quick/ability/QuickBottomSheetDialogFragment.kt @@ -3,6 +3,7 @@ package com.wpf.app.quick.ability import android.content.Intent import android.os.Bundle import android.view.View +import android.widget.FrameLayout import androidx.annotation.CallSuper import androidx.lifecycle.ViewModel import com.wpf.app.base.ability.base.QuickAbility @@ -17,18 +18,24 @@ import com.wpf.app.quickutil.helper.InitViewHelper import com.wpf.app.quickutil.other.asTo import com.wpf.app.quickutil.other.forceTo -open class QuickBottomSheetDialogFragment( +open class QuickBottomSheetDialogFragment @JvmOverloads constructor( private val abilityList: MutableList = mutableListOf() ) : QuickBaseBottomSheetDialogFragment( layoutViewCreate = { - val inflateAbility = abilityList.first { ability -> ability is QuickInflateViewAbility } - .forceTo() - InitViewHelper.init( - this, - inflateAbility.layoutId(), - inflateAbility.layoutView(), - inflateAbility.layoutViewCreate() - ) + val inflateAbility = + abilityList.firstOrNull { ability -> ability is QuickInflateViewAbility } + ?.forceTo() + if (inflateAbility != null) { + InitViewHelper.init( + this, + inflateAbility.layoutId(), + inflateAbility.layoutView(), + inflateAbility.layoutViewCreate() + ) + } else { + //恢复时能力丢失返回空页面 + FrameLayout(this) + } } ), BindViewModel { @Suppress("unused") diff --git a/Quick/src/main/java/com/wpf/app/quick/ability/QuickDialog.kt b/Quick/src/main/java/com/wpf/app/quick/ability/QuickDialog.kt index f1bc74f6..59605e78 100644 --- a/Quick/src/main/java/com/wpf/app/quick/ability/QuickDialog.kt +++ b/Quick/src/main/java/com/wpf/app/quick/ability/QuickDialog.kt @@ -3,6 +3,7 @@ package com.wpf.app.quick.ability import android.content.Context import android.os.Bundle import android.view.View +import android.widget.FrameLayout import androidx.annotation.CallSuper import androidx.annotation.StyleRes import androidx.lifecycle.ViewModel @@ -22,14 +23,20 @@ open class QuickDialog( @StyleRes themeId: Int = 0, val abilityList: MutableList = mutableListOf(), ) : QuickBaseDialog(context = context, themeId = themeId, layoutViewCreate = { - val inflateAbility = abilityList.first { ability -> ability is QuickInflateViewAbility } - .forceTo() - InitViewHelper.init( - this, - inflateAbility.layoutId(), - inflateAbility.layoutView(), - inflateAbility.layoutViewCreate() - ) + val inflateAbility = + abilityList.firstOrNull { ability -> ability is QuickInflateViewAbility } + ?.forceTo() + if (inflateAbility != null) { + InitViewHelper.init( + this, + inflateAbility.layoutId(), + inflateAbility.layoutView(), + inflateAbility.layoutViewCreate() + ) + } else { + //恢复时能力丢失返回空页面 + FrameLayout(this) + } }), BindViewModel { val extraParameter: LinkedHashMap = linkedMapOf() diff --git a/Quick/src/main/java/com/wpf/app/quick/ability/QuickDialogFragment.kt b/Quick/src/main/java/com/wpf/app/quick/ability/QuickDialogFragment.kt index 8db5fe1f..2a45a006 100644 --- a/Quick/src/main/java/com/wpf/app/quick/ability/QuickDialogFragment.kt +++ b/Quick/src/main/java/com/wpf/app/quick/ability/QuickDialogFragment.kt @@ -3,6 +3,7 @@ package com.wpf.app.quick.ability import android.content.Intent import android.os.Bundle import android.view.View +import android.widget.FrameLayout import androidx.annotation.CallSuper import androidx.lifecycle.ViewModel import com.wpf.app.base.ability.base.QuickAbility @@ -17,18 +18,24 @@ import com.wpf.app.quickutil.helper.InitViewHelper import com.wpf.app.quickutil.other.asTo import com.wpf.app.quickutil.other.forceTo -open class QuickDialogFragment( +open class QuickDialogFragment @JvmOverloads constructor( private val abilityList: MutableList = mutableListOf() ) : QuickBaseDialogFragment( layoutViewCreate = { - val inflateAbility = abilityList.first { ability -> ability is QuickInflateViewAbility } - .forceTo() - InitViewHelper.init( - this, - inflateAbility.layoutId(), - inflateAbility.layoutView(), - inflateAbility.layoutViewCreate() - ) + val inflateAbility = + abilityList.firstOrNull { ability -> ability is QuickInflateViewAbility } + ?.forceTo() + if (inflateAbility != null) { + InitViewHelper.init( + this, + inflateAbility.layoutId(), + inflateAbility.layoutView(), + inflateAbility.layoutViewCreate() + ) + } else { + //恢复时能力丢失返回空页面 + FrameLayout(this) + } } ), BindViewModel { @Suppress("unused") diff --git a/Quick/src/main/java/com/wpf/app/quick/ability/QuickFragment.kt b/Quick/src/main/java/com/wpf/app/quick/ability/QuickFragment.kt index b862111d..99fb65e1 100644 --- a/Quick/src/main/java/com/wpf/app/quick/ability/QuickFragment.kt +++ b/Quick/src/main/java/com/wpf/app/quick/ability/QuickFragment.kt @@ -3,6 +3,7 @@ package com.wpf.app.quick.ability import android.content.Intent import android.os.Bundle import android.view.View +import android.widget.FrameLayout import androidx.annotation.CallSuper import androidx.lifecycle.ViewModel import com.wpf.app.base.ability.base.QuickAbility @@ -17,18 +18,24 @@ import com.wpf.app.quickutil.helper.InitViewHelper import com.wpf.app.quickutil.other.asTo import com.wpf.app.quickutil.other.forceTo -open class QuickFragment( - private val abilityList: MutableList = mutableListOf() +open class QuickFragment @JvmOverloads constructor( + private val abilityList: MutableList = mutableListOf(), ) : QuickBaseFragment( layoutViewCreate = { - val inflateAbility = abilityList.first { ability -> ability is QuickInflateViewAbility } - .forceTo() - InitViewHelper.init( - this, - inflateAbility.layoutId(), - inflateAbility.layoutView(), - inflateAbility.layoutViewCreate() - ) + val inflateAbility = + abilityList.firstOrNull { ability -> ability is QuickInflateViewAbility } + ?.forceTo() + if (inflateAbility != null) { + InitViewHelper.init( + this, + inflateAbility.layoutId(), + inflateAbility.layoutView(), + inflateAbility.layoutViewCreate() + ) + } else { + //恢复时能力丢失返回空页面 + FrameLayout(this) + } } ), BindViewModel { @Suppress("unused") @@ -106,14 +113,6 @@ open class QuickFragment( } } -// override fun onSaveInstanceState(outState: Bundle) { -// super.onSaveInstanceState(outState) -// abilityList.filterIsInstance().forEach { -// it.onSaveInstanceState(outState) -// } -// outState.putSerializable("abilityList", abilityList.toTypedArray()) -// } - @CallSuper @Suppress("DEPRECATION") @Deprecated("Deprecated by Android") diff --git a/Quick/src/main/java/com/wpf/app/quick/ability/QuickView.kt b/Quick/src/main/java/com/wpf/app/quick/ability/QuickView.kt index 05bcd534..f6116fa4 100644 --- a/Quick/src/main/java/com/wpf/app/quick/ability/QuickView.kt +++ b/Quick/src/main/java/com/wpf/app/quick/ability/QuickView.kt @@ -19,6 +19,7 @@ import com.wpf.app.quickutil.other.forceTo import com.wpf.app.quickutil.widget.wishLayoutParams import kotlinx.coroutines.Job +@Suppress("CanBeParameter") open class QuickView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, diff --git a/gradle.properties b/gradle.properties index 540c95d5..0a1a63a6 100755 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 IS_REMOTE=true GROUP=com.wpf.app.quick -VERSION_NAME=0.10.6 +VERSION_NAME=0.10.7 POM_DESCRIPTION=Quick Android.