Java 类android.support.v4.util.AtomicFile 实例源码

项目:chromium-for-android-56-debug-video    文件:TabPersistentStore.java   
/**
 * 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());
        }
    }
}
项目:AndroidChromium    文件:TabPersistentStore.java   
/**
 * 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());
        }
    }
}
项目:365browser    文件:TabPersistentStore.java   
/**
 * 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());
        }
    }
}
项目:truth-android    文件:AtomicFileSubject.java   
public static SubjectFactory<AtomicFileSubject, AtomicFile> type() {
  return new SubjectFactory<AtomicFileSubject, AtomicFile>() {
    @Override
    public AtomicFileSubject getSubject(FailureStrategy fs, AtomicFile that) {
      return new AtomicFileSubject(fs, that);
    }
  };
}
项目:truth-android    文件:AtomicFileSubject.java   
protected AtomicFileSubject(FailureStrategy failureStrategy, AtomicFile subject) {
  super(failureStrategy, subject);
}
项目:Overchan-Android    文件:Serializer.java   
/**
 * Конструктор
 * @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);
}
项目:assertj-android    文件:AtomicFileAssert.java   
public AtomicFileAssert(AtomicFile actual) {
  super(actual, AtomicFileAssert.class);
}
项目:Smarty-Streets-AutoCompleteTextView    文件:DefaultAutocompleteHistoryManager.java   
private DefaultAutocompleteHistoryManager(@NonNull final File historyFile, @NonNull final SmartyStreetsApiJsonParser parser) {
    savedFile = new AtomicFile(historyFile);

    jsonParser = parser;

    addresses = new ArrayList<>();

    readPlaces();
}
项目:android-PlacesAutocompleteTextView    文件:DefaultAutocompleteHistoryManager.java   
private DefaultAutocompleteHistoryManager(@NonNull final File historyFile, @NonNull final PlacesApiJsonParser parser) {
    savedFile = new AtomicFile(historyFile);

    jsonParser = parser;

    places = new ArrayList<>();

    readPlaces();
}