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

rollback: library tab activity has not view changes against master branch

This commit is contained in:
Nikolay Pultsin 2010-11-20 07:43:15 +00:00
parent 6483c0c07a
commit 7e485dcc9f
5 changed files with 11 additions and 56 deletions

View file

@ -3,21 +3,21 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingLeft="5dp"
android:paddingLeft="5dip"
android:orientation="horizontal"
android:gravity="top|left"
>
<ImageView
android:id="@+id/library_tree_item_icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:adjustViewBounds="false"
android:layout_height="wrap_content"
android:paddingTop="10dip"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingLeft="5dp"
android:paddingLeft="5dip"
android:paddingRight="8dp"
android:orientation="vertical"
>
@ -25,7 +25,7 @@
android:id="@+id/library_tree_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginTop="6dip"
android:layout_alignParentTop="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
@ -36,7 +36,7 @@
android:id="@+id/library_tree_item_childrenlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginTop="5dip"
android:layout_below="@id/library_tree_item_name"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"

View file

@ -68,7 +68,7 @@ public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuIt
private void createDefaultTabs() {
new LibraryAdapter(createTab("byAuthor", R.id.by_author, R.drawable.ic_tab_library_author), myLibrary.byAuthor(), Type.TREE);
new LibraryAdapter(createTab("byTag", R.id.by_tag, R.drawable.ic_tab_library_tag), myLibrary.byTag(), Type.TREE);
new LibraryAdapter(createTab("recent", R.id.recent, R.drawable.ic_tab_library_recent), myLibrary.recentBooks(), Type.TREE);
new LibraryAdapter(createTab("recent", R.id.recent, R.drawable.ic_tab_library_recent), myLibrary.recentBooks(), Type.FLAT);
findViewById(R.id.search_results).setVisibility(View.GONE);
}

View file

@ -112,7 +112,7 @@ public class TOCActivity extends ListActivity {
LayoutInflater.from(parent.getContext()).inflate(R.layout.toc_tree_item, parent, false);
final TOCTree tree = (TOCTree)getItem(position);
view.setBackgroundColor((tree == mySelectedItem) ? 0xff808080 : 0);
setIcon(view, (ImageView)view.findViewById(R.id.toc_tree_item_icon), tree);
setIcon((ImageView)view.findViewById(R.id.toc_tree_item_icon), tree);
((TextView)view.findViewById(R.id.toc_tree_item_text)).setText(tree.getText());
return view;
}

View file

@ -23,17 +23,11 @@ import java.util.HashSet;
import android.view.*;
import android.widget.*;
import android.graphics.Bitmap;
import org.geometerplus.zlibrary.core.tree.ZLTree;
import org.geometerplus.zlibrary.core.image.ZLImage;
import org.geometerplus.zlibrary.ui.android.R;
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageData;
abstract class ZLTreeAdapter extends BaseAdapter implements AdapterView.OnItemClickListener, View.OnCreateContextMenuListener {
private final ListView myParent;
private ZLTree<?> myTree;
@ -192,7 +186,7 @@ abstract class ZLTreeAdapter extends BaseAdapter implements AdapterView.OnItemCl
public abstract View getView(int position, View convertView, ViewGroup parent);
protected final void setIcon(View parentView, ImageView imageView, ZLTree<?> tree) {
protected final void setIcon(ImageView imageView, ZLTree<?> tree) {
if (tree.hasChildren()) {
if (isOpen(tree)) {
imageView.setImageResource(R.drawable.ic_list_group_open);
@ -200,42 +194,8 @@ abstract class ZLTreeAdapter extends BaseAdapter implements AdapterView.OnItemCl
imageView.setImageResource(R.drawable.ic_list_group_closed);
}
} else {
setupCover(parentView, imageView, tree);
imageView.setImageResource(R.drawable.ic_list_group_empty);
}
imageView.setPadding(25 * (tree.Level - 1), imageView.getPaddingTop(), 0, imageView.getPaddingBottom());
}
ZLImage myFBReaderIcon;
private void setupCover(View parentView, ImageView imageView, ZLTree<?> tree) {
System.err.println("setupCover 0");
final int height = parentView.getMeasuredHeight();
final int width = height * 15 / 32;
Bitmap coverBitmap = null;
ZLImage cover = null;//tree.getCover();
if (cover == null) {
System.err.println("setupCover 1");
if (myFBReaderIcon == null) {
myFBReaderIcon = ZLAndroidLibrary.createImage(parentView.getContext(), R.drawable.fbreader);
}
cover = myFBReaderIcon;
}
if (cover != null) {
System.err.println("setupCover 2");
final ZLAndroidImageManager mgr = (ZLAndroidImageManager)ZLAndroidImageManager.Instance();
final ZLAndroidImageData data = mgr.getImageData(cover);
if (data != null) {
System.err.println("setupCover 3");
coverBitmap = data.getBitmap(width, height);
}
}
if (coverBitmap != null) {
System.err.println("setupCover 4a");
imageView.setImageBitmap(coverBitmap);
} else {
System.err.println("setupCover 4b");
imageView.setImageDrawable(null);
}
}
}

View file

@ -23,7 +23,6 @@ import java.io.*;
import java.util.*;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.AssetFileDescriptor;
import android.content.Intent;
@ -109,12 +108,8 @@ public final class ZLAndroidLibrary extends ZLibrary {
return new AndroidAssetsFile((AndroidAssetsFile)parent, name);
}
public static ZLImage createImage(Context context, int drawableId) {
return new ZLAndroidResourceBasedImageData(context.getResources(), drawableId);
}
public ZLImage createImage(int drawableId) {
return createImage(myApplication, drawableId);
return new ZLAndroidResourceBasedImageData(myApplication.getResources(), drawableId);
}
@Override