Projects >> android-arabic-reader >>40e98cd33c21c99d7c9040279ad2bff84f4a048a

Chunk
Conflicting content
			myBooks.put(book.getId(), book);
		}

<<<<<<< HEAD
		if (myDoGroupTitlesByFirstLetter) {
			final String letter = TitleTree.firstTitleLetter(book);
			if (letter != null) {
				final TitleTree tree =
					getFirstLevelTree(LibraryTree.ROOT_BY_TITLE).getTitleSubTree(letter);
				tree.createBookWithAuthorsSubTree(book);
			}
		} else {
			getFirstLevelTree(LibraryTree.ROOT_BY_TITLE).createBookWithAuthorsSubTree(book);
		}

		synchronized (this) {
			final SearchResultsTree found = (SearchResultsTree)getFirstLevelTree(LibraryTree.ROOT_FOUND);
			if (found != null && book.matches(found.getPattern())) {
				found.createBookWithAuthorsSubTree(book);
			}
=======
		final SearchResultsTree found =
			(SearchResultsTree)getFirstLevelTree(LibraryTree.ROOT_FOUND);
		if (found != null && book.matches(found.getPattern())) {
			found.createBookWithAuthorsSubTree(book);
>>>>>>> 2148db4a2dcb3cb8be13fb74f0797867b99e2620
		}
	}
Solution content
			myBooks.put(book.getId(), book);
		}

		synchronized (this) {
			final SearchResultsTree found = (SearchResultsTree)getFirstLevelTree(LibraryTree.ROOT_FOUND);
			if (found != null && book.matches(found.getPattern())) {
				found.createBookWithAuthorsSubTree(book);
			}
		}
	}
File
Library.java
Developer's decision
Combination
Kind of conflict
Cast expression
If statement
Method invocation
Synchronized statement
Variable
Chunk
Conflicting content
		fireModelChangedEvent(ChangeListener.Code.BookAdded);
	}

<<<<<<< HEAD
=======
	private void build() {
		// Step 0: get database books marked as "existing"
		final FileInfoSet fileInfos = new FileInfoSet(myDatabase);
		final Map savedBooksByFileId = myDatabase.loadBooks(fileInfos, true);
		final Map savedBooksByBookId = new HashMap();
		for (Book b : savedBooksByFileId.values()) {
			savedBooksByBookId.put(b.getId(), b);
		}

		// Step 2: check if files corresponding to "existing" books really exists;
		//         add books to library if yes (and reload book info if needed);
		//         remove from recent/favorites list if no;
		//         collect newly "orphaned" books
		final Set orphanedBooks = new HashSet();
		final Set physicalFiles = new HashSet();
		int count = 0;
		for (Book book : savedBooksByFileId.values()) {
			synchronized (this) {
				final ZLPhysicalFile file = book.File.getPhysicalFile();
				if (file != null) {
					physicalFiles.add(file);
				}
				if (file != book.File && file != null && file.getPath().endsWith(".epub")) {
					continue;
				}
				if (book.File.exists()) {
					boolean doAdd = true;
					if (file == null) {
						continue;
					}
					if (!fileInfos.check(file, true)) {
						try {
							book.readMetaInfo();
							book.save();
						} catch (BookReadingException e) {
							doAdd = false;
						}
						file.setCached(false);
					}
					if (doAdd) {
						addBookToLibrary(book);
						if (++count % 16 == 0) {
							fireModelChangedEvent(ChangeListener.Code.BookAdded);
						}
					}
				} else {
					fireModelChangedEvent(ChangeListener.Code.BookRemoved);
					orphanedBooks.add(book);
				}
			}
		}
		fireModelChangedEvent(ChangeListener.Code.BookAdded);
		myDatabase.setExistingFlag(orphanedBooks, false);

		// Step 3: collect books from physical files; add new, update already added,
		//         unmark orphaned as existing again, collect newly added
		final Map orphanedBooksByFileId = myDatabase.loadBooks(fileInfos, false);
		final Set newBooks = new HashSet();

		final List physicalFilesList = collectPhysicalFiles();
		for (ZLPhysicalFile file : physicalFilesList) {
			if (physicalFiles.contains(file)) {
				continue;
			}
			collectBooks(
				file, fileInfos,
				savedBooksByFileId, orphanedBooksByFileId,
				newBooks,
				!fileInfos.check(file, true)
			);
			file.setCached(false);
		}

		// Step 4: add help file
		try {
			final ZLFile helpFile = getHelpFile();
			Book helpBook = savedBooksByFileId.get(fileInfos.getId(helpFile));
			if (helpBook == null) {
				helpBook = new Book(helpFile);
			}
			addBookToLibrary(helpBook);
			fireModelChangedEvent(ChangeListener.Code.BookAdded);
		} catch (BookReadingException e) {
			// that's impossible
			e.printStackTrace();
		}

		// Step 5: save changes into database
		fileInfos.save();

		myDatabase.executeAsATransaction(new Runnable() {
			public void run() {
				for (Book book : newBooks) {
					book.save();
				}
			}
		});
		myDatabase.setExistingFlag(newBooks, true);
	}

	private volatile boolean myBuildStarted = false;

	public synchronized void startBuild() {
		if (myBuildStarted) {
			fireModelChangedEvent(ChangeListener.Code.StatusChanged);
			return;
		}
		myBuildStarted = true;

		setStatus(myStatusMask | STATUS_LOADING);
		final Thread builder = new Thread("Library.build") {
			public void run() {
				try {
					build();
				} finally {
					setStatus(myStatusMask & ~STATUS_LOADING);
				}
			}
		};
		builder.setPriority((Thread.MIN_PRIORITY + Thread.NORM_PRIORITY) / 2);
		builder.start();
	}

>>>>>>> 2148db4a2dcb3cb8be13fb74f0797867b99e2620
	public boolean isUpToDate() {
		return myStatusMask == 0;
	}
Solution content
		fireModelChangedEvent(ChangeListener.Code.BookAdded);
	}

	public boolean isUpToDate() {
		return myStatusMask == 0;
	}
File
Library.java
Developer's decision
Version 1
Kind of conflict
Attribute
Method declaration