[cng1985] r629 committed - [No log message]

2 views
Skip to first unread message

cng...@googlecode.com

unread,
Sep 12, 2011, 10:28:36 PM9/12/11
to cng...@googlegroups.com
Revision: 629
Author: cng1985
Date: Mon Sep 12 19:27:13 2011
Log: [No log message]
http://code.google.com/p/cng1985/source/detail?r=629

Modified:
/books/src/com/baoyi/adapter/BooksAdapter.java
/books/src/com/baoyi/widget/BookWidget.java
/books/src/com/iym/bookstore/MainUI.java
/books/src/org/geometerplus/android/fbreader/ShowLibraryAction.java

=======================================
--- /books/src/com/baoyi/adapter/BooksAdapter.java Mon Sep 12 18:58:48 2011
+++ /books/src/com/baoyi/adapter/BooksAdapter.java Mon Sep 12 19:27:13 2011
@@ -14,9 +14,11 @@

public class BooksAdapter extends BaseAdapter {
private Context context;
+ private int imagesourceid;
private List<BookWidget> widgets=new ArrayList<BookWidget>();
- public BooksAdapter(Context c){
+ public BooksAdapter(Context c,int imageid){
context=c;
+ imagesourceid=imageid;
}
public void setDatas(FBTree fbs){
datas= fbs.subTrees();
@@ -26,6 +28,7 @@
BookWidget item=new BookWidget(context);
item.setTitle(fbTree.getName());
item.setAuthor(fbTree.getSecondString());
+ item.setImage(imagesourceid);
widgets.add(item);
}
}
=======================================
--- /books/src/com/baoyi/widget/BookWidget.java Mon Sep 12 18:58:48 2011
+++ /books/src/com/baoyi/widget/BookWidget.java Mon Sep 12 19:27:13 2011
@@ -2,6 +2,7 @@

import android.content.Context;
import android.view.LayoutInflater;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

@@ -11,11 +12,13 @@

private TextView noveltext;
private TextView author;
+ private ImageView imageView;
public BookWidget(Context context) {
super(context);
LayoutInflater.from(getContext()).inflate(R.layout.widget_book, this);
noveltext = (TextView) findViewById(R.id.library_tree_item_name);
author= (TextView) findViewById(R.id.library_tree_item_childrenlist);
+ imageView= (ImageView) findViewById(R.id.library_tree_item_icon);
}
public void setTitle(String title){
noveltext.setText(title);
@@ -23,5 +26,8 @@
public void setAuthor(String title){
author.setText(title);
}
+ public void setImage(int id){
+ imageView.setImageResource(id);
+ }

}
=======================================
--- /books/src/com/iym/bookstore/MainUI.java Mon Sep 12 18:58:48 2011
+++ /books/src/com/iym/bookstore/MainUI.java Mon Sep 12 19:27:13 2011
@@ -2,14 +2,15 @@

import org.geometerplus.android.fbreader.BookInfoActivity;
import org.geometerplus.android.fbreader.SQLiteBooksDatabase;
-import org.geometerplus.android.fbreader.library.InitializationService;
-import org.geometerplus.android.fbreader.library.LibraryBaseActivity;
import org.geometerplus.android.fbreader.library.LibraryTopLevelActivity;
import org.geometerplus.android.fbreader.network.NetworkLibraryActivity;
+import org.geometerplus.fbreader.library.AuthorTree;
import org.geometerplus.fbreader.library.Book;
import org.geometerplus.fbreader.library.BookTree;
import org.geometerplus.fbreader.library.BooksDatabase;
import org.geometerplus.fbreader.library.Library;
+import org.geometerplus.fbreader.library.TagTree;
+import org.geometerplus.fbreader.tree.FBTree;

import android.app.Activity;
import android.app.AlertDialog;
@@ -74,6 +75,7 @@
R.anim.max);
v.startAnimation(animation);
chanageBg(v);
+ initDataByTitle();
}

});
@@ -86,6 +88,7 @@
R.anim.max);
v.startAnimation(animation);
chanageBg(v);
+ initDataByAuthor();
}
});
biaoti.setOnClickListener(new OnClickListener() {
@@ -96,7 +99,9 @@
Animation animation = AnimationUtils.loadAnimation(MainUI.this,
R.anim.max);
v.startAnimation(animation);
+ initDataByTag();
chanageBg(v);
+
}
});
tushuguan.setOnClickListener(new OnClickListener() {
@@ -108,11 +113,13 @@
R.anim.max);
v.startAnimation(animation);
openOnline();
+
}
});

init();
- initData();
+ chanageBg(tushu);
+ initDataByTitle();
//aa();
}

@@ -128,14 +135,14 @@

BooksAdapter adapter;

- private void initData() {
+ private void initDataByTitle() {
DatabaseInstance = SQLiteBooksDatabase.Instance();
if (DatabaseInstance == null) {
DatabaseInstance = new SQLiteBooksDatabase(this, "LIBRARY");
}


- adapter = new BooksAdapter(this);
+ adapter = new BooksAdapter(this,R.drawable.ic_list_library_books);
// adapter.set
LibraryInstance = new Library();
LibraryInstance.synchronize();
@@ -160,7 +167,96 @@
}

}
-
+ private void initDataByTag() {
+ DatabaseInstance = SQLiteBooksDatabase.Instance();
+ if (DatabaseInstance == null) {
+ DatabaseInstance = new SQLiteBooksDatabase(this, "LIBRARY");
+ }
+
+
+ adapter = new BooksAdapter(this,R.drawable.ic_list_library_tag);
+ // adapter.set
+ LibraryInstance = new Library();
+ LibraryInstance.synchronize();
+ try {
+ adapter.setDatas(LibraryInstance.byTag());
+ listView.setAdapter(adapter);
+ listView.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1,
+ int arg2, long arg3) {
+ BookWidget book = (BookWidget) arg1;
+ Object item = adapter.getItem(arg2);
+ if (item instanceof TagTree) {
+ TagTree fb = (TagTree) item;
+ showAuthor(fb);
+ }
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+ private void initDataByAuthor() {
+ DatabaseInstance = SQLiteBooksDatabase.Instance();
+ if (DatabaseInstance == null) {
+ DatabaseInstance = new SQLiteBooksDatabase(this, "LIBRARY");
+ }
+
+
+ adapter = new BooksAdapter(this,R.drawable.ic_list_library_author);
+ // adapter.set
+ LibraryInstance = new Library();
+ LibraryInstance.synchronize();
+ try {
+ adapter.setDatas(LibraryInstance.byAuthor());
+ listView.setAdapter(adapter);
+ listView.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1,
+ int arg2, long arg3) {
+ BookWidget book = (BookWidget) arg1;
+ Object item = adapter.getItem(arg2);
+ if (item instanceof AuthorTree) {
+ AuthorTree fb = (AuthorTree) item;
+ showAuthor(fb);
+ //showBookInfo(fb.Book);
+ }
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+ protected void showAuthor(FBTree tree) {
+ adapter = new BooksAdapter(this,R.drawable.ic_list_library_books);
+ // adapter.set
+ LibraryInstance = new Library();
+ LibraryInstance.synchronize();
+ try {
+ adapter.setDatas(tree);
+ listView.setAdapter(adapter);
+ listView.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1,
+ int arg2, long arg3) {
+ BookWidget book = (BookWidget) arg1;
+ Object item = adapter.getItem(arg2);
+ if (item instanceof BookTree) {
+ BookTree fb = (BookTree) item;
+ showBookInfo(fb.Book);
+ }
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
protected void showBookInfo(Book book) {
startActivityForResult(new Intent(getApplicationContext(),
BookInfoActivity.class).putExtra(
=======================================
--- /books/src/org/geometerplus/android/fbreader/ShowLibraryAction.java Thu
Sep 8 01:57:02 2011
+++ /books/src/org/geometerplus/android/fbreader/ShowLibraryAction.java Mon
Sep 12 19:27:13 2011
@@ -19,13 +19,14 @@

package org.geometerplus.android.fbreader;

-import android.content.Intent;
-
+import org.geometerplus.android.fbreader.library.LibraryTopLevelActivity;
+import org.geometerplus.fbreader.bookmodel.BookModel;
import org.geometerplus.fbreader.fbreader.FBAction;
import org.geometerplus.fbreader.fbreader.FBReaderApp;
-import org.geometerplus.fbreader.bookmodel.BookModel;
-
-import org.geometerplus.android.fbreader.library.LibraryTopLevelActivity;
+
+import android.content.Intent;
+
+import com.iym.bookstore.MainUI;

class ShowLibraryAction extends FBAction {
private final FBReader myBaseActivity;
@@ -37,7 +38,7 @@

public void run() {
final BookModel model = Reader.Model;
- Intent intent = new Intent(myBaseActivity.getApplicationContext(),
LibraryTopLevelActivity.class);
+ Intent intent = new Intent(myBaseActivity.getApplicationContext(),
MainUI.class);
if (model != null && model.Book != null) {
intent.putExtra(LibraryTopLevelActivity.SELECTED_BOOK_PATH_KEY,
model.Book.File.getPath());
}

Reply all
Reply to author
Forward
0 new messages