mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
NG Library View: in progress
This commit is contained in:
parent
97d0cbe046
commit
78eeff76c6
7 changed files with 69 additions and 55 deletions
|
@ -80,7 +80,7 @@
|
|||
<activity android:name="org.geometerplus.android.fbreader.library.LibraryTopLevelActivity" android:process=":library" 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.library.LibraryRecentActivity" android:process=":library" android:configChanges="orientation|keyboardHidden">
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.LibraryTreeActivity" android:process=":library" 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" />
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<activity android:name="org.geometerplus.android.fbreader.library.LibraryTopLevelActivity" android:process=":library" 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.library.LibraryRecentActivity" android:process=":library" android:configChanges="orientation|keyboardHidden">
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.LibraryTreeActivity" android:process=":library" 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" />
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
<node name="recent" value="Recent">
|
||||
<node name="summary" value="Recently opened books"/>
|
||||
</node>
|
||||
<node name="favorites" value="Favorites">
|
||||
<node name="summary" value="My selected books"/>
|
||||
</node>
|
||||
<node name="searchResults" value="Found">
|
||||
<node name="summary" value="Search results for: %s"/>
|
||||
</node>
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.geometerplus.android.fbreader.library;
|
|||
import java.util.List;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.view.*;
|
||||
|
@ -48,6 +49,7 @@ abstract class LibraryBaseActivity extends ListActivity {
|
|||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
|
||||
mySelectedBookPath = getIntent().getStringExtra(SELECTED_BOOK_PATH_KEY);
|
||||
}
|
||||
|
||||
|
@ -121,4 +123,22 @@ abstract class LibraryBaseActivity extends ListActivity {
|
|||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
protected class OpenTreeRunnable implements Runnable {
|
||||
private final String myTreePath;
|
||||
private final String mySelectedBookPath;
|
||||
|
||||
public OpenTreeRunnable(String treePath, String selectedBookPath) {
|
||||
myTreePath = treePath;
|
||||
mySelectedBookPath = selectedBookPath;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
startActivity(
|
||||
new Intent(LibraryBaseActivity.this, LibraryTreeActivity.class)
|
||||
.putExtra(SELECTED_BOOK_PATH_KEY, mySelectedBookPath)
|
||||
.putExtra(LibraryTreeActivity.TREE_PATH_KEY, myTreePath)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.android.fbreader.library;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.geometerplus.fbreader.library.Library;
|
||||
|
||||
public class LibraryRecentActivity extends LibraryTreeActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
setListAdapter(new LibraryAdapter(LibraryTopLevelActivity.Library.recentBooks().subTrees()));
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
@ -42,6 +43,7 @@ public class LibraryTopLevelActivity extends LibraryBaseActivity {
|
|||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
if (SQLiteBooksDatabase.Instance() == null) {
|
||||
new SQLiteBooksDatabase("LIBRARY_NG");
|
||||
|
@ -59,35 +61,25 @@ public class LibraryTopLevelActivity extends LibraryBaseActivity {
|
|||
}
|
||||
}
|
||||
));
|
||||
items.add(new TopLevelTree(
|
||||
myResource.getResource("favorites"),
|
||||
R.drawable.ic_tab_library_recent,
|
||||
new OpenTreeRunnable(LibraryTreeActivity.PATH_FAVORITES, mySelectedBookPath)
|
||||
));
|
||||
items.add(new TopLevelTree(
|
||||
myResource.getResource("recent"),
|
||||
R.drawable.ic_tab_library_recent,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
final Intent intent = new Intent(
|
||||
LibraryTopLevelActivity.this,
|
||||
LibraryRecentActivity.class
|
||||
);
|
||||
intent.putExtra(SELECTED_BOOK_PATH_KEY, mySelectedBookPath);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
new OpenTreeRunnable(LibraryTreeActivity.PATH_RECENT, mySelectedBookPath)
|
||||
));
|
||||
items.add(new TopLevelTree(
|
||||
myResource.getResource("byAuthor"),
|
||||
R.drawable.library_by_author,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
}
|
||||
}
|
||||
new OpenTreeRunnable(LibraryTreeActivity.PATH_BY_AUTHOR, mySelectedBookPath)
|
||||
));
|
||||
items.add(new TopLevelTree(
|
||||
myResource.getResource("byTag"),
|
||||
R.drawable.library_by_tag,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
}
|
||||
}
|
||||
new OpenTreeRunnable(LibraryTreeActivity.PATH_BY_TAG, mySelectedBookPath)
|
||||
));
|
||||
items.add(new TopLevelTree(
|
||||
myResource.getResource("fileTree"),
|
||||
|
|
|
@ -19,17 +19,49 @@
|
|||
|
||||
package org.geometerplus.android.fbreader.library;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.geometerplus.fbreader.library.Library;
|
||||
import org.geometerplus.fbreader.library.LibraryTree;
|
||||
import org.geometerplus.fbreader.library.BookTree;
|
||||
|
||||
import org.geometerplus.android.fbreader.FBReader;
|
||||
|
||||
abstract class LibraryTreeActivity extends LibraryBaseActivity {
|
||||
public class LibraryTreeActivity extends LibraryBaseActivity {
|
||||
static final String TREE_PATH_KEY = "TreePath";
|
||||
|
||||
static final String PATH_FAVORITES = "favorites";
|
||||
static final String PATH_RECENT = "recent";
|
||||
static final String PATH_BY_AUTHOR = "author";
|
||||
static final String PATH_BY_TAG = "tag";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
final String[] path = getIntent().getStringExtra(TREE_PATH_KEY).split("\000");
|
||||
|
||||
final Library library = LibraryTopLevelActivity.Library;
|
||||
LibraryTree root = null;
|
||||
if (path.length == 1) {
|
||||
if (PATH_RECENT.equals(path[0])) {
|
||||
root = library.recentBooks();
|
||||
} else if (PATH_BY_AUTHOR.equals(path[0])) {
|
||||
root = library.byAuthor();
|
||||
} else if (PATH_BY_TAG.equals(path[0])) {
|
||||
root = library.byTag();
|
||||
} else if (PATH_FAVORITES.equals(path[0])) {
|
||||
}
|
||||
}
|
||||
|
||||
if (root != null) {
|
||||
setListAdapter(new LibraryAdapter(root.subTrees()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView listView, View view, int position, long rowId) {
|
||||
LibraryTree tree = (LibraryTree)((LibraryAdapter)getListAdapter()).getItem(position);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue