/** * Atomically writes the given serialized data out to disk. * @param stateDirectory Directory to save TabModel data into. * @param stateFileName File name to save TabModel data into. * @param listData TabModel data in the form of a serialized byte array. */ public static void saveListToFile(File stateDirectory, String stateFileName, byte[] listData) { synchronized (SAVE_LIST_LOCK) { // Save the index file containing the list of tabs to restore. File metadataFile = new File(stateDirectory, stateFileName); AtomicFile file = new AtomicFile(metadataFile); FileOutputStream stream = null; try { stream = file.startWrite(); stream.write(listData, 0, listData.length); file.finishWrite(stream); } catch (IOException e) { if (stream != null) file.failWrite(stream); Log.e(TAG, "Failed to write file: " + metadataFile.getAbsolutePath()); } } }
public static SubjectFactory<AtomicFileSubject, AtomicFile> type() { return new SubjectFactory<AtomicFileSubject, AtomicFile>() { @Override public AtomicFileSubject getSubject(FailureStrategy fs, AtomicFile that) { return new AtomicFileSubject(fs, that); } }; }
protected AtomicFileSubject(FailureStrategy failureStrategy, AtomicFile subject) { super(failureStrategy, subject); }
/** * Конструктор * @param fileCache объект файлового кэша */ public Serializer(FileCache fileCache) { this.fileCache = fileCache; this.tabsStateFile = new AtomicFile(new File(fileCache.getFilesDirectory(), FileCache.TABS_FILENAME)); this.kryo = new Kryo(); this.kryo.setReferences(false); this.kryo.setDefaultSerializer(TaggedFieldSerializer.class); this.kryo.register(TabsState.class, 0); this.kryo.register(TabModel.class, 1); this.kryo.register(TabsIdStack.class, 2); this.kryo.register(SerializablePage.class, 3); this.kryo.register(SerializableBoardsList.class, 4); this.kryo.register(AttachmentModel.class, 5); this.kryo.register(BadgeIconModel.class, 6); this.kryo.register(BoardModel.class, 7); this.kryo.register(DeletePostModel.class, 8); this.kryo.register(PostModel.class, 9); this.kryo.register(SendPostModel.class, 10); this.kryo.register(SimpleBoardModel.class, 11); this.kryo.register(ThreadModel.class, 12); this.kryo.register(UrlPageModel.class, 13); this.kryo.register(AttachmentModel[].class, 14); this.kryo.register(BadgeIconModel[].class, 15); this.kryo.register(BoardModel[].class, 16); this.kryo.register(DeletePostModel[].class, 17); this.kryo.register(PostModel[].class, 18); this.kryo.register(SendPostModel[].class, 19); this.kryo.register(SimpleBoardModel[].class, 20); this.kryo.register(ThreadModel[].class, 21); this.kryo.register(UrlPageModel[].class, 22); this.kryo.register(java.util.ArrayList.class, 23); this.kryo.register(java.util.LinkedList.class, 24); this.kryo.register(java.io.File.class, new FileSerializer(), 25); this.kryo.register(java.io.File[].class, 26); }
public AtomicFileAssert(AtomicFile actual) { super(actual, AtomicFileAssert.class); }
private DefaultAutocompleteHistoryManager(@NonNull final File historyFile, @NonNull final SmartyStreetsApiJsonParser parser) { savedFile = new AtomicFile(historyFile); jsonParser = parser; addresses = new ArrayList<>(); readPlaces(); }
private DefaultAutocompleteHistoryManager(@NonNull final File historyFile, @NonNull final PlacesApiJsonParser parser) { savedFile = new AtomicFile(historyFile); jsonParser = parser; places = new ArrayList<>(); readPlaces(); }