當前位置: 首頁>>代碼示例>>Java>>正文


Java VolleyLog.v方法代碼示例

本文整理匯總了Java中com.android.volley.VolleyLog.v方法的典型用法代碼示例。如果您正苦於以下問題:Java VolleyLog.v方法的具體用法?Java VolleyLog.v怎麽用?Java VolleyLog.v使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.android.volley.VolleyLog的用法示例。


在下文中一共展示了VolleyLog.v方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseNetworkResponse

import com.android.volley.VolleyLog; //導入方法依賴的package包/類
@Override
protected com.android.volley.Response<String> parseNetworkResponse(NetworkResponse response) {
    this.statusCode = response.statusCode;
    this.responseHeaders = response.headers;
    /* Get the response data */
    try {
        String json = "";
        if (response.data != null) {
            json = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        }
        String log = "%1$s\nResponse code: %2$s\nResponse body: %3$s";
        VolleyLog.v(log, getUrl(), statusCode, json);
        if (statusCode >= 200 && statusCode < 300) {
            /* Return the parsed result in a response wrapper */
            return shouldCache() ?
                    success(json, parseIgnoreCacheHeaders(response)) :
                    success(json, parseCacheHeaders(response));
        } else {
            return error(new ServerError(response));
        }
    } catch (UnsupportedEncodingException e) {
        return error(new ParseError(e));
    }
}
 
開發者ID:octaware,項目名稱:super-volley,代碼行數:25,代碼來源:BaseRequest.java

示例2: pruneIfNeeded

import com.android.volley.VolleyLog; //導入方法依賴的package包/類
/**
 * Prunes the cache to fit the amount of bytes specified.
 * @param neededSpace The amount of bytes we are trying to fit into the cache.
 */
private void pruneIfNeeded(int neededSpace) {
  if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes) {
    return;
  }
  if (VolleyLog.DEBUG) {
    VolleyLog.v("Pruning old cache entries.");
  }

  long before = mTotalSize;
  int prunedFiles = 0;
  long startTime = SystemClock.elapsedRealtime();

  Iterator<Map.Entry<String, CacheHeader>> iterator = mEntries.entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry<String, CacheHeader> entry = iterator.next();
    CacheHeader e = entry.getValue();
    boolean deleted = getFileForKey(e.key).delete();
    if (deleted) {
      mTotalSize -= e.size;
    } else {
      VolleyLog.d("Could not delete cache entry for key=%s, filename=%s",
          e.key, getFilenameForKey(e.key));
    }
    iterator.remove();
    prunedFiles++;

    if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes * HYSTERESIS_FACTOR) {
      break;
    }
  }

  if (VolleyLog.DEBUG) {
    VolleyLog.v("pruned %d files, %d bytes, %d ms",
        prunedFiles, (mTotalSize - before), SystemClock.elapsedRealtime() - startTime);
  }
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:41,代碼來源:DrDiskBasedCache.java

示例3: entityToBytes

