google / volley

https://google.github.io/volley
Apache License 2.0
3.37k stars 751 forks source link

setPriority() for Request #438

Open BenjyTec opened 2 years ago

BenjyTec commented 2 years ago

After reading the documentation and looking into the Request.java file, it seems like there is currently no option to easily set the Priority for a Request, neither via Setter or Constructor. Is there any particular reason for this? I already found posts on Stackoverflow on how to get the desired functionality, but as basic as this is, I'm still curious to find out why the 'obvious' way hasn't been implemented, as I guess there is a good reason for it.

Thanks for any clarification.

jpd236 commented 2 years ago

It's a fair enough point, given that there are other setters for mutable properties. But the semantics could be a bit strange to introduce now, in that you could end up in a world where you call setPriority, but it does nothing because the Request subclass being used has its own implementation of getPriority which behaves differently. We could fix this in the built-in requests like ImageRequest, but there's always a chance of other Request classes existing outside the library that should be fixed as well.

It's also likely we'd break compilation for many libraries which provide custom setPriority methods that would now be overriding the base method, without specifying @Override.

So I'm overall open to this... but given these risks, and that you can fairly easily subclass Request, and almost certainly will/should be doing so anyway to implement your own requests, I don't think it's much of a priority.