Skip to content

Commit dd0a4a7

Browse files
committed
Merge pull request #105 from ParsePlatform/grantland.lds_file
Remove unused methods
2 parents 70f5c20 + e54e7f4 commit dd0a4a7

File tree

1 file changed

+1
-117
lines changed

1 file changed

+1
-117
lines changed

Parse/src/main/java/com/parse/ParseFile.java

Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public boolean isDirty() {
231231
* Whether the file has available data.
232232
*/
233233
public boolean isDataAvailable() {
234-
return data != null || getFileController().isDataAvailable(state) || isPinnedDataAvailable();
234+
return data != null || getFileController().isDataAvailable(state);
235235
}
236236

237237
/**
@@ -244,122 +244,6 @@ public String getUrl() {
244244
return state.url();
245245
}
246246

247-
//region LDS
248-
249-
/* package */ static File getFilesDir() {
250-
return Parse.getParseFilesDir("files");
251-
}
252-
253-
private String getFilename() {
254-
return state.name();
255-
}
256-
257-
/**
258-
* On disk cache of the {@code ParseFile}'s data
259-
*
260-
* @return File if cached, null if not.
261-
*/
262-
/* package for tests */ File getCacheFile() {
263-
return getFileController().getCacheFile(state);
264-
}
265-
266-
/* package for tests */ File getFilesFile() {
267-
String filename = getFilename();
268-
return filename != null ? new File(getFilesDir(), filename) : null;
269-
}
270-
271-
/* package */ boolean isPinned() {
272-
File file = getFilesFile();
273-
return file != null && file.exists();
274-
}
275-
276-
private boolean isPinnedDataAvailable() {
277-
return getFilesFile().exists();
278-
}
279-
280-
/* package */ void pin() throws ParseException {
281-
setPinned(true);
282-
}
283-
284-
/* package */ void unpin() throws ParseException {
285-
setPinned(false);
286-
}
287-
288-
/* package */ Task<Void> pinInBackground() {
289-
return setPinnedInBackground(true);
290-
}
291-
292-
/* package */ Task<Void> unpinInBackground() {
293-
return setPinnedInBackground(false);
294-
}
295-
296-
/* package */ void pinInBackground(ParseCallback1<ParseException> callback) {
297-
setPinnedInBackground(true, callback);
298-
}
299-
300-
/* package */ void unpinInBackground(ParseCallback1<ParseException> callback) {
301-
setPinnedInBackground(false, callback);
302-
}
303-
304-
private void setPinned(boolean pinned) throws ParseException {
305-
ParseTaskUtils.wait(setPinnedInBackground(pinned));
306-
}
307-
308-
private void setPinnedInBackground(boolean pinned, ParseCallback1<ParseException> callback) {
309-
ParseTaskUtils.callbackOnMainThreadAsync(setPinnedInBackground(pinned), callback);
310-
}
311-
312-
private Task<Void> setPinnedInBackground(final boolean pinned) {
313-
return taskQueue.enqueue(new Continuation<Void, Task<Void>>() {
314-
@Override
315-
public Task<Void> then(Task<Void> task) throws Exception {
316-
return task;
317-
}
318-
}).continueWith(new Continuation<Void, Void>() {
319-
@Override
320-
public Void then(Task<Void> task) throws Exception {
321-
if (state.url() == null) {
322-
throw new IllegalStateException("Unable to pin file before saving");
323-
}
324-
325-
if ((pinned && isPinned()) || (!pinned && !isPinned())) {
326-
// Already pinned or unpinned
327-
return null;
328-
}
329-
330-
File src, dest;
331-
if (pinned) {
332-
src = getCacheFile();
333-
dest = getFilesFile();
334-
} else {
335-
src = getFilesFile();
336-
dest = getCacheFile();
337-
}
338-
339-
if (dest.exists()) {
340-
ParseFileUtils.deleteQuietly(dest);
341-
}
342-
343-
if (pinned && data != null) {
344-
ParseFileUtils.writeByteArrayToFile(dest, data);
345-
if (src.exists()) {
346-
ParseFileUtils.deleteQuietly(src);
347-
}
348-
return null;
349-
}
350-
351-
if (src == null || !src.exists()) {
352-
throw new IllegalStateException("Unable to pin file before retrieving");
353-
}
354-
355-
ParseFileUtils.moveFile(src, dest);
356-
return null;
357-
}
358-
}, Task.BACKGROUND_EXECUTOR);
359-
}
360-
361-
//endregion
362-
363247
/**
364248
* Saves the file to the Parse cloud synchronously.
365249
*/

0 commit comments

Comments
 (0)