From a13ad566412794e8f4fa809bc2baba2546ff2f2f Mon Sep 17 00:00:00 2001 From: Igor Date: Thu, 11 Jul 2024 17:34:32 +0300 Subject: [PATCH] fix npe --- README.md | 16 ++++++++-------- .../detail/networklog/NetworkLogActivity.kt | 2 +- .../networklog/NetworkLogPayloadFragment.kt | 7 ++++--- .../finch_fragment_network_log_overview.xml | 4 ++-- .../finch_fragment_network_log_payload.xml | 4 ++-- dependencies.gradle | 2 +- .../networklog/grpc/FinchClientInterceptor.kt | 2 +- sample/build.gradle | 13 ++++++------- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index bc04fda..6387354 100644 --- a/README.md +++ b/README.md @@ -27,17 +27,17 @@ Pick a UI implementation and add the dependency: ````java dependencies { - debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.9' - releaseImplementation 'com.github.kernel0x.finch:noop:2.2.9' + debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.10' + releaseImplementation 'com.github.kernel0x.finch:noop:2.2.10' // optional only for OkHttp - debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.9' - releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.9' + debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.10' + releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.10' // optional only for GRPC - debugImplementation 'com.github.kernel0x.finch:log-grpc:2.2.9' - releaseImplementation 'com.github.kernel0x.finch:log-grpc-noop:2.2.9' + debugImplementation 'com.github.kernel0x.finch:log-grpc:2.2.10' + releaseImplementation 'com.github.kernel0x.finch:log-grpc-noop:2.2.10' // optional only for logs - debugImplementation 'com.github.kernel0x.finch:log:2.2.9' - releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.9' + debugImplementation 'com.github.kernel0x.finch:log:2.2.10' + releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.10' } ```` diff --git a/core/src/main/java/com/kernel/finch/core/presentation/detail/networklog/NetworkLogActivity.kt b/core/src/main/java/com/kernel/finch/core/presentation/detail/networklog/NetworkLogActivity.kt index ea45500..82c7fbd 100644 --- a/core/src/main/java/com/kernel/finch/core/presentation/detail/networklog/NetworkLogActivity.kt +++ b/core/src/main/java/com/kernel/finch/core/presentation/detail/networklog/NetworkLogActivity.kt @@ -110,7 +110,7 @@ internal class NetworkLogActivity : BaseFinchActivity() { @SuppressLint("SetTextI18n") private fun update() { networkLog?.apply { - findViewById(R.id.finch_text_view).text = "$method $path" + findViewById(R.id.finch_text_view)?.text = "$method $path" for (fragment in adapter.fragments) { fragment.networkLogUpdated(this) } diff --git a/core/src/main/java/com/kernel/finch/core/presentation/detail/networklog/NetworkLogPayloadFragment.kt b/core/src/main/java/com/kernel/finch/core/presentation/detail/networklog/NetworkLogPayloadFragment.kt index 38cafe3..245fed0 100644 --- a/core/src/main/java/com/kernel/finch/core/presentation/detail/networklog/NetworkLogPayloadFragment.kt +++ b/core/src/main/java/com/kernel/finch/core/presentation/detail/networklog/NetworkLogPayloadFragment.kt @@ -7,9 +7,9 @@ import android.view.LayoutInflater import android.view.Menu import android.view.View import android.view.ViewGroup +import android.widget.ScrollView import android.widget.TextView import androidx.appcompat.widget.SearchView -import androidx.core.widget.NestedScrollView import androidx.fragment.app.Fragment import com.kernel.finch.common.loggers.data.models.MediaType import com.kernel.finch.common.loggers.data.models.NetworkLogEntity @@ -55,6 +55,7 @@ internal class NetworkLogPayloadFragment : Fragment(), NetworkLogFragment, getFormattedRequestBody(), requestBodyIsPlainText ) + TYPE_RESPONSE -> setText( getResponseHeadersString(true), getFormattedResponseBody(), @@ -100,7 +101,7 @@ internal class NetworkLogPayloadFragment : Fragment(), NetworkLogFragment, override fun onQueryTextChange(newText: String): Boolean { view?.run { - findViewById(R.id.finch_body).run { + findViewById(R.id.finch_body)?.run { var fullText = text.toString() if (newText.isEmpty() || !fullText.contains(newText) || TextUtils.isEmpty(newText)) { update() @@ -110,7 +111,7 @@ internal class NetworkLogPayloadFragment : Fragment(), NetworkLogFragment, val highlighted = "$newText" fullText = fullText.replace(newText, highlighted) text = Html.fromHtml(fullText) - findViewById(R.id.finch_scroll_view).scrollTo( + findViewById(R.id.finch_scroll_view)?.scrollTo( 0, layout.getLineTop(lineNumber) ) diff --git a/core/src/main/res/layout/finch_fragment_network_log_overview.xml b/core/src/main/res/layout/finch_fragment_network_log_overview.xml index 5aded1a..d80c6c8 100644 --- a/core/src/main/res/layout/finch_fragment_network_log_overview.xml +++ b/core/src/main/res/layout/finch_fragment_network_log_overview.xml @@ -1,5 +1,5 @@ - - + diff --git a/core/src/main/res/layout/finch_fragment_network_log_payload.xml b/core/src/main/res/layout/finch_fragment_network_log_payload.xml index 45708c8..04472b5 100644 --- a/core/src/main/res/layout/finch_fragment_network_log_payload.xml +++ b/core/src/main/res/layout/finch_fragment_network_log_payload.xml @@ -1,5 +1,5 @@ - - + diff --git a/dependencies.gradle b/dependencies.gradle index 4d79632..7441b39 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ ext.versions = [ minSdk : 21, targetSdk : 34, compileSdk : 34, - libraryVersion : '2.2.9', + libraryVersion : '2.2.10', libraryVersionCode: 15, okhttp3 : '3.7.0', diff --git a/log-grpc/src/main/java/com/kernel/finch/networklog/grpc/FinchClientInterceptor.kt b/log-grpc/src/main/java/com/kernel/finch/networklog/grpc/FinchClientInterceptor.kt index 6b04d56..0300953 100644 --- a/log-grpc/src/main/java/com/kernel/finch/networklog/grpc/FinchClientInterceptor.kt +++ b/log-grpc/src/main/java/com/kernel/finch/networklog/grpc/FinchClientInterceptor.kt @@ -52,7 +52,7 @@ internal class FinchClientInterceptor : ClientInterceptor { responseListener ) { override fun onMessage(message: RespT) { - networkLog.responseBody = + networkLog.responseBody += TextFormat.printer().escapingNonAscii(false).printToString( message as MessageOrBuilder ) diff --git a/sample/build.gradle b/sample/build.gradle index a252827..6a94742 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -29,16 +29,15 @@ android { } dependencies { - //debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.9' - //releaseImplementation 'com.github.kernel0x.finch:noop:2.2.9' - //debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.9' - //releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.9' - //debugImplementation 'com.github.kernel0x.finch:log:2.2.9' - //releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.9' + //debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.10' + //releaseImplementation 'com.github.kernel0x.finch:noop:2.2.10' + //debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.10' + //releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.10' + //debugImplementation 'com.github.kernel0x.finch:log:2.2.10' + //releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.10' debugImplementation project(":ui-drawer") debugImplementation project(":log") debugImplementation project(":log-okhttp") - implementation "androidx.appcompat:appcompat:$versions.appCompat" implementation "com.google.android.material:material:1.0.0" implementation "com.squareup.retrofit2:retrofit:2.9.0" implementation "com.squareup.retrofit2:converter-gson:2.2.0"