Volley 加载图片内存溢出解决办法

咱们要保持项目中惟一一个Volley的RequestQueue,使用单例模式来实现
public class NetRequest {spa

    private static RequestQueue mQueue = null;
    private static Lock lock = new ReentrantLock();
    private static final String NETREQUEST = "netrequest";
    
    public static RequestQueue getInstance(Context context) {
        if (mQueue == null) {
            lock.lock();
            if (mQueue == null) {
                mQueue = Volley.newRequestQueue(context.getApplicationContext());
            }
            lock.unlock();
        }
        return mQueue;
    }
}get

相关文章
相关标签/搜索