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


Java VolleyLog類代碼示例

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


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

示例1: writeHeader

import com.android.volley.VolleyLog; //導入依賴的package包/類
/**
 * Writes the contents of this CacheHeader to the specified OutputStream.
 */
public boolean writeHeader(OutputStream os) {
    try {
        writeInt(os, CACHE_MAGIC);
        writeString(os, key);
        writeString(os, etag == null ? "" : etag);
        writeLong(os, serverDate);
        writeLong(os, lastModified);
        writeLong(os, ttl);
        writeLong(os, softTtl);
        writeStringStringMap(responseHeaders, os);
        os.flush();
        return true;
    } catch (IOException e) {
        VolleyLog.d("%s", e.toString());
        return false;
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:DiskBasedCache.java

示例2: writeHeader

import com.android.volley.VolleyLog; //導入依賴的package包/類
/**
 * Writes the contents of this CacheHeader to the specified OutputStream.
 */
public boolean writeHeader(OutputStream os) {
  try {
    writeInt(os, CACHE_MAGIC);
    writeString(os, key);
    writeString(os, etag == null ? "" : etag);
    writeLong(os, serverDate);
    writeLong(os, ttl);
    writeLong(os, softTtl);
    writeStringStringMap(responseHeaders, os);
    os.flush();
    return true;
  } catch (IOException e) {
    VolleyLog.d("%s", e.toString());
    return false;
  }
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:20,代碼來源:DrDiskBasedCache.java

示例3: 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

示例4: writeHeader

import com.android.volley.VolleyLog; //導入依賴的package包/類
/**
 * Writes the contents of this CacheHeader to the specified OutputStream.
 */
public boolean writeHeader(OutputStream os) {
    try {
        writeInt(os, CACHE_MAGIC);
        writeString(os, key);
        writeString(os, etag == null ? "" : etag);
        writeLong(os, serverDate);
        writeLong(os, ttl);
        writeLong(os, softTtl);
        writeStringStringMap(responseHeaders, os);
        os.flush();
        return true;
    } catch (IOException e) {
        VolleyLog.d("%s", e.toString());
        return false;
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:20,代碼來源:DiskBasedCache.java

示例5: writeHeader

import com.android.volley.VolleyLog; //導入依賴的package包/類
public boolean writeHeader(OutputStream os) {
    try {
        DiskBasedCache.writeInt(os, DiskBasedCache.CACHE_MAGIC);
        DiskBasedCache.writeString(os, this.key);
        DiskBasedCache.writeString(os, this.etag == null ? "" : this.etag);
        DiskBasedCache.writeLong(os, this.serverDate);
        DiskBasedCache.writeLong(os, this.lastModified);
        DiskBasedCache.writeLong(os, this.ttl);
        DiskBasedCache.writeLong(os, this.softTtl);
        DiskBasedCache.writeStringStringMap(this.responseHeaders, os);
        os.flush();
        return true;
    } catch (IOException e) {
        VolleyLog.d("%s", e.toString());
        return false;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:DiskBasedCache.java

示例6: put

import com.android.volley.VolleyLog; //導入依賴的package包/類
public synchronized void put(String key, Entry entry) {
    pruneIfNeeded(entry.data.length);
    File file = getFileForKey(key);
    try {
        BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
        CacheHeader e = new CacheHeader(key, entry);
        if (e.writeHeader(fos)) {
            fos.write(entry.data);
            fos.close();
            putEntry(key, e);
        } else {
            fos.close();
            VolleyLog.d("Failed to write header for %s", file.getAbsolutePath());
            throw new IOException();
        }
    } catch (IOException e2) {
        if (!file.delete()) {
            VolleyLog.d("Could not clean up file %s", file.getAbsolutePath());
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:DiskBasedCache.java

示例7: getBody

import com.android.volley.VolleyLog; //導入依賴的package包/類
@Override
public byte[] getBody() {
    try {
        return mRequestBody == null ? null : mRequestBody.getBytes(PROTOCOL_CHARSET);
    } catch (UnsupportedEncodingException uee) {
        VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s",
                mRequestBody, PROTOCOL_CHARSET);
        return null;
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:JsonRequest.java

示例8: clear

import com.android.volley.VolleyLog; //導入依賴的package包/類
/**
 * Clears the cache. Deletes all cached files from disk.
 */
@Override
public synchronized void clear() {
    File[] files = mRootDirectory.listFiles();
    if (files != null) {
        for (File file : files) {
            file.delete();
        }
    }
    mEntries.clear();
    mTotalSize = 0;
    VolleyLog.d("Cache cleared.");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:DiskBasedCache.java

示例9: get

import com.android.volley.VolleyLog; //導入依賴的package包/類
/**
 * Returns the cache entry with the specified key if it exists, null otherwise.
 */
@Override
public synchronized Entry get(String key) {
    CacheHeader entry = mEntries.get(key);
    // if the entry does not exist, return.
    if (entry == null) {
        return null;
    }

    File file = getFileForKey(key);
    CountingInputStream cis = null;
    try {
        cis = new CountingInputStream(new BufferedInputStream(new FileInputStream(file)));
        CacheHeader.readHeader(cis); // eat header
        byte[] data = streamToBytes(cis, (int) (file.length() - cis.bytesRead));
        return entry.toCacheEntry(data);
    } catch (IOException e) {
        VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString());
        remove(key);
        return null;
    } finally {
        if (cis != null) {
            try {
                cis.close();
            } catch (IOException ioe) {
                return null;
            }
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:33,代碼來源:DiskBasedCache.java

示例10: remove

import com.android.volley.VolleyLog; //導入依賴的package包/類
/**
 * Removes the specified key from the cache if it exists.
 */
@Override
public synchronized void remove(String key) {
    boolean deleted = getFileForKey(key).delete();
    removeEntry(key);
    if (!deleted) {
        VolleyLog.d("Could not delete cache entry for key=%s, filename=%s",
                key, getFilenameForKey(key));
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:DiskBasedCache.java

示例11: 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

示例12: logSlowRequests

import com.android.volley.VolleyLog; //導入依賴的package包/類
/**
 * Logs requests that took over SLOW_REQUEST_THRESHOLD_MS to complete.
 */
private void logSlowRequests(long requestLifetime, Request<?> request,
        byte[] responseContents, StatusLine statusLine) {
    if (DEBUG || requestLifetime > SLOW_REQUEST_THRESHOLD_MS) {
        VolleyLog.d("HTTP response for request=<%s> [lifetime=%d], [size=%s], " +
                "[rc=%d], [retryCount=%s]", request, requestLifetime,
                responseContents != null ? responseContents.length : "null",
                statusLine.getStatusCode(), request.getRetryPolicy().getCurrentRetryCount());
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:BasicNetwork.java

示例13: 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

示例14: 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:nordfalk,項目名稱:EsperantoRadio,代碼行數:32,代碼來源:DrBasicNetwork.java

示例15: initialize

import com.android.volley.VolleyLog; //導入依賴的package包/類
/**
   * Initializes the DiskBasedCache by scanning for all files currently in the
   * specified root directory. Creates the root directory if necessary.
   */
  @Override
  public synchronized void initialize() {
    if (!mRootDirectory.exists()) {
      if (!mRootDirectory.mkdirs()) {
        VolleyLog.e("Unable to create cache dir %s", mRootDirectory.getAbsolutePath());
      }
    }
/* DR ÆNDRING - løb ikke igennem cache-mappen, det tager henved 1 sekund per 100 elementer
        File[] files = mRootDirectory.listFiles();
        if (files == null) {
            return;
        }
        for (File file : files) {
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(file);
                CacheHeader entry = CacheHeader.readHeader(fis);
                entry.size = file.length();
                putEntry(entry.key, entry);
            } catch (IOException e) {
                if (file != null) {
                   file.delete();
        }
            } finally {
                try {
                    if (fis != null) {
                        fis.close();
    }
                } catch (IOException ignored) { }
            }
        }
        */
  }
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:38,代碼來源:DrDiskBasedCache.java


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