From 4b628993ab2dff80c6e0fdb5d33a40c3779091b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A8=81=E5=A8=81=E5=90=9B=E2=80=9D?= <“1214585092@qq.com”> Date: Thu, 4 Jun 2020 19:14:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=96=E7=A0=81=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=96=B9=E6=B3=95addEncode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ldw/test/ui/default/DefaultFragment.kt | 5 ++++- .../com/ldw/test/ui/default/DefaultViewModel.kt | 15 +++++++++++++++ .../com/ldw/bhttp_compiler/KotlinProcessor.kt | 6 +++--- .../src/main/java/com/ldw/bhttp/BaseBHttp.java | 1 - 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/ldw/test/ui/default/DefaultViewModel.kt diff --git a/app/src/main/java/com/ldw/test/ui/default/DefaultFragment.kt b/app/src/main/java/com/ldw/test/ui/default/DefaultFragment.kt index 77527ec..dccf34a 100644 --- a/app/src/main/java/com/ldw/test/ui/default/DefaultFragment.kt +++ b/app/src/main/java/com/ldw/test/ui/default/DefaultFragment.kt @@ -5,6 +5,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import androidx.lifecycle.ViewModelProvider import com.bhttp.wrapper.generator.BHttp import com.ldw.bhttp.callback.Observer import com.ldw.test.ApiService @@ -16,7 +17,7 @@ import okhttp3.Response class DefaultFragment : Fragment() { - + private lateinit var defaultViewModel: DefaultViewModel override fun onCreateView( inflater: LayoutInflater, @@ -30,6 +31,8 @@ class DefaultFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) // BHttp.setDefaultDomain("http://192.168.1.2:8022/") + defaultViewModel = ViewModelProvider(this).get(DefaultViewModel::class.java) + // defaultViewModel.mediatorLiveData.addSource() BHttp.setDebug(true) get.setOnClickListener { get() diff --git a/app/src/main/java/com/ldw/test/ui/default/DefaultViewModel.kt b/app/src/main/java/com/ldw/test/ui/default/DefaultViewModel.kt new file mode 100644 index 0000000..3b62b84 --- /dev/null +++ b/app/src/main/java/com/ldw/test/ui/default/DefaultViewModel.kt @@ -0,0 +1,15 @@ +package com.ldw.test.ui.default + +import androidx.lifecycle.MediatorLiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel + +/** + * @date 2020/6/3 23:43 + * @user 威威君 + */ +class DefaultViewModel : ViewModel() { + var mutableLiveData = MutableLiveData() + var mediatorLiveData = MediatorLiveData() + +} \ No newline at end of file diff --git a/bhttp-compiler/src/main/java/com/ldw/bhttp_compiler/KotlinProcessor.kt b/bhttp-compiler/src/main/java/com/ldw/bhttp_compiler/KotlinProcessor.kt index 477192f..efbe4d4 100644 --- a/bhttp-compiler/src/main/java/com/ldw/bhttp_compiler/KotlinProcessor.kt +++ b/bhttp-compiler/src/main/java/com/ldw/bhttp_compiler/KotlinProcessor.kt @@ -157,7 +157,6 @@ class KotlinProcessor : AbstractProcessor() { } var ss = """ - package com.ldw.bhttp; import android.app.Activity; @@ -448,7 +447,6 @@ public class BaseBHttp { Type returnType = method.getGenericReturnType(); BaseBHttp result = serviceMethodCache.get(method); if (result != null) { - LogUtils.logd("缓存读取"); result.reLoadParam(method, args); return result; } @@ -708,7 +706,9 @@ public class BaseBHttp { }); } - + + + """.trimIndent() } diff --git a/bhttp-core/src/main/java/com/ldw/bhttp/BaseBHttp.java b/bhttp-core/src/main/java/com/ldw/bhttp/BaseBHttp.java index 35ef717..3a26568 100644 --- a/bhttp-core/src/main/java/com/ldw/bhttp/BaseBHttp.java +++ b/bhttp-core/src/main/java/com/ldw/bhttp/BaseBHttp.java @@ -288,7 +288,6 @@ public static T create(final Class service) { Type returnType = method.getGenericReturnType(); BaseBHttp result = serviceMethodCache.get(method); if (result != null) { - LogUtils.logd("缓存读取"); result.reLoadParam(method, args); return result; }