-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
Migrate search to SDK to fix cancellation issues #2727
Migrate search to SDK to fix cancellation issues #2727
Conversation
5cda6e9
to
df00ce1
Compare
I think I would like to change this by doing a small refactor:
Then we can move the search networking out of the ItemRowAdapter entirely. I noticed we're already doing this in a few places. There's an One annoying thing about this however is if we try to pass in a list of |
b9235a0
to
2eec7c6
Compare
app/src/main/java/org/jellyfin/androidtv/ui/search/TextSearchFragment.kt
Fixed
Show fixed
Hide fixed
app/src/main/java/org/jellyfin/androidtv/ui/search/TextSearchFragment.kt
Fixed
Show fixed
Hide fixed
app/src/main/java/org/jellyfin/androidtv/ui/itemhandling/ItemRowAdapter.java
Fixed
Show fixed
Hide fixed
app/src/main/java/org/jellyfin/androidtv/ui/itemhandling/ItemRowAdapter.java
Fixed
Show fixed
Hide fixed
app/src/main/java/org/jellyfin/androidtv/ui/itemhandling/ItemRowAdapter.java
Fixed
Show fixed
Hide fixed
app/src/main/java/org/jellyfin/androidtv/ui/itemhandling/ItemRowAdapter.java
Fixed
Show fixed
Hide fixed
bc12135
to
4b9dd31
Compare
app/src/main/java/org/jellyfin/androidtv/ui/itemhandling/ItemRowAdapter.java
Fixed
Show fixed
Hide fixed
app/src/main/java/org/jellyfin/androidtv/ui/itemhandling/ItemRowAdapter.java
Fixed
Show fixed
Hide fixed
app/src/main/java/org/jellyfin/androidtv/ui/itemhandling/ItemRowAdapter.java
Fixed
Show fixed
Hide fixed
3135fe8
to
b33cd13
Compare
If we're migrating the search code to the SDK we should use the items API with the |
a5181fa
to
5a64896
Compare
Updated this to use the new search api |
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
38c9426
to
9f67e3c
Compare
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchFragmentDelegate.kt
Fixed
Show fixed
Hide fixed
app/src/main/java/org/jellyfin/androidtv/ui/itemhandling/ItemRowAdapter.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchRepository.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/LeanbackSearchFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/LeanbackSearchFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/TextSearchFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/TextSearchFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchFragmentDelegate.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchFragmentDelegate.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchFragmentDelegate.kt
Outdated
Show resolved
Hide resolved
9f67e3c
to
54f6f53
Compare
54f6f53
to
d8aa16a
Compare
Addressed comments |
d8aa16a
to
e4c7262
Compare
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchRepository.kt
Outdated
Show resolved
Hide resolved
e4c7262
to
11f32cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some files are indented with spaces instead of tabs, and a lot of places use (like constructors) use 2x the amount of indent compared to existing code.
app/src/main/java/org/jellyfin/androidtv/ui/search/LeanbackSearchFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/LeanbackSearchFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/TextSearchFragment.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/jellyfin/androidtv/ui/search/SearchRepository.kt
Outdated
Show resolved
Hide resolved
Sorry about the whitespace changes, I tend to use the AS formatter quite frequently so that's why it moved things around |
Hmm that's weird, the default Android Studio config + our editorconfig should configure the formatter properly. I use it all the time. Maybe it broke in a newer version? I'll look into it. |
I tried out the Canary build of AS and I think that messed up the autoformatter. I'll fix it in the PR |
17b5721
to
8a56e2b
Compare
8a56e2b
to
d73857b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some additional changes;
- Updates formatting
- Moved
searchJob?.cancel()
to before the query.isBlank check to prevent a race condition where items wouldn't be cleared when emptying the input.
Thanks a lot for the pull request!
Changes
* Extends ItemItemRowAdapter and provides a suspending function for the search logic* Suspending function is canceled when a new search happensSee comment below
The issue was caused by the old API client using Volley for HTTP requests, which launches a thread. It does not use a coroutine / suspending function, so even though the coroutine is being canceled with new search input, the api call is not.
Issues
#2726