-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
Improve search results #1327
Improve search results #1327
Conversation
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.
- The tabs are blue with white font for me, should be Backgroundcolor + textcolor, blue only for selected tab
- I like the setup with the
SearchFragment
that handles common functionality - it should probably not be the
SearchFragment
that inherits fromSFragment
, but only theSearchStatusFragment
? - The error handling needs some improvement. The snackbar only retries one of the requests, but i feel like it should retry all 3. Maybe the sad elephant fullscreen is be a better way to show the error?
|
||
import android.view.View | ||
|
||
interface AnchorActivity { |
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.
Without comments its absolutely unclear what this interface is doing. I think you can remove it, Snackbar should also work with another view.
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.
It worked not correct because activity has a scrollable toolbar and fragments have CoordinatorLayout as root. When app searches the layout for snackbar it founds the fragment's CoordinatorLayout. But root CoordinatorLayout hides the bottom of the fragment (with Snackbar) when toolbar shown. I've removed child CoordinatorLayout, so, Snackbar always uses the Activity's CoordinatorLayout
data class HashTag( | ||
|
||
@field:SerializedName("name") | ||
val name: String, |
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.
@SerializedName
is not necessary when the property has the same name
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.
We must not forget to add this file to proguard rules in this case. I prefer to set the SerializedName and do not worry about proguard.
} | ||
|
||
override fun onReblog(reblog: Boolean, position: Int) { | ||
//TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
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.
Don't forget to implement these methods
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.
Implemented. I decided to do a trick.
ViewModel stores loaded statuses at the separate list.
When user update the status - app updates the status at this list and invalidate DataSource. DataSource uses this precached list as initial load data. When user changes the search phrase, app clear this list and app uses the network request to load data.
Not sure that this is the best solution, but it allow to use standard paging libraries.
app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/keylesspalace/tusky/components/search/SearchViewModel.kt
Outdated
Show resolved
Hide resolved
79eced7
to
77d610a
Compare
|
About error handling. |
|
||
public override fun getItem(position: Int): Account? { | ||
return super.getItem(position) | ||
} |
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.
this override is unnecessary, it just calls super
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.
This is really well done, nice work.
- Can you give the tabs the same color as the search bar please (in all themes)? I do not care if you make the tabs the color of the bar or the other way.
- there is still a problem with error handling, retrying does not work for me sometimes. Seems like all snackbars just reload the first tab or something like that. I can send you a video if you want.
- (optional) pull to refresh would actually be really nice inside the tabs
|
||
public override fun getItem(position: Int): HashTag? { | ||
return super.getItem(position) | ||
} |
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.
unnecessary override
|
||
public override fun getItem(position: Int): Pair<Status, StatusViewData.Concrete>? { | ||
return super.getItem(position) | ||
} |
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.
unnecessary overrride
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.
This one is required in order to change visibility of the method from protected
to public
, used at:
import com.google.gson.annotations.SerializedName | ||
|
||
data class HashTag( | ||
@field:SerializedName("name") |
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.
SerializedName
does nothing if the property has the same name anyway.
|
||
} | ||
|
||
protected fun showNoData(isEmpty: Boolean) { |
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.
can be private
if (it == NetworkState.LOADING) { | ||
searchProgressBar.show() | ||
} else | ||
searchProgressBar.hide() |
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.
there is a extension function visible
so you can do these checks shorter
searchProgressBar.visible(it == NetworkState.LOADING)
app/src/main/java/com/keylesspalace/tusky/components/search/fragments/SearchStatusesFragment.kt
Outdated
Show resolved
Hide resolved
|
||
val loggedInAccountId = viewModel.activeAccount?.accountId | ||
|
||
val popup = PopupMenu(context!!, view) |
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.
view.context
is always non-null
if (activity == null) { | ||
return | ||
} | ||
AlertDialog.Builder(activity!!) |
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.
activity?.let{
makes this shorter and you don't have to use !!
7f51a3c
to
8c5b21a
Compare
@connyduck could you provide the video showing the weird retry behaviour that you mention above please? I've not been able to replicate it. |
Do you have a new GitHub account? |
Here is a video https://connyduck.at/device-2019-07-07-143455.mp4 |
@connyduck Nope, different person. I'm leading on Roma for Android now, so aiming to tidy up and close out any remnant PRs from the fork before starting any new ones, and thanks for the vid! |
…agments/SearchStatusesFragment.kt Co-Authored-By: Konrad Pozniak <connyduck@users.noreply.github.com>
e9972dd
to
635e9a4
Compare
One thing to note is that searching hashtags results in infinite paging, full of the same result, which looks like a bug. However that's actually what the V2 API returns from server-side when the I think that satisfies all of the prior comments, but would welcome further review and feedback. Update: Oh and it's no longer WIP, but I don't own the PR so can't rename it. I didn't want to create a new one and lose the review conversation. |
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.
Looks good now, thx. Awesome work.
Just one more thing from a UX perspective: What if there are no results on the first tab? Should we somehow indicate that there is more on other tabs? Maybe don't display tabs that have no results? Or reorder them?
I think I would go with merging this and asking users what they think?
Good point, hadn't thought of that! A few approaches come to mind:
User feedback would definitely be a good guide for that; could even make it switchable behaviour. |
I merge this now so more people can try it out, lets see.
Would be nice, but I think we don't get this info from the api? Thx again |
Oh no, found another bug: The account list does not stop loading and shows the same account over and over again: |
Looking at that, it seems that it's instance-specific so perhaps a server-side issue, as it doesn't occur on the (admittedly Pleroma) instances I've tried with the head of Could you raise an issue against me for that, with details of which instance version you're using please? |
Ok, i tried debugging this and it looks like it is a bug in Mastodon and only happens when searching for ones own account 🤣 I will open a ticket on their repo |
Issue #1081