@Override public void handle(Throwable t) { if (t != null && Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "Request threw uncaught throwable", t); } } };
private static int parseContentLength(@Nullable String contentLengthHeader) { int result = UNKNOWN; if (!TextUtils.isEmpty(contentLengthHeader)) { try { result = Integer.parseInt(contentLengthHeader); } catch (NumberFormatException e) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "failed to parse content length header: " + contentLengthHeader, e); } } } return result; }
private boolean writeDataDirect(ByteBuffer data, File file) { try { ByteBufferUtil.toFile(data, file); } catch (IOException e) { if (Log.isLoggable(TAG, Log.WARN)) { Log.w(TAG, "Failed to write GIF data", e); } return false; } return true; }
@Override public boolean onPreDraw() { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "OnGlobalLayoutListener called attachStateListener=" + this); } SizeDeterminer sizeDeterminer = sizeDeterminerRef.get(); if (sizeDeterminer != null) { sizeDeterminer.checkCurrentDimens(); } return true; } }
@Override public void clearMemory() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "clearMemory"); } trimToSize(0); }
private void dump() { if (Log.isLoggable(TAG, Log.VERBOSE)) { dumpUnchecked(); } }
@Override public void onFailure(Request request, IOException e) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "OkHttp failed to obtain result", e); } callback.onLoadFailed(e); }
@Override public void onFailure(@NonNull Call call, @NonNull IOException e) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "OkHttp failed to obtain result", e); } callback.onLoadFailed(e); }
@Override public boolean onPreDraw() { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "OnGlobalLayoutListener called attachStateListener=" + this); } SizeDeterminer sizeDeterminer = sizeDeterminerRef.get(); if (sizeDeterminer != null) { sizeDeterminer.checkCurrentDimens(); } return true; } }
private InputStream getStreamForSuccessfulRequest(HttpURLConnection urlConnection) throws IOException { if (TextUtils.isEmpty(urlConnection.getContentEncoding())) { int contentLength = urlConnection.getContentLength(); stream = ContentLengthInputStream.obtain(urlConnection.getInputStream(), contentLength); } else { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Got non empty content encoding: " + urlConnection.getContentEncoding()); } stream = urlConnection.getInputStream(); } return stream; }
@Override public void onAttach(Context context) { super.onAttach(context); try { registerFragmentWithRoot(getActivity()); } catch (IllegalStateException e) { // OnAttach can be called after the activity is destroyed, see #497. if (Log.isLoggable(TAG, Log.WARN)) { Log.w(TAG, "Unable to register fragment with root", e); } } }
@Override public void onReceive(@NonNull Context context, Intent intent) { boolean wasConnected = isConnected; isConnected = isConnected(context); if (wasConnected != isConnected) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "connectivity changed, isConnected: " + isConnected); } listener.onConnectivityChanged(isConnected); } } };
@Override public void onSearchFailed(Query query, Exception e) { if (!isCurrentQuery(query)) { return; } if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "Search failed", e); } searching.setVisibility(View.VISIBLE); searchLoading.setVisibility(View.INVISIBLE); searchTerm.setText(getString(R.string.search_failed, currentQuery.getDescription())); } }
@SuppressWarnings("deprecation") @Override public void onAttach(Activity activity) { super.onAttach(activity); try { registerFragmentWithRoot(activity); } catch (IllegalStateException e) { // OnAttach can be called after the activity is destroyed, see #497. if (Log.isLoggable(TAG, Log.WARN)) { Log.w(TAG, "Unable to register fragment with root", e); } } }
@Override public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super T> callback) { try { data = loadResource(assetManager, assetPath); } catch (IOException e) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Failed to load data from asset manager", e); } callback.onLoadFailed(e); return; } callback.onDataReady(data); }
@Override public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super Data> callback) { try { data = opener.open(file); } catch (FileNotFoundException e) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Failed to open file", e); } callback.onLoadFailed(e); return; } callback.onDataReady(data); }
@SuppressLint("InlinedApi") @Override public void trimMemory(int level) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "trimMemory, level=" + level); } if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) { clearMemory(); } else if (level >= android.content.ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN || level == android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) { trimToSize(getMaxSize() / 2); } }
@Override protected VolleyError parseNetworkError(VolleyError volleyError) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Volley failed to retrieve response", volleyError); } if (!isCanceled()) { callback.onLoadFailed(volleyError); } return super.parseNetworkError(volleyError); }
@Override public void delete(Key key) { String safeKey = safeKeyGenerator.getSafeKey(key); try { getDiskCache().remove(safeKey); } catch (IOException e) { if (Log.isLoggable(TAG, Log.WARN)) { Log.w(TAG, "Unable to delete from disk cache", e); } } }
private void evictToSize(int size) { while (currentSize > size) { Object evicted = groupedMap.removeLast(); Preconditions.checkNotNull(evicted); ArrayAdapterInterface<Object> arrayAdapter = getAdapterFromObject(evicted); currentSize -= arrayAdapter.getArrayLength(evicted) * arrayAdapter.getElementSizeInBytes(); decrementArrayOfSize(arrayAdapter.getArrayLength(evicted), evicted.getClass()); if (Log.isLoggable(arrayAdapter.getTag(), Log.VERBOSE)) { Log.v(arrayAdapter.getTag(), "evicted: " + arrayAdapter.getArrayLength(evicted)); } } }