import com.android.volley.VolleyLog; //導入方法依賴的package包/類
/** Reads the contents of HttpEntity into a byte[]. */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
    PoolingByteArrayOutputStream bytes =
            new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
    byte[] buffer = null;
    try {
        InputStream in = entity.getContent();
        if (in == null) {
            throw new ServerError();
        }
        buffer = mPool.getBuf(1024);
        int count;
        while ((count = in.read(buffer)) != -1) {
            bytes.write(buffer, 0, count);
        }
        return bytes.toByteArray();
    } finally {
        try {
            // Close the InputStream and release the resources by "consuming the content".
            entity.consumeContent();
        } catch (IOException e) {
            // This can happen if there was an exception above that left the entity in
            // an invalid state.
            VolleyLog.v("Error occured when calling consumingContent");
        }
        mPool.returnBuf(buffer);
        bytes.close();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:BasicNetwork.java

示例4: pruneIfNeeded

import com.android.volley.VolleyLog; //導入方法依賴的package包/類
/**
 * Prunes the cache to fit the amount of bytes specified.
 * @param neededSpace The amount of bytes we are trying to fit into the cache.
 */
private void pruneIfNeeded(int neededSpace) {
    if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes) {
        return;
    }
    if (VolleyLog.DEBUG) {
        VolleyLog.v("Pruning old cache entries.");
    }

    long before = mTotalSize;
    int prunedFiles = 0;
    long startTime = SystemClock.elapsedRealtime();

    Iterator<Map.Entry<String, CacheHeader>> iterator = mEntries.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<String, CacheHeader> entry = iterator.next();
        CacheHeader e = entry.getValue();
        boolean deleted = getFileForKey(e.key).delete();
        if (deleted) {
            mTotalSize -= e.size;
        } else {
           VolleyLog.d("Could not delete cache entry for key=%s, filename=%s",
                   e.key, getFilenameForKey(e.key));
        }
        iterator.remove();
        prunedFiles++;

        if ((mTotalSize + neededSpace) < mMaxCacheSizeInBytes * HYSTERESIS_FACTOR) {
            break;
        }
    }

    if (VolleyLog.DEBUG) {
        VolleyLog.v("pruned %d files, %d bytes, %d ms",
                prunedFiles, (mTotalSize - before), SystemClock.elapsedRealtime() - startTime);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:41,代碼來源:DiskBasedCache.java

示例5: entityToBytes

import com.android.volley.VolleyLog; //導入方法依賴的package包/類
/**
 * Reads the contents of HttpEntity into a byte[].
 */
private byte[] entityToBytes(HttpEntity entity) throws IOException, ServerError {
    PoolingByteArrayOutputStream bytes = new PoolingByteArrayOutputStream(mPool, (int) entity.getContentLength());
    byte[] buffer = null;
    try {
        InputStream in = entity.getContent();
        if (in == null) {
            throw new ServerError();
        }
        buffer = mPool.getBuf(1024);
        int count;
        while ((count = in.read(buffer)) != -1) {
            bytes.write(buffer, 0, count);
        }
        return bytes.toByteArray();
    } finally {
        try {
            // Close the InputStream and release the resources by "consuming the content".
            entity.consumeContent();
        } catch (IOException e) {
            // This can happen if there was an exception above that left the entity in
            // an invalid state.
            VolleyLog.v("Error occured when calling consumingContent");
        }
        mPool.returnBuf(buffer);
        bytes.close();
    }
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:31,代碼來源:BaseNetwork.java

示例6: pruneIfNeeded

import com.android.volley.VolleyLog; //導入方法依賴的package包/類
private void pruneIfNeeded(int neededSpace) {
    if (this.mTotalSize + ((long) neededSpace) >= ((long) this.mMaxCacheSizeInBytes)) {
        if (VolleyLog.DEBUG) {
            VolleyLog.v("Pruning old cache entries.", new Object[0]);
        }
        long before = this.mTotalSize;
        int prunedFiles = 0;
        long startTime = SystemClock.elapsedRealtime();
        Iterator<Map.Entry<String, CacheHeader>> iterator = this.mEntries.entrySet().iterator();
        while (iterator.hasNext()) {
            CacheHeader e = (CacheHeader) ((Map.Entry) iterator.next()).getValue();
            if (getFileForKey(e.key).delete()) {
                this.mTotalSize -= e.size;
            } else {
                VolleyLog.d("Could not delete cache entry for key=%s, filename=%s", e.key, getFilenameForKey(e.key));
            }
            iterator.remove();
            prunedFiles++;
            if (((float) (this.mTotalSize + ((long) neededSpace))) < ((float) this.mMaxCacheSizeInBytes) * HYSTERESIS_FACTOR) {
                break;
            }
        }
        if (VolleyLog.DEBUG) {
            VolleyLog.v("pruned %d files, %d bytes, %d ms", Integer.valueOf(prunedFiles), Long.valueOf(this.mTotalSize - before), Long.valueOf(SystemClock.elapsedRealtime() - startTime));
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:28,代碼來源:DiskBasedCache.java

示例7: logError

import com.android.volley.VolleyLog; //導入方法依賴的package包/類
protected void logError(String what, String url, long start) {
    long now = SystemClock.elapsedRealtime();
    VolleyLog.v("HTTP ERROR(%s) %d ms to fetch %s", what, (now - start), url);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:BasicNetwork.java


注:本文中的com.android.volley.VolleyLog.v方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。