1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

added book deleting

fixed synchronization problem in ZLTextView



git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@989 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
Nikolay Pultsin 2009-06-21 09:40:55 +00:00
parent f89c7c64a0
commit dfece0b383
19 changed files with 281 additions and 113 deletions

1
VERSION Normal file
View file

@ -0,0 +1 @@
0.5.7

View file

@ -8,7 +8,6 @@
<property name="test.dir" value="test"/>
<property name="manifest.file" value="manifest.mf"/>
<property name="main.jar" value="FBReaderJ.jar"/>
<property name="sources.zip" value="FBReaderJ-sources.zip"/>
<target name="prepare">
<mkdir dir="${bin.dir}" />
@ -61,26 +60,9 @@
<delete dir="${bin.dir}"/>
<delete dir="${cache.dir}"/>
<delete file="${main.jar}"/>
<delete file="${sources.zip}"/>
<delete file="FBReaderJ.jad"/>
<delete dir="platform/android/res/raw"/>
<delete dir="platform/android/res/drawable"/>
<delete file="platform/android/src/org/geometerplus/zlibrary/ui/android/R.java"/>
</target>
<target name="sources-archive" depends="clean">
<echo>Packaging sources archive...</echo>
<exec executable="zip" failonerror="true">
<arg value="-rq" />
<arg value="${sources.zip}" />
<arg value="${data.dir}" />
<arg value="${icons.dir}" />
<arg value="${manifest.file}" />
<arg value="build.xml" />
<arg value="src" />
<arg value="platform" />
<arg value="-x" />
<arg value="*/.svn/*" />
</exec>
</target>
</project>

