设置请求优先级排球 [英] Setting Request Priority Volley

查看:219
本文介绍了设置请求优先级排球的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置使用Android的凌空库我的请求的优先级。我不能找出如何设置请求的优先级。

I am trying to set the priority of my requests using the Volley library in Android. I cant find out how to set the requests priority.

StringRequest request = new StringRequest(Request.Method.GET,"feed URL",volleyListener, volleyErrorListener);
pe.requestQueue.add(request);

这是我会怎么做任何想法?

Any Ideas on how I would do this?

推荐答案

图书馆遗憾的是没有完全充实呢。要为请求设置优先级,你需要扩展的要求并覆盖getPriority()。对于你的例子我想创建扩展StringRequest并实现getPriority(一类新)(也许一个setPriority()为好,这样你就可以以编程方式更改在不同请求的优先级)。

The library unfortunately isn't fully fleshed out yet. To set priority for a request you need to extend the request and override getPriority(). For your example I would create a new class that extends StringRequest and implements getPriority() (and maybe a setPriority() as well, so you can programmatically change priorities in different requests).

private Priority mPriority = Priority.LOW;

@Override
public Priority getPriority() {
    return mPriority;
}

public void setPriority(Priority priority) {
    mPriority = priority;
}

优先级请求一个ENUM 类。

这篇关于设置请求优先级排球的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