Android Volley library: do we always have to repeat Response.Listener and Response.ErrorListener

后端 未结 2 917
小鲜肉
小鲜肉 2020-12-16 04:48

I have recently started using Android Volley in my project. The common practice mentioned in most of the tutorials is to use it this way:

JsonObjectRequest          


        
2条回答
  •  时光取名叫无心
    2020-12-16 05:28

    Create a class (like "ApiManager") that you pass the url and parameters, that creates the Volley request and keeps track of the replies and listeners. The ApiManager would typically get a callback from the calling class for the results. This way, you have to type the Volley code only once, while the logic for each call would be concise. Or, that's how I do it.

提交回复
热议问题