From 03c152847b5dc56cf2ac477a5092237d6be0cb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=9C=8B=E9=A3=9E?= Date: Mon, 8 Aug 2022 10:48:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=B8=B8=E6=8F=90=E4=BA=A4:2022-08-08?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wpf/app/quickbind/QuickBind.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/QuickBind/src/main/java/com/wpf/app/quickbind/QuickBind.kt b/QuickBind/src/main/java/com/wpf/app/quickbind/QuickBind.kt index 42520619..feb71742 100644 --- a/QuickBind/src/main/java/com/wpf/app/quickbind/QuickBind.kt +++ b/QuickBind/src/main/java/com/wpf/app/quickbind/QuickBind.kt @@ -148,15 +148,7 @@ object QuickBind { ) { if (obj == null) return try { - val fields: List = ReflectHelper.getFieldWithParent(obj) - for (field in fields) { - val annotations = field.annotations.toMutableList() - annotations.sortBy { plugins.keys.indexOf(it.annotationClass) } - annotations.forEach { - plugins[it.annotationClass]?.dealField(obj, null, field) - } - annotations.clear() - } + if (viewModel != null) { val viewModelFields: List = ReflectHelper.getFieldWithParent(viewModel) for (field in viewModelFields) { @@ -167,6 +159,16 @@ object QuickBind { } annotations.clear() } + } else { + val fields: List = ReflectHelper.getFieldWithParent(obj) + for (field in fields) { + val annotations = field.annotations.toMutableList() + annotations.sortBy { plugins.keys.indexOf(it.annotationClass) } + annotations.forEach { + plugins[it.annotationClass]?.dealField(obj, null, field) + } + annotations.clear() + } } } catch (e: Exception) { e.printStackTrace()