private GetFile(WeakReference<Context> contextWeakReference) { getFileFuture = ThreadUtils.postToBackgroundThread(() -> { Context context = contextWeakReference.get(); if (context == null) { return null; } return getFile(context); }); }
static void postDelayIfTesting(Runnable runnable, boolean shouldDelay) { if (shouldDelay) { ThreadUtils.postToMainThreadDelayed(runnable, TEST_DELAY); } else { runnable.run(); } } }
private void writeToCache(String string) { try { final Runnable runnable = new FileUtils.WriteStringToFileRunnable(new File(new FileUtils.GetCache(new WeakReference<>(context)).get(), subscriptionKey), string); ThreadUtils.postToBackgroundThread(runnable); } catch (ExecutionException | InterruptedException e) { e.printStackTrace(); Log.e(TAG, "Failed to open cache directory when writing to cache."); } }
private void writeToCache(String string) { try { final Runnable runnable = new FileUtils.WriteStringToFileRunnable(new File(new FileUtils.GetCache(new WeakReference<>(context)).get(), subscriptionKey), string); ThreadUtils.postToBackgroundThread(runnable); } catch (ExecutionException | InterruptedException e) { e.printStackTrace(); Log.e(TAG, "Failed to open cache directory when writing to cache."); } }
private void deleteCache() { try { final Runnable runnable = new FileUtils.DeleteFileRunnable(new File(new FileUtils.GetCache(new WeakReference<>(context)).get(), subscriptionKey)); ThreadUtils.postToBackgroundThread(runnable); } catch (ExecutionException | InterruptedException e) { e.printStackTrace(); Log.e(TAG, "Failed to open cache directory when deleting cache."); } }
private void deleteCache() { try { final Runnable runnable = new FileUtils.DeleteFileRunnable(new File(new FileUtils.GetCache(new WeakReference<>(context)).get(), subscriptionKey)); ThreadUtils.postToBackgroundThread(runnable); } catch (ExecutionException | InterruptedException e) { e.printStackTrace(); Log.e(TAG, "Failed to open cache directory when deleting cache."); } } }