mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
Code cleanup
This commit is contained in:
parent
3f07c2924a
commit
f29380ac4b
14 changed files with 42 additions and 63 deletions
|
@ -21,10 +21,14 @@ package org.geometerplus.android.fbreader;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.geometerplus.android.fbreader.library.FileManager;
|
||||
import org.geometerplus.fbreader.fbreader.ActionCode;
|
||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
import org.geometerplus.fbreader.library.Library;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.*;
|
||||
|
||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
@ -36,17 +40,8 @@ import org.geometerplus.zlibrary.ui.android.R;
|
|||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidActivity;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import org.geometerplus.fbreader.fbreader.ActionCode;
|
||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
|
||||
|
||||
public final class FBReader extends ZLAndroidActivity {
|
||||
|
@ -89,13 +84,13 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
private static TextSearchButtonPanel myTextSearchPanel;
|
||||
private static NavigationButtonPanel myNavigatePanel;
|
||||
|
||||
private String fileNameFromUri(Uri uri) {
|
||||
/*private String fileNameFromUri(Uri uri) {
|
||||
if (uri.equals(Uri.parse("file:///"))) {
|
||||
return Library.getHelpFile().getPath();
|
||||
} else {
|
||||
return uri.getPath();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected ZLFile fileFromIntent(Intent intent) {
|
||||
|
|
|
@ -33,9 +33,9 @@ public class FManagerAdapter extends ArrayAdapter<FileOrder>{
|
|||
final View view = (convertView != null) ? convertView :
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.library_tree_item, parent, false);
|
||||
|
||||
FileOrder order = myOrders.get(position);
|
||||
if (order != null) {
|
||||
((TextView)view.findViewById(R.id.library_tree_item_name)).setText(order.getName());
|
||||
FileOrder order = myOrders.get(position);
|
||||
if (order != null) {
|
||||
((TextView)view.findViewById(R.id.library_tree_item_name)).setText(order.getName());
|
||||
((TextView)view.findViewById(R.id.library_tree_item_childrenlist)).setText(order.getPath());
|
||||
|
||||
if (myCoverWidth == -1) {
|
||||
|
@ -51,9 +51,9 @@ public class FManagerAdapter extends ArrayAdapter<FileOrder>{
|
|||
coverView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
coverView.requestLayout();
|
||||
|
||||
coverView.setImageResource(order.getIcon());
|
||||
}
|
||||
return view;
|
||||
coverView.setImageResource(order.getIcon());
|
||||
}
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@ class FileOrder{
|
|||
myName = book.getTitle();
|
||||
FormatPlugin plugin = PluginCollection.Instance().getPlugin(file);
|
||||
ZLImage image = plugin.readCover(book);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class InitializationService extends Service {
|
|||
public void onStart(Intent intent, int startId) {
|
||||
final Thread libraryInitializer = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
LibraryTopLevelActivity.Library.synchronize();
|
||||
LibraryTopLevelActivity.LibraryInstance.synchronize();
|
||||
}
|
||||
});
|
||||
libraryInitializer.setPriority(Thread.MIN_PRIORITY);
|
||||
|
|
|
@ -25,8 +25,6 @@ import android.app.*;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.os.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
|
||||
|
@ -59,7 +57,7 @@ abstract class LibraryBaseActivity extends ListActivity {
|
|||
static final String PATH_BY_AUTHOR = "byAuthor";
|
||||
static final String PATH_BY_TAG = "byTag";
|
||||
|
||||
static Library Library;
|
||||
static Library LibraryInstance;
|
||||
|
||||
static final ZLStringOption BookSearchPatternOption =
|
||||
new ZLStringOption("BookSearch", "Pattern", "");
|
||||
|
@ -88,7 +86,7 @@ abstract class LibraryBaseActivity extends ListActivity {
|
|||
return false;
|
||||
}
|
||||
BookSearchPatternOption.setValue(pattern);
|
||||
return Library.searchBooks(pattern).hasChildren();
|
||||
return LibraryInstance.searchBooks(pattern).hasChildren();
|
||||
}
|
||||
|
||||
protected void showNotFoundToast() {
|
||||
|
@ -124,12 +122,12 @@ abstract class LibraryBaseActivity extends ListActivity {
|
|||
if (tree instanceof BookTree) {
|
||||
menu.setHeaderTitle(tree.getName());
|
||||
menu.add(0, OPEN_BOOK_ITEM_ID, 0, myResource.getResource("openBook").getValue());
|
||||
if (Library.isBookInFavorites(((BookTree)tree).Book)) {
|
||||
if (LibraryInstance.isBookInFavorites(((BookTree)tree).Book)) {
|
||||
menu.add(0, REMOVE_FROM_FAVORITES_ITEM_ID, 0, myResource.getResource("removeFromFavorites").getValue());
|
||||
} else {
|
||||
menu.add(0, ADD_TO_FAVORITES_ITEM_ID, 0, myResource.getResource("addToFavorites").getValue());
|
||||
}
|
||||
if ((Library.getRemoveBookMode(((BookTree)tree).Book) & Library.REMOVE_FROM_DISK) != 0) {
|
||||
if ((LibraryInstance.getRemoveBookMode(((BookTree)tree).Book) & Library.REMOVE_FROM_DISK) != 0) {
|
||||
menu.add(0, DELETE_BOOK_ITEM_ID, 0, myResource.getResource("deleteBook").getValue());
|
||||
}
|
||||
}
|
||||
|
@ -229,10 +227,10 @@ abstract class LibraryBaseActivity extends ListActivity {
|
|||
openBook(bookTree.Book);
|
||||
return true;
|
||||
case ADD_TO_FAVORITES_ITEM_ID:
|
||||
Library.addBookToFavorites(bookTree.Book);
|
||||
LibraryInstance.addBookToFavorites(bookTree.Book);
|
||||
return true;
|
||||
case REMOVE_FROM_FAVORITES_ITEM_ID:
|
||||
Library.removeBookFromFavorites(bookTree.Book);
|
||||
LibraryInstance.removeBookFromFavorites(bookTree.Book);
|
||||
getListView().invalidateViews();
|
||||
return true;
|
||||
case DELETE_BOOK_ITEM_ID:
|
||||
|
@ -269,13 +267,13 @@ abstract class LibraryBaseActivity extends ListActivity {
|
|||
);
|
||||
}
|
||||
};
|
||||
if (Library.hasState(Library.STATE_FULLY_INITIALIZED)) {
|
||||
if (LibraryInstance.hasState(Library.STATE_FULLY_INITIALIZED)) {
|
||||
postRunnable.run();
|
||||
} else {
|
||||
UIUtil.runWithMessage(LibraryBaseActivity.this, "loadingBookList",
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
Library.waitForState(Library.STATE_FULLY_INITIALIZED);
|
||||
LibraryInstance.waitForState(Library.STATE_FULLY_INITIALIZED);
|
||||
}
|
||||
},
|
||||
postRunnable);
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.geometerplus.android.fbreader.library;
|
|||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
@ -29,7 +28,6 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
|
@ -53,8 +51,8 @@ public class LibraryTopLevelActivity extends LibraryBaseActivity {
|
|||
if (SQLiteBooksDatabase.Instance() == null) {
|
||||
new SQLiteBooksDatabase(this, "LIBRARY_NG");
|
||||
}
|
||||
if (Library == null) {
|
||||
Library = new Library();
|
||||
if (LibraryInstance == null) {
|
||||
LibraryInstance = new Library();
|
||||
startService(new Intent(getApplicationContext(), InitializationService.class));
|
||||
}
|
||||
|
||||
|
@ -95,7 +93,7 @@ public class LibraryTopLevelActivity extends LibraryBaseActivity {
|
|||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Library = null;
|
||||
LibraryInstance = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,15 +69,15 @@ public class LibraryTreeActivity extends LibraryBaseActivity {
|
|||
|
||||
FBTree tree = null;
|
||||
if (PATH_RECENT.equals(path[0])) {
|
||||
tree = Library.recentBooks();
|
||||
tree = LibraryInstance.recentBooks();
|
||||
} else if (PATH_SEARCH_RESULTS.equals(path[0])) {
|
||||
tree = Library.searchResults();
|
||||
tree = LibraryInstance.searchResults();
|
||||
} else if (PATH_BY_AUTHOR.equals(path[0])) {
|
||||
tree = Library.byAuthor();
|
||||
tree = LibraryInstance.byAuthor();
|
||||
} else if (PATH_BY_TAG.equals(path[0])) {
|
||||
tree = Library.byTag();
|
||||
tree = LibraryInstance.byTag();
|
||||
} else if (PATH_FAVORITES.equals(path[0])) {
|
||||
tree = Library.favorites();
|
||||
tree = LibraryInstance.favorites();
|
||||
}
|
||||
|
||||
for (int i = 1; i < path.length; ++i) {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.geometerplus.android.fbreader.network;
|
||||
|
||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.geometerplus.zlibrary.core.image.ZLLoadableImage;
|
|||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
|
||||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageLoader;
|
||||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageData;
|
||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
|
||||
|
||||
import org.geometerplus.fbreader.network.NetworkTree;
|
||||
import org.geometerplus.fbreader.network.tree.NetworkBookTree;
|
||||
|
|
|
@ -30,7 +30,6 @@ import android.os.Message;
|
|||
import android.view.*;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import org.geometerplus.zlibrary.core.library.ZLibrary;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
||||
import org.geometerplus.zlibrary.core.language.ZLLanguageUtil;
|
||||
|
|
|
@ -31,7 +31,6 @@ import android.os.Message;
|
|||
import android.view.MenuItem;
|
||||
import android.view.Menu;
|
||||
|
||||
import org.geometerplus.zlibrary.core.image.ZLLoadableImage;
|
||||
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
||||
|
||||
import org.geometerplus.fbreader.network.*;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Set;
|
|||
import java.util.LinkedList;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
|
|
@ -20,12 +20,9 @@
|
|||
package org.geometerplus.android.fbreader.preferences;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLIntegerOption;
|
||||
import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
import org.geometerplus.zlibrary.text.view.style.*;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.*;
|
|||
import org.geometerplus.zlibrary.core.constants.XMLNamespaces;
|
||||
import org.geometerplus.zlibrary.core.constants.MimeTypes;
|
||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||
import org.geometerplus.zlibrary.core.image.ZLSingleImage;
|
||||
import org.geometerplus.zlibrary.core.image.ZLImageProxy;
|
||||
import org.geometerplus.zlibrary.core.xml.*;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
package org.geometerplus.zlibrary.core.dialogs;
|
||||
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
public abstract class ZLDialogManager {
|
||||
protected static ZLDialogManager ourInstance;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue