Skip to content

Commit

Permalink
日常修改:2024-10-17.
Browse files Browse the repository at this point in the history
  • Loading branch information
walgr committed Oct 17, 2024
1 parent 52185eb commit 65a4093
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package com.wpf.app.quicknetwork.helper

object NetworkResponseInterceptor {

/**
* 默认执行
*/
internal val beforeListDefault = mutableListOf<() -> Unit>()
internal val successBeforeListDefault = mutableListOf<(data: Any) -> Unit>()
internal val successListDefault = mutableListOf<(data: Any) -> Unit>()
Expand Down Expand Up @@ -93,6 +96,9 @@ object NetworkResponseInterceptor {
finallyListDefault.add(onAfter)
}

/**
* 强制执行
*/
internal val beforeListForce = mutableListOf<() -> Unit>()
internal val successBeforeListForce = mutableListOf<(data: Any) -> Unit>()
internal val successListForce = mutableListOf<(data: Any) -> Unit>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object RetrofitCreateHelper {

private val retrofitMap: MutableMap<String, Retrofit> = mutableMapOf()
private val retrofitServiceMap: MutableMap<Class<*>, Retrofit> = mutableMapOf()
val serviceMap: MutableMap<Class<*>, Any> = mutableMapOf()
val serviceMap: MutableMap<Class<*>, Any> = mutableMapOf() //保存Retrofit create后的Service

/**
* 存储已经初始化过的Retrofit
Expand All @@ -26,7 +26,7 @@ object RetrofitCreateHelper {
fun registerServices(baseUrl: String, serviceCls: Class<*>) {
if (retrofitServiceMap[serviceCls] != retrofitMap[baseUrl]!!) {
retrofitServiceMap[serviceCls] = retrofitMap[baseUrl]!!
createService(serviceCls)
serviceMap[serviceCls] = createService(serviceCls)
}
}

Expand All @@ -45,7 +45,7 @@ object RetrofitCreateHelper {

fun newInstance(
baseUrl: String,
serviceCls: Class<*>,
serviceCls: Class<*>? = null,
callFactoryList: List<CallAdapter.Factory>? = null,
converterFactoryList: List<Converter.Factory>? = null,
okHttp: OkHttpClient = OkHttpCreateHelper.newInstance(),
Expand All @@ -66,7 +66,9 @@ object RetrofitCreateHelper {
init?.invoke(retrofitBuilder)
retrofit = retrofitBuilder.build()
retrofitMap[baseUrl] = retrofit
retrofitServiceMap[serviceCls] = retrofit
serviceCls?.let {
retrofitServiceMap[serviceCls] = retrofit
}
}
return retrofit!!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import android.widget.RelativeLayout
import androidx.constraintlayout.widget.ConstraintLayout
import com.google.android.material.tabs.TabLayout
import com.wpf.app.quickutil.helper.children
import com.wpf.app.quickutil.helper.matchMarginLayoutParams
import com.wpf.app.quickutil.helper.generic.GenericEx
import com.wpf.app.quickutil.helper.matchMarginLayoutParams
import java.lang.reflect.Constructor

enum class GroupType(val type: Int) {
Expand Down Expand Up @@ -76,10 +76,11 @@ internal interface QuickViewGroupI<T : ViewGroup> {
shadowView: View?,
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
defStyleAttr: Int = 0,
genericCls: Class<T>? = null,
): T? {
if (shadowView != null) return shadowView as T
val tCls: Class<T>? = GenericEx.get0Clazz(this)
val tCls: Class<T>? = genericCls ?: GenericEx.get0Clazz(this)
if ("ViewGroup" == tCls?.simpleName) return shadowView
tCls?.let {
val t = tCls.constructors.findLast {
Expand All @@ -104,7 +105,7 @@ internal interface QuickViewGroupI<T : ViewGroup> {
return null
}

fun addChildToT(shadowView: ViewGroup?, curView: ViewGroup) {
fun addChildToGroup(shadowView: ViewGroup?, curView: ViewGroup) {
curView.children().forEach {
shadowView?.addView(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.google.android.material.tabs.TabLayout
import com.wpf.app.quickutil.helper.attribute.AutoGetAttributeHelper
import com.wpf.app.quickutil.helper.generic.asTo
import com.wpf.app.quickutil.helper.generic.nullDefault
import com.wpf.app.quickutil.helper.parent
import com.wpf.app.quickwidget.R

/**
Expand All @@ -28,10 +29,13 @@ open class QuickViewGroupNoAttrs<T : ViewGroup> @JvmOverloads constructor(
private val attrs: AttributeSet? = null,
private val defStyleAttr: Int = 0,
private var addToParent: Boolean = true,
private val forceGenerics: Boolean = false //强制泛型初始化
private val forceGenerics: Boolean = false, //强制泛型初始化
private val forceGenericsCls: Class<T>? = null, //强制Cls初始化
private var addChildToParent: Boolean = false, //是否把子View添加到父View
) : ViewGroup(context, attrs, defStyleAttr), QuickViewGroupI<T> {

private val attrSet: QuickViewGroupAttrSet = AutoGetAttributeHelper.init(context, attrs, R.styleable.QuickViewGroup)
private val attrSet: QuickViewGroupAttrSet =
AutoGetAttributeHelper.init(context, attrs, R.styleable.QuickViewGroup)

init {
init()
Expand All @@ -48,15 +52,20 @@ open class QuickViewGroupNoAttrs<T : ViewGroup> @JvmOverloads constructor(
if (isInEditMode) {
addToParent = false
}
shadowView = if (forceGenerics || attrSet.groupType == -1) {
initViewGroupByT(shadowView, context, attrs, defStyleAttr)
if (!addChildToParent) {
shadowView = if (attrSet.groupType != -1) {
initViewGroupByXml(shadowView, attrSet.groupType, context, attrs, defStyleAttr)
} else if (forceGenerics || forceGenericsCls != null) {
initViewGroupByT(shadowView, context, attrs, defStyleAttr, forceGenericsCls)
} else {
initViewGroupByT(shadowView, context, attrs, defStyleAttr)
}
addChildToGroup(shadowView, this)
if (!addToParent) {
addT(false, shadowView, this)
}
} else {
initViewGroupByXml(shadowView, attrSet.groupType, context, attrs, defStyleAttr)
?: initViewGroupByT(shadowView, context, attrs, defStyleAttr)
}
addChildToT(shadowView, this)
if (!addToParent) {
addT(false, shadowView, this)
addChildToGroup(parent(), this)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ abstract class Only1Child<T : View> @JvmOverloads constructor(
mContext: Context,
attributeSet: AttributeSet? = null,
defStyleAttr: Int = 0,
) : QuickViewGroupNoAttrs<RelativeLayout>(mContext, attributeSet, defStyleAttr, true) {
) : QuickViewGroupNoAttrs<RelativeLayout>(
mContext,
attributeSet,
defStyleAttr,
false,
forceGenericsCls = RelativeLayout::class.java,
) {

@CallSuper
override fun onFinishInflate() {
Expand Down
12 changes: 1 addition & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,14 @@ android {
debug {
debuggable true
minifyEnabled false
kotlin {
sourceSets {
main.kotlin.srcDirs += 'build/generated/ksp/debug/kotlin'
}
}

}
release {
minifyEnabled true
// 移除无用的resource文件
shrinkResources true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

kotlin {
sourceSets {
main.kotlin.srcDirs += 'build/generated/ksp/release/kotlin'
}
}
}
}
compileOptions {
Expand Down
29 changes: 16 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />

<!-- 安装Apk-->

<application
android:name="com.wpf.app.quick.demo.App"
Expand All @@ -12,27 +14,28 @@
android:theme="@style/Theme.Quick">

<!--App页面-->
<activity android:name=".CodeMainActivity"
<activity
android:name=".CodeMainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".RecyclerViewTestActivity" />
<activity android:name=".IntentDataTestActivity" />
<activity android:name=".SelectListTestActivity" />
<activity android:name=".ViewPagerNotifySizeTestActivity"/>
<activity android:name=".ViewPagerNotifyDataTestActivity"/>
<activity android:name=".RequestTestActivity"/>
<activity android:name=".DialogTestActivity"/>
<activity android:name=".ShadowViewTestActivity"/>
<activity android:name=".FragmentTestActivity"/>
<activity android:name=".BottomSheetDialogTestActivity"/>
<activity android:name=".WheelViewTestActivity"/>
<activity android:name=".wanandroid.WanAndroidHomeActivity"/>
<activity android:name=".wanandroid.WebViewActivity"/>
<activity android:name=".ViewPagerNotifySizeTestActivity" />
<activity android:name=".ViewPagerNotifyDataTestActivity" />
<activity android:name=".RequestTestActivity" />
<activity android:name=".DialogTestActivity" />
<activity android:name=".ShadowViewTestActivity" />
<activity android:name=".FragmentTestActivity" />
<activity android:name=".BottomSheetDialogTestActivity" />
<activity android:name=".WheelViewTestActivity" />
<activity android:name=".wanandroid.WanAndroidHomeActivity" />
<activity android:name=".wanandroid.WebViewActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import android.annotation.SuppressLint
import android.view.View
import android.widget.TextView
import com.wpf.app.quick.ability.QuickFragment
import com.wpf.app.quickutil.ability.ex.contentView
import com.wpf.app.quick.ability.ex.modelBinding
import com.wpf.app.quickutil.ability.base.with
import com.wpf.app.quick.annotations.bind.BindView
import com.wpf.app.quick.demo.R
import com.wpf.app.quick.demo.databinding.FragmentMainReleaseBinding
import com.wpf.app.quickbind.annotations.BindSp2View
import com.wpf.app.quickutil.ability.base.with
import com.wpf.app.quickutil.ability.ex.contentView
import com.wpf.app.quickutil.helper.postDelay

class MainReleaseFragment : QuickFragment(
contentView(R.layout.fragment_main_release).with(modelBinding<MainReleaseVM, FragmentMainReleaseBinding>())
) {

@SuppressLint("NonConstantResourceId")
@BindSp2View(bindSp = "绑定的SpKey1", defaultValue = "默认值1")
// @BindSp2View(bindSp = "绑定的SpKey1", defaultValue = "默认值1")
@BindView(R.id.spTextView1)
var text1: TextView? = null

Expand Down
16 changes: 12 additions & 4 deletions app/src/main/res/layout/fragment_main_release.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,20 @@
android:gravity="center_vertical"
android:orientation="horizontal">

<TextView
android:id="@+id/spTextView1"
<com.wpf.app.quickwidget.quickview.inxml.LoadSp2Text
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:text="测试绑定1" />
app:bindData2Sp="true"
app:bindKey="spTextView1">

<TextView
android:id="@+id/spTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
android:text="测试绑定1" />

</com.wpf.app.quickwidget.quickview.inxml.LoadSp2Text>

<TextView
android:id="@+id/spTextView2"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/device_admin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<policy android:name="android.permission.REQUEST_DEVICE_ADMIN"/>
</uses-policies>
</device-admin>

0 comments on commit 65a4093

Please sign in to comment.