Best Practices for Handling Search

前端 未结 3 792
旧时难觅i
旧时难觅i 2021-02-13 07:10

I\'ve got a SearchView setup, and I have a loosely decoupled architecture using Retrofit and Otto.

I am wondering what the

3条回答
  •  醉梦人生
    2021-02-13 07:29

    So to answer this question in a sufficient way, as I was not satisfied with the other answers here there are a few more steps to consider in this problem.

    First we would need to ask a few questions in regards to how we would tackle this issue:

    • Is there autocomplete?
    • What is the scope of the search?
    • Would there be caching?

    And many more questions.

    I would probably first build a custom adapter to handle the querying in the search, then implement aggressive caching on the user's queries. This is important in the sense that a user's queries are very important. It would probably make sense to only used cached results for Autocomplete it is very expensive to implement autocomplete and have it ping the server at every text change.

    Caching can be accomplished by using the SQLite helpers in Android. This can be expensive, but we are dealing with simple query objects, (as this should be the case from the API the objects should be memory or byte size expensive).

提交回复
热议问题