From e54e7f4376f46ceae4b08277c76e488682013062 Mon Sep 17 00:00:00 2001 From: Grantland Chew Date: Fri, 4 Sep 2015 13:14:36 -0700 Subject: [PATCH] Remove unused methods --- Parse/src/main/java/com/parse/ParseFile.java | 118 +------------------ 1 file changed, 1 insertion(+), 117 deletions(-) diff --git a/Parse/src/main/java/com/parse/ParseFile.java b/Parse/src/main/java/com/parse/ParseFile.java index ad47196fc..919cda549 100644 --- a/Parse/src/main/java/com/parse/ParseFile.java +++ b/Parse/src/main/java/com/parse/ParseFile.java @@ -231,7 +231,7 @@ public boolean isDirty() { * Whether the file has available data. */ public boolean isDataAvailable() { - return data != null || getFileController().isDataAvailable(state) || isPinnedDataAvailable(); + return data != null || getFileController().isDataAvailable(state); } /** @@ -244,122 +244,6 @@ public String getUrl() { return state.url(); } - //region LDS - - /* package */ static File getFilesDir() { - return Parse.getParseFilesDir("files"); - } - - private String getFilename() { - return state.name(); - } - - /** - * On disk cache of the {@code ParseFile}'s data - * - * @return File if cached, null if not. - */ - /* package for tests */ File getCacheFile() { - return getFileController().getCacheFile(state); - } - - /* package for tests */ File getFilesFile() { - String filename = getFilename(); - return filename != null ? new File(getFilesDir(), filename) : null; - } - - /* package */ boolean isPinned() { - File file = getFilesFile(); - return file != null && file.exists(); - } - - private boolean isPinnedDataAvailable() { - return getFilesFile().exists(); - } - - /* package */ void pin() throws ParseException { - setPinned(true); - } - - /* package */ void unpin() throws ParseException { - setPinned(false); - } - - /* package */ Task pinInBackground() { - return setPinnedInBackground(true); - } - - /* package */ Task unpinInBackground() { - return setPinnedInBackground(false); - } - - /* package */ void pinInBackground(ParseCallback1 callback) { - setPinnedInBackground(true, callback); - } - - /* package */ void unpinInBackground(ParseCallback1 callback) { - setPinnedInBackground(false, callback); - } - - private void setPinned(boolean pinned) throws ParseException { - ParseTaskUtils.wait(setPinnedInBackground(pinned)); - } - - private void setPinnedInBackground(boolean pinned, ParseCallback1 callback) { - ParseTaskUtils.callbackOnMainThreadAsync(setPinnedInBackground(pinned), callback); - } - - private Task setPinnedInBackground(final boolean pinned) { - return taskQueue.enqueue(new Continuation>() { - @Override - public Task then(Task task) throws Exception { - return task; - } - }).continueWith(new Continuation() { - @Override - public Void then(Task task) throws Exception { - if (state.url() == null) { - throw new IllegalStateException("Unable to pin file before saving"); - } - - if ((pinned && isPinned()) || (!pinned && !isPinned())) { - // Already pinned or unpinned - return null; - } - - File src, dest; - if (pinned) { - src = getCacheFile(); - dest = getFilesFile(); - } else { - src = getFilesFile(); - dest = getCacheFile(); - } - - if (dest.exists()) { - ParseFileUtils.deleteQuietly(dest); - } - - if (pinned && data != null) { - ParseFileUtils.writeByteArrayToFile(dest, data); - if (src.exists()) { - ParseFileUtils.deleteQuietly(src); - } - return null; - } - - if (src == null || !src.exists()) { - throw new IllegalStateException("Unable to pin file before retrieving"); - } - - ParseFileUtils.moveFile(src, dest); - return null; - } - }, Task.BACKGROUND_EXECUTOR); - } - - //endregion - /** * Saves the file to the Parse cloud synchronously. */