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

formatting

This commit is contained in:
Nikolay Pultsin 2013-09-15 13:44:45 +01:00
parent 0cb1180467
commit e8695cf6f2
4 changed files with 67 additions and 73 deletions

View file

@ -1,23 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp">
<TextView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"/>
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
/>
</LinearLayout>

View file

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView android:id="@+id/selectedList"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ListView
android:id="@+id/selectedList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

View file

@ -33,35 +33,33 @@ import org.geometerplus.fbreader.network.*;
import org.geometerplus.fbreader.network.tree.NetworkCatalogRootTree;
import org.geometerplus.android.fbreader.covers.CoverManager;
public class AllCatalogsActivity extends Activity {
final NetworkLibrary library = NetworkLibrary.Instance();
CheckListAdapter myAdapter;
ArrayList<String> ids = new ArrayList<String>();
ArrayList<String> inactiveIds = new ArrayList<String>();
public final static String IDS_LIST = "org.geometerplus.android.fbreader.network.IDS_LIST";
public final static String INACTIVE_IDS_LIST = "org.geometerplus.android.fbreader.network.INACTIVE_IDS_LIST";
private boolean isChanged = false;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.network_library_filter);
Intent intent = getIntent();
ids = intent.getStringArrayListExtra(IDS_LIST);
inactiveIds = intent.getStringArrayListExtra(INACTIVE_IDS_LIST);
}
@Override
protected void onStart() {
super.onStart();
ArrayList<CheckItem> idItems = new ArrayList<CheckItem>();
if(ids.size() > 0){
idItems.add(new CheckSection(getLabelByKey("active")));
@ -76,34 +74,34 @@ public class AllCatalogsActivity extends Activity {
System.out.println("-- "+i.getTree().getTreeTitle());
}
}
if(inactiveIds.size() > 0){
idItems.add(new CheckSection(getLabelByKey("inactive")));
for(String i : inactiveIds){
idItems.add(new CheckItem(i, false, library.getCatalogTreeByUrlAll(i)));
}
}
ListView selectedList = (ListView) findViewById(R.id.selectedList);
myAdapter = new CheckListAdapter(this, R.layout.checkbox_item, idItems, this);
selectedList.setAdapter(myAdapter);
}
private String getLabelByKey(String keyName) {
return NetworkLibrary.resource().getResource("allCatalogs").getResource(keyName).getValue();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
protected void onStop() {
super.onStop();
@ -119,12 +117,12 @@ public class AllCatalogsActivity extends Activity {
library.synchronize();
}
}
private class CheckItem implements Comparable<CheckItem>{
private String myId;
private boolean isChecked;
NetworkTree myTree = null;
public CheckItem(String id, boolean checked, NetworkTree tree){
myId = id;
isChecked = checked;
@ -134,36 +132,36 @@ public class AllCatalogsActivity extends Activity {
System.out.println("Tree parameter should be an instance of NetworkCatalogRootTree");
}
}
public CheckItem(String id, boolean checked){
myId = id;
isChecked = checked;
}
public String getId(){
return myId;
}
public NetworkTree getTree(){
return myTree;
}
public String getTitle(){
return myTree.getLink().getTitle();
}
public String getTitleLower(){
return getTitle().toLowerCase(Locale.getDefault());
}
public boolean isChecked(){
return isChecked;
}
public void setChecked(boolean value){
isChecked = value;
}
public boolean isSection(){
return false;
}
@ -173,7 +171,7 @@ public class AllCatalogsActivity extends Activity {
return getTitleLower().compareTo(another.getTitleLower());
}
}
private class CheckSection extends CheckItem{
public CheckSection(String title){
super(title, false);
@ -182,28 +180,28 @@ public class AllCatalogsActivity extends Activity {
return true;
}
}
private class CheckListAdapter extends ArrayAdapter<CheckItem> {
Activity myActivity;
private CoverManager myCoverManager;
private ArrayList<CheckItem> items = new ArrayList<CheckItem>();
public CheckListAdapter(Context context, int textViewResourceId, List<CheckItem> objects, Activity activity) {
super(context, textViewResourceId, objects);
myActivity = activity;
items.addAll(objects);
}
public ArrayList<CheckItem> getItems(){
return items;
}
@Override
public View getView(int position, View convertView, final ViewGroup parent) {
View v = convertView;
CheckItem item = this.getItem(position);
CheckItem item = this.getItem(position);
if (item != null) {
if(item.isSection()){
LayoutInflater vi;
@ -214,20 +212,20 @@ public class AllCatalogsActivity extends Activity {
tt.setText(item.getId());
}
}else{
if (myCoverManager == null) {
v.measure(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int coverHeight = v.getMeasuredHeight();
myCoverManager = new CoverManager(myActivity, coverHeight * 15 / 12, coverHeight);
v.requestLayout();
}
LayoutInflater vi;
vi = LayoutInflater.from(getContext());
v = vi.inflate(R.layout.checkbox_item, null);
NetworkTree t = item.getTree();
if(t != null){
INetworkLink link = t.getLink();
TextView tt = (TextView)v.findViewById(R.id.title);
@ -238,27 +236,27 @@ public class AllCatalogsActivity extends Activity {
if (tt != null) {
tt.setText(link.getSummary());
}
ImageView coverView = (ImageView)v.findViewById(R.id.icon);
if (!myCoverManager.trySetCoverImage(coverView, t)) {
coverView.setImageResource(R.drawable.ic_list_library_books);
}
CheckBox ch = (CheckBox)v.findViewById(R.id.check_item);
if (ch != null) {
ch.setText("");
ch.setChecked(item.isChecked());
ch.setTag(item);
ch.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox)v;
ch.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox)v;
CheckItem checkedItem = (CheckItem) cb.getTag();
if(checkedItem != null){
checkedItem.setChecked(cb.isChecked());
}
isChanged = true;
}
});
});
}
}
}

View file

@ -475,12 +475,10 @@ public class NetworkLibrary {
if (l != null && link.compareTo(l) <= 0) {
break;
}
++index;
}
new NetworkCatalogRootTree(myRootTree, link, index);
}
// we do add non-catalog items
new SearchCatalogTree(myRootTree, mySearchItem, 0);
new AddCustomCatalogItemTree(myRootTree);