Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response search fixes #256

Merged
merged 3 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.text.style.ForegroundColorSpan
import android.text.style.UnderlineSpan

/**
* Hightlight parts of the String when it matches the search.
* Highlight parts of the String when it matches the search.
*
* @param search the text to highlight
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal class TransactionBodyAdapter(
bodyItems.filterIsInstance<TransactionPayloadItem.BodyLineItem>()
.withIndex()
.forEach { (index, item) ->
if (newText in item.line) {
if (item.line.contains(newText, ignoreCase = true)) {
item.line.clearSpans()
item.line = item.line.toString()
.highlightWithDefinedColors(newText, backgroundColor, foregroundColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ internal class TransactionPayloadFragment :

override fun onQueryTextChange(newText: String): Boolean {
val adapter = (transactionContentList.adapter as TransactionBodyAdapter)
if (newText.isNotBlank()) {
if (newText.isNotBlank() && newText.length > NUMBER_OF_IGNORED_SYMBOLS) {
adapter.highlightQueryWithColors(newText, backgroundSpanColor, foregroundSpanColor)
} else {
adapter.resetHighlight()
Expand Down Expand Up @@ -241,6 +241,7 @@ internal class TransactionPayloadFragment :
progressBar?.visibility = View.INVISIBLE
recyclerView?.visibility = View.VISIBLE
recyclerView?.adapter = TransactionBodyAdapter(result)
fragment.requireActivity().invalidateOptionsMenu()
}
}

Expand Down Expand Up @@ -298,6 +299,8 @@ internal class TransactionPayloadFragment :
private const val ARG_TYPE = "type"
private const val TRANSACTION_EXCEPTION = "Transaction not ready"

private const val NUMBER_OF_IGNORED_SYMBOLS = 1

const val TYPE_REQUEST = 0
const val TYPE_RESPONSE = 1

Expand Down