16
build_sources_archive.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
version=`cat VERSION`
intversion=`echo $version | sed "s/\\./0/g" | sed -E "s/^0+//"`
dir=FBReaderJ-sources-$version
archive=FBReaderJ-sources-$version.zip
echo "<!ENTITY FBReaderVersion \"$version\">" > data/formats/fb2/FBReaderVersion.ent
sed "s/@INTVERSION@/$intversion/" platform/android/AndroidManifest.xml.pattern | sed "s/@VERSION@/$version/" > platform/android/AndroidManifest.xml
rm -rf $dir $archive
mkdir $dir
cp -r data icons src platform manifest.mf build.xml build_sources_archive.sh VERSION $dir
rm -rf `find $dir -name .svn`
zip -rq $archive $dir/*
rm -rf $dir

View file

@ -10,9 +10,11 @@
<node name="recent" value="Recent"/>
<node name="searchResults" value="Found"/>
<node name="menu">
<node name="localSearch" value="Local Search"/>
<node name="networkSearch" value="Network Search"/>
<node name="localSearch" value="Local search"/>
<node name="networkSearch" value="Network search"/>
</node>
<node name="openBook" value="Open book"/>
<node name="deleteBook" value="Delete book"/>
</node>
<node name="tocView">
<node name="expandTree" value="Expand tree"/>
@ -181,29 +183,8 @@
</node>
</node>
</node>
<node name="removeBookBox">
<node name="title" value="Remove Book"/>
<node name="message" value="Remove Book &#10;&#8220;%s&#8221;&#10; from the Library?"/>
</node>
<node name="removeTagBox">
<node name="title" value="Remove Tag"/>
<node name="message" value="Remove Tag &#8220;%s&#8221;?"/>
</node>
<node name="openBookErrorBox">
<node name="title" value="Error"/>
<node name="message" value="Couldn't open:&#10;%s"/>
</node>
<node name="noHelpBox">
<node name="title" value="Error"/>
<node name="message" value="Help file not found, sorry"/>
</node>
<node name="tagMustBeNonEmpty">
<node name="title" value="Error"/>
<node name="message" value="Tag name must be a non-empty string"/>
</node>
<node name="tagMustNotContainComma">
<node name="title" value="Error"/>
<node name="message" value="Tag name must not contain a &#8220;,&#8221; symbol"/>
<node name="deleteBookBox">
<node name="message" value="The book file will be removed irreversibly. Are you sure?"/>
</node>
<node name="waitMessage">
<node name="downloadingFile" value="Downloading book %s"/>
@ -269,10 +250,4 @@
<node name="unsupportedCompressionMethod" value="Unsupported Compression Method"/>
<node name="encriptedFile" value="DRM-protected File"/>
</node>
<node name="library">
<node name="caption" value="Library"/>
<node name="allBooks" value="All Books"/>
<node name="booksWithoutTags" value="Books with no Tags"/>
<node name="noBooks" value="FBReader found no books in the configured locations. Please specify the path to your books in the Preferences Dialog (&#8220;Library&#8221; tab, &#8220;Book Path&#8221; entry). Alternatively, you can add books to your library using &#8220;Add Book&#8221; menu item."/>
</node>
</resources>

View file

@ -13,6 +13,8 @@
<node name="localSearch" value="Поиск"/>
<node name="networkSearch" value="Поиск в сети"/>
</node>
<node name="openBook" value="Читать книгу"/>
<node name="deleteBook" value="Удалить книгу"/>
</node>
<node name="tocView">
<node name="expandTree" value="Развернуть ветвь дерева"/>
@ -179,29 +181,8 @@
</node>
</node>
</node>
<node name="removeBookBox">
<node name="title" value="Удаление книги"/>
<node name="message" value="Удалить книгу &#10;&#171;%s&#187;&#10; из библиотеки?"/>
</node>
<node name="removeTagBox">
<node name="title" value="Удаление категории"/>
<node name="message" value="Удалить категорию &#171;%s&#187;?"/>
</node>
<node name="openBookErrorBox">
<node name="title" value="Ошибка"/>
<node name="message" value="Не могу открыть:&#10;%s"/>
</node>
<node name="noHelpBox">
<node name="title" value="Ошибка"/>
<node name="message" value="Извините, нет файла с информацией"/>
</node>
<node name="tagMustBeNonEmpty">
<node name="title" value="Ошибка"/>
<node name="message" value="Название категории не может быть пустым"/>
</node>
<node name="tagMustNotContainComma">
<node name="title" value="Ошибка"/>
<node name="message" value="В названии категории не может быть запятой"/>
<node name="deleteBookBox">
<node name="message" value="Файл книги будет удален необратимо. Продолжать?"/>
</node>
<node name="waitMessage">
<node name="downloadingFile" value="Загужается книга %s"/>
@ -267,10 +248,4 @@
<node name="unsupportedCompressionMethod" value="неподдерживаемый метод сжатия"/>
<node name="encriptedFile" value="файл защищен DRM"/>
</node>
<node name="library">
<node name="caption" value="Библиотека"/>
<node name="allBooks" value="Все книги"/>
<node name="booksWithoutTags" value="Книги без категорий"/>
<node name="noBooks" value="В библиотеке нет ни одной книги. Введите, пожалуйста, список каталогов, содержащих книги в диалоге настроек (вкладка &#171;Библиотека&#187;, поле &#171;Путь к книгам&#187;), либо добавьте книги вручную с помощью кнопки &#171;Добавить книгу&#187;."/>
</node>
</resources>

View file

@ -2,11 +2,11 @@
<resources>
<node name="dialog">
<node name="button">
<node name="ok" value="&amp;Ok"/>
<node name="cancel" value="&amp;Cancel"/>
<node name="yes" value="&amp;Yes"/>
<node name="no" value="&amp;No"/>
<node name="apply" value="&amp;Apply"/>
<node name="ok" value="Ok"/>
<node name="cancel" value="Cancel"/>
<node name="yes" value="Yes"/>
<node name="no" value="No"/>
<node name="apply" value="Apply"/>
</node>
<node name="waitMessage">
<node name="savingConfig" value="Saving config..."/>

View file

@ -2,11 +2,11 @@
<resources>
<node name="dialog">
<node name="button">
<node name="ok" value="&amp;ОК"/>
<node name="cancel" value="О&amp;тменить"/>
<node name="yes" value="&amp;Да"/>
<node name="no" value="&amp;Нет"/>
<node name="apply" value="При&amp;менить"/>
<node name="ok" value="ОК"/>
<node name="cancel" value="Отменить"/>
<node name="yes" value="Да"/>
<node name="no" value="Нет"/>
<node name="apply" value="Применить"/>
</node>
<node name="waitMessage">
<node name="savingConfig" value="Сохранение настроек..."/>

View file

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.geometerplus.zlibrary.ui.android" android:versionCode="@INTVERSION@" android:versionName="@VERSION@">
<uses-sdk android:minSdkVersion="1"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application android:name="org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication" android:icon="@drawable/fbreader" android:label="FBReader">
<activity android:name="org.geometerplus.android.fbreader.FBReader" android:icon="@drawable/fbreader" android:label="FBReader" android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.TextSearchActivity" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.TextSearchActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.BookSearchActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.BookmarkSearchActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.LibraryTabActivity" android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.BookSearchActivity" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.TOCActivity" android:configChanges="orientation|keyboardHidden" />
<activity android:name="org.geometerplus.android.fbreader.BookmarksActivity" android:configChanges="orientation|keyboardHidden">
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.BookmarkSearchActivity" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.BookmarkEditActivity" android:theme="@android:style/Theme.Dialog" android:configChanges="orientation|keyboardHidden"/>
<activity android:name="org.geometerplus.android.fbreader.preferences.PreferenceActivity" android:configChanges="orientation|keyboardHidden" />
<activity android:name="org.geometerplus.android.fbreader.preferences.BookInfoActivity" android:configChanges="orientation|keyboardHidden" />
<activity android:name="org.geometerplus.android.fbreader.BookDownloader" android:theme="@android:style/Theme.Dialog" android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.epub" />
<data android:pathPattern=".*\\.oeb" />
<data android:pathPattern=".*\\.fb2" />
<data android:pathPattern=".*\\.mobi" />
<data android:pathPattern=".*\\.prc" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="*/*" android:scheme="http" android:pathPattern=".*\\.fb2\\.zip" />
</intent-filter>
</activity>
<activity android:name="org.geometerplus.zlibrary.ui.android.dialogs.DialogActivity" android:label="" android:configChanges="orientation|keyboardHidden"/>
<activity android:name="org.geometerplus.zlibrary.ui.android.dialogs.OptionsActivity" android:label="" />
</application>
</manifest>

