android.support.v4.util.AtomicFile Java Examples
The following examples show how to use
android.support.v4.util.AtomicFile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TabPersistentStore.java From delion with Apache License 2.0 | 6 votes |
/** * Atomically writes the given serialized data out to disk. * @param stateDirectory Directory to save TabModel data into. * @param selectorIndex Index of the TabModelSelector to write out. * @param listData TabModel data in the form of a serialized byte array. */ public static void saveListToFile(File stateDirectory, int selectorIndex, byte[] listData) { synchronized (SAVE_LIST_LOCK) { // Save the index file containing the list of tabs to restore. File metadataFile = new File(stateDirectory, getStateFileName(selectorIndex)); 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()); } } }
Example #2
Source File: TabPersistentStore.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * 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()); } } }
Example #3
Source File: TabPersistentStore.java From 365browser with Apache License 2.0 | 6 votes |
/** * 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()); } } }
Example #4
Source File: JobStore.java From JobSchedulerCompat with Apache License 2.0 | 5 votes |
/** * Construct the instance of the job store. This results in a blocking read from disk. */ private JobStore(Context context, File dataDir) { mContext = context; mDirtyOperations = 0; File systemDir = new File(dataDir, "system"); File jobDir = new File(systemDir, "job"); jobDir.mkdirs(); mJobsFile = new AtomicFile(new File(jobDir, "jobs.xml")); mJobSet = new ArraySet<JobStatus>(); readJobMapFromDisk(mJobSet); }
Example #5
Source File: Serializer.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
/** * Конструктор * @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); }
Example #6
Source File: AtomicFileAssert.java From assertj-android with Apache License 2.0 | 4 votes |
public AtomicFileAssert(AtomicFile actual) { super(actual, AtomicFileAssert.class); }
Example #7
Source File: DefaultAutocompleteHistoryManager.java From Smarty-Streets-AutoCompleteTextView with Apache License 2.0 | 3 votes |
private DefaultAutocompleteHistoryManager(@NonNull final File historyFile, @NonNull final SmartyStreetsApiJsonParser parser) { savedFile = new AtomicFile(historyFile); jsonParser = parser; addresses = new ArrayList<>(); readPlaces(); }
Example #8
Source File: DefaultAutocompleteHistoryManager.java From android-PlacesAutocompleteTextView with BSD 2-Clause "Simplified" License | 3 votes |
private DefaultAutocompleteHistoryManager(@NonNull final File historyFile, @NonNull final PlacesApiJsonParser parser) { savedFile = new AtomicFile(historyFile); jsonParser = parser; places = new ArrayList<>(); readPlaces(); }