/**
   * Method that removes all the textures from the queue
   *
   * @param reload Forces a reload of the queue
   */
  public void emptyTextureQueue(boolean reload) {
    synchronized (mSync) {
      // Recycle the textures
      try {
        List<GLESTextureInfo> all = mQueue.removeAll();
        for (GLESTextureInfo info : all) {
          if (GLES20.glIsTexture(info.handle)) {
            int[] textures = new int[] {info.handle};
            if (GLESUtil.DEBUG_GL_MEMOBJS) {
              Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteTextures: [" + info.handle + "]");
            }
            GLES20.glDeleteTextures(1, textures, 0);
            GLESUtil.glesCheckError("glDeleteTextures");
          }
          // Return the bitmap
          info.bitmap.recycle();
          info.bitmap = null;
        }
      } catch (EmptyQueueException eqex) {
        // Ignore
      }

      // Remove all pictures in the queue
      try {
        mQueue.removeAll();
      } catch (EmptyQueueException ex) {
        // Ignore
      }

      // Reload the queue
      if (reload) {
        synchronized (mBackgroundTask.mLoadSync) {
          mBackgroundTask.resetAvailableImages();
          mBackgroundTask.mLoadSync.notify();
        }
      }
    }
  }