View file

@ -62,6 +62,11 @@ public class FBReader extends ZLAndroidActivity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
/*
android.telephony.TelephonyManager tele =
(android.telephony.TelephonyManager)getSystemService(TELEPHONY_SERVICE);
System.err.println(tele.getNetworkOperator());
*/
Instance = this;
final ZLAndroidApplication application = ZLAndroidApplication.Instance();
myFullScreenFlag =

View file

@ -19,13 +19,15 @@
package org.geometerplus.android.fbreader;
import android.app.TabActivity;
import android.app.*;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
import android.content.DialogInterface;
import org.geometerplus.zlibrary.ui.android.R;
import org.geometerplus.zlibrary.core.filesystem.*;
import org.geometerplus.zlibrary.core.tree.ZLTree;
import org.geometerplus.zlibrary.core.options.ZLStringOption;
import org.geometerplus.zlibrary.core.resources.ZLResource;
@ -148,6 +150,20 @@ public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuIt
}
}
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
final int position = ((AdapterView.AdapterContextMenuInfo)menuInfo).position;
final LibraryTree tree = (LibraryTree)getItem(position);
if (tree instanceof BookTree) {
menu.setHeaderTitle(tree.getName());
final ZLResource resource = ZLResource.resource("libraryView");
menu.add(0, OPEN_BOOK_ITEM_ID, 0, resource.getResource("openBook").getValue());
if (Library.Instance().canDeleteBook(((BookTree)tree).Book)) {
menu.add(0, DELETE_BOOK_ITEM_ID, 0, resource.getResource("deleteBook").getValue());
}
}
}
private ZLTree findFirstSelectedItem() {
if (myCurrentBook == null) {
return null;
@ -192,4 +208,61 @@ public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuIt
return true;
}
}
private static final int OPEN_BOOK_ITEM_ID = 0;
private static final int DELETE_BOOK_ITEM_ID = 1;
@Override
public boolean onContextItemSelected(MenuItem item) {
final LibraryAdapter adapter =
(LibraryAdapter)((ListView)getTabHost().getCurrentView()).getAdapter();
final int position = ((AdapterView.AdapterContextMenuInfo)item.getMenuInfo()).position;
final BookTree tree = (BookTree)adapter.getItem(position);
switch (item.getItemId()) {
case OPEN_BOOK_ITEM_ID:
adapter.runTreeItem(tree);
return true;
case DELETE_BOOK_ITEM_ID:
tryToDeleteBook(tree.Book);
return true;
}
return super.onContextItemSelected(item);
}
private class BookDeleter implements DialogInterface.OnClickListener {
private final Book myBook;
BookDeleter(Book book) {
myBook = book;
}
private void invalidateView(View v) {
ZLTreeAdapter adapter = (ZLTreeAdapter)((ListView)v).getAdapter();
if (adapter != null) {
adapter.resetTree();
}
}
public void onClick(DialogInterface dialog, int which) {
Library.Instance().deleteBook(myBook);
invalidateView(findViewById(R.id.by_author));
invalidateView(findViewById(R.id.by_tag));
invalidateView(findViewById(R.id.recent));
invalidateView(findViewById(R.id.search_results));
}
}
private void tryToDeleteBook(Book book) {
final ZLResource dialogResource = ZLResource.resource("dialog");
final ZLResource buttonResource = dialogResource.getResource("button");
final ZLResource boxResource = dialogResource.getResource("deleteBookBox");
new AlertDialog.Builder(this)
.setTitle(book.getTitle())
.setMessage(boxResource.getResource("message").getValue())
.setIcon(0)
.setPositiveButton(buttonResource.getResource("yes").getValue(), new BookDeleter(book))
.setNegativeButton(buttonResource.getResource("no").getValue(), null)
.create().show();
}
}

View file

@ -162,6 +162,12 @@ abstract class ZLTreeAdapter extends BaseAdapter implements AdapterView.OnItemCl
myParent.requestLayout();
}
void resetTree() {
myItems = new ZLTree[myTree.getSize() - 1];
myParent.invalidateViews();
myParent.requestLayout();
}
public final void onItemClick(AdapterView parent, View view, int position, long id) {
runTreeItem(getItem(position));
}

View file

@ -19,11 +19,8 @@
package org.geometerplus.fbreader.fbreader;
import java.util.ArrayList;
import org.geometerplus.zlibrary.core.application.ZLApplication;
import org.geometerplus.zlibrary.core.util.ZLColor;
import org.geometerplus.zlibrary.core.view.ZLPaintContext;
import org.geometerplus.zlibrary.core.library.ZLibrary;
import org.geometerplus.zlibrary.text.model.ZLTextModel;
import org.geometerplus.zlibrary.text.view.*;

View file

@ -311,4 +311,33 @@ public final class Library {
}
db.saveRecentBookIds(ids);
}
public boolean canDeleteBook(Book book) {
ZLFile file = book.File;
if (file.getPhysicalFile() == null) {
return false;
}
while (file instanceof ZLArchiveEntryFile) {
file = file.getParent();
if (file.children().size() != 1) {
return false;
}
}
return true;
}
public void deleteBook(Book book) {
synchronize();
myBooks.remove(book);
myLibraryByAuthor.removeBook(book);
myLibraryByTag.removeBook(book);
if (myRecentBooks.removeBook(book)) {
final BooksDatabase db = BooksDatabase.Instance();
final List<Long> ids = db.listRecentBookIds();
ids.remove(book.getId());
db.saveRecentBookIds(ids);
}
mySearchResult.removeBook(book);
book.File.getPhysicalFile().delete();
}
}

View file

@ -19,8 +19,7 @@
package org.geometerplus.fbreader.library;
import java.util.Collections;
import java.util.List;
import java.util.*;
import org.geometerplus.zlibrary.core.tree.ZLTree;
@ -91,4 +90,24 @@ public abstract class LibraryTree extends ZLTree<LibraryTree> implements Compara
}
}
}
public boolean removeBook(Book book) {
final LinkedList<LibraryTree> toRemove = new LinkedList<LibraryTree>();
for (LibraryTree tree : this) {
if ((tree instanceof BookTree) && ((BookTree)tree).Book.equals(book)) {
toRemove.add(tree);
}
}
for (LibraryTree tree : toRemove) {
tree.removeSelf();
LibraryTree parent = tree.Parent;
for (; (parent != null) && !parent.hasChildren(); parent = parent.Parent) {
parent.removeSelf();
}
for (; parent != null; parent = parent.Parent) {
parent.myChildrenString = null;
}
}
return !toRemove.isEmpty();
}
}

View file

@ -51,7 +51,7 @@ public final class ZLPhysicalFile extends ZLFile {
return myFile.isDirectory();
}
public boolean remove() {
public boolean delete() {
return myFile.delete();
}

View file

@ -86,6 +86,20 @@ public abstract class ZLTree<T extends ZLTree> implements Iterable<T> {
}
}
public void removeSelf() {
final int subTreeSize = getSize();
ZLTree parent = Parent;
if (parent != null) {
parent.mySubTrees.remove(this);
if (parent.mySubTrees.isEmpty()) {
parent.mySubTrees = null;
}
for (; parent != null; parent = parent.Parent) {
parent.mySize -= subTreeSize;
}
}
}
public final void clear() {
mySubTrees = null;
mySize = 1;

View file

@ -28,13 +28,13 @@ import org.geometerplus.zlibrary.text.model.*;
public final class ZLTextParagraphCursor {
private static final class Processor {
private final ZLTextParagraph myParagraph;
private final ArrayList myElements;
private final ArrayList<ZLTextElement> myElements;
private int myOffset;
private int myFirstMark;
private int myLastMark;
private final ArrayList myMarks;
private Processor(ZLTextParagraph paragraph, ArrayList marks, int paragraphIndex, ArrayList elements) {
private Processor(ZLTextParagraph paragraph, ArrayList marks, int paragraphIndex, ArrayList<ZLTextElement> elements) {
myParagraph = paragraph;
myElements = elements;
myMarks = marks;
@ -52,7 +52,7 @@ public final class ZLTextParagraphCursor {
}
void fill() {
final ArrayList elements = myElements;
final ArrayList<ZLTextElement> elements = myElements;
for (ZLTextParagraph.EntryIterator it = myParagraph.iterator(); it.hasNext(); ) {
it.next();
switch (it.getType()) {
@ -97,7 +97,7 @@ public final class ZLTextParagraphCursor {
final int end = offset + length;
int firstNonSpace = -1;
boolean spaceInserted = false;
final ArrayList elements = myElements;
final ArrayList<ZLTextElement> elements = myElements;
for (int charPos = offset; charPos < end; ++charPos) {
final char ch = data[charPos];
if ((ch == ' ') || (ch <= 0x0D)) {
@ -136,7 +136,7 @@ public final class ZLTextParagraphCursor {
public final int Index;
public final ZLTextModel Model;
private final ArrayList myElements = new ArrayList();
private final ArrayList<ZLTextElement> myElements = new ArrayList<ZLTextElement>();
private ZLTextParagraphCursor(ZLTextModel model, int index) {
Model = model;
@ -173,7 +173,7 @@ public final class ZLTextParagraphCursor {
}
public boolean isLast() {
return (Index + 1 == Model.getParagraphsNumber());
return (Index + 1 >= Model.getParagraphsNumber());
}
public boolean isEndOfSection() {
@ -194,7 +194,7 @@ public final class ZLTextParagraphCursor {
ZLTextElement getElement(int index) {
try {
return (ZLTextElement)myElements.get(index);
return myElements.get(index);
} catch (IndexOutOfBoundsException e) {
return null;
}
@ -203,4 +203,9 @@ public final class ZLTextParagraphCursor {
ZLTextParagraph getParagraph() {
return Model.getParagraph(Index);
}
@Override
public String toString() {
return "ZLTextParagraphCursor [" + Index + " (0.." + myElements.size() + ")]";
}
}

View file

@ -61,8 +61,9 @@ public abstract class ZLTextView extends ZLTextViewBase {
mySelectionModel = new ZLTextSelectionModel(this);
}
public void setModel(ZLTextModel model) {
public synchronized void setModel(ZLTextModel model) {
ZLTextParagraphCursorCache.clear();
mySelectionModel.clear();
myModel = model;
myCurrentPage.reset();
@ -100,7 +101,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
return myCurrentPage.EndCursor;
}
private void gotoMark(ZLTextMark mark) {
private synchronized void gotoMark(ZLTextMark mark) {
if (mark == null) {
return;
}
@ -136,7 +137,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
}
}
public int search(final String text, boolean ignoreCase, boolean wholeText, boolean backward, boolean thisSectionOnly) {
public synchronized int search(final String text, boolean ignoreCase, boolean wholeText, boolean backward, boolean thisSectionOnly) {
if (text.length() == 0) {
return 0;
}
@ -166,7 +167,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
return !end.isNull() && (myModel != null) && (myModel.getNextMark(end.getMark()) != null);
}
public void findNext() {
public synchronized void findNext() {
final ZLTextWordCursor end = myCurrentPage.EndCursor;
if (!end.isNull()) {
gotoMark(myModel.getNextMark(end.getMark()));
@ -178,7 +179,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
return !start.isNull() && (myModel != null) && (myModel.getPreviousMark(start.getMark()) != null);
}
public void findPrevious() {
public synchronized void findPrevious() {
final ZLTextWordCursor start = myCurrentPage.StartCursor;
if (!start.isNull()) {
gotoMark(myModel.getPreviousMark(start.getMark()));
@ -250,7 +251,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
myNextPage.reset();
if (myCurrentPage.PaintState == PaintStateEnum.NOTHING_TO_PAINT) {
preparePaintInfo(myPreviousPage);
myCurrentPage.StartCursor.setCursor(myNextPage.EndCursor);
myCurrentPage.StartCursor.setCursor(myPreviousPage.EndCursor);
myCurrentPage.PaintState = PaintStateEnum.START_IS_KNOWN;
}
break;
@ -502,9 +503,6 @@ public abstract class ZLTextView extends ZLTextViewBase {
do {
resetTextStyle();
final ZLTextParagraphCursor paragraphCursor = result.getParagraphCursor();
if (paragraphCursor == null) {
break;
}
final int wordIndex = result.getElementIndex();
applyControls(paragraphCursor, 0, wordIndex);
ZLTextLineInfo info = new ZLTextLineInfo(paragraphCursor, wordIndex, result.getCharIndex(), getTextStyle());
@ -815,13 +813,13 @@ public abstract class ZLTextView extends ZLTextViewBase {
}
}
public final void gotoPosition(ZLTextPosition position) {
public final synchronized void gotoPosition(ZLTextPosition position) {
if (position != null) {
gotoPosition(position.getParagraphIndex(), position.getElementIndex(), position.getCharIndex());
}
}
public final void gotoPosition(int paragraphIndex, int wordIndex, int charIndex) {
public final synchronized void gotoPosition(int paragraphIndex, int wordIndex, int charIndex) {
if (myModel != null) {
myCurrentPage.moveStartCursor(paragraphIndex, wordIndex, charIndex);
myPreviousPage.reset();

View file

@ -203,4 +203,9 @@ public final class ZLTextWordCursor extends ZLTextPosition {
moveTo(myElementIndex, myCharIndex);
}
}
@Override
public String toString() {
return super.toString() + " (" + myParagraphCursor + "," + myElementIndex + "," + myCharIndex + ")";
}
}