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

class & fields renamings

This commit is contained in:
Nikolay Pultsin 2013-09-15 20:00:29 +03:00
parent cd35f7ee53
commit a4dd79f523

View file

@ -34,7 +34,7 @@ import org.geometerplus.android.fbreader.covers.CoverManager;
public class AllCatalogsActivity extends Activity { public class AllCatalogsActivity extends Activity {
final NetworkLibrary myLibrary = NetworkLibrary.Instance(); final NetworkLibrary myLibrary = NetworkLibrary.Instance();
CheckListAdapter myAdapter; CatalogsListAdapter myAdapter;
ArrayList<String> myIds = new ArrayList<String>(); ArrayList<String> myIds = new ArrayList<String>();
ArrayList<String> myInactiveIds = new ArrayList<String>(); ArrayList<String> myInactiveIds = new ArrayList<String>();
@ -59,7 +59,7 @@ public class AllCatalogsActivity extends Activity {
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
final ArrayList<CheckItem> idItems = new ArrayList<CheckItem>(); final ArrayList<Item> idItems = new ArrayList<Item>();
if (myIds.size() > 0) { if (myIds.size() > 0) {
idItems.add(new SectionItem(getLabelByKey("active"))); idItems.add(new SectionItem(getLabelByKey("active")));
@ -79,8 +79,8 @@ public class AllCatalogsActivity extends Activity {
idItems.addAll(items); idItems.addAll(items);
} }
ListView selectedList = (ListView) findViewById(R.id.selectedList); final ListView selectedList = (ListView)findViewById(R.id.selectedList);
myAdapter = new CheckListAdapter(this, R.layout.checkbox_item, idItems, this); myAdapter = new CatalogsListAdapter(R.layout.checkbox_item, idItems);
selectedList.setAdapter(myAdapter); selectedList.setAdapter(myAdapter);
} }
@ -103,9 +103,12 @@ public class AllCatalogsActivity extends Activity {
super.onStop(); super.onStop();
if (myIsChanged) { if (myIsChanged) {
final ArrayList<String> ids = new ArrayList<String>(); final ArrayList<String> ids = new ArrayList<String>();
for (CheckItem item : myAdapter.getItems()) { for (Item item : myAdapter.getItems()) {
if (item instanceof CatalogItem && ((CatalogItem)item).IsChecked) { if (item instanceof CatalogItem) {
ids.add(item.Id); final CatalogItem catalogItem = (CatalogItem)item;
if (catalogItem.IsChecked) {
ids.add(catalogItem.Id);
}
} }
} }
myLibrary.setActiveIds(ids); myLibrary.setActiveIds(ids);
@ -113,26 +116,24 @@ public class AllCatalogsActivity extends Activity {
} }
} }
private static abstract class CheckItem { private static interface Item {
}
private static class SectionItem implements Item {
private final String Title;
public SectionItem(String title) {
Title = title;
}
}
private static class CatalogItem implements Item, Comparable<CatalogItem> {
private final String Id; private final String Id;
public CheckItem(String id) {
Id = id;
}
}
private static class SectionItem extends CheckItem {
public SectionItem(String id) {
super(id);
}
}
private static class CatalogItem extends CheckItem implements Comparable<CatalogItem> {
private final NetworkTree Tree; private final NetworkTree Tree;
private boolean IsChecked; private boolean IsChecked;
public CatalogItem(String id, boolean checked, NetworkTree tree) { public CatalogItem(String id, boolean checked, NetworkTree tree) {
super(id); Id = id;
IsChecked = checked; IsChecked = checked;
Tree = tree; Tree = tree;
} }
@ -151,38 +152,36 @@ public class AllCatalogsActivity extends Activity {
} }
} }
private class CheckListAdapter extends ArrayAdapter<CheckItem> { private class CatalogsListAdapter extends ArrayAdapter<Item> {
Activity myActivity;
private CoverManager myCoverManager; private CoverManager myCoverManager;
private ArrayList<CheckItem> items = new ArrayList<CheckItem>(); private ArrayList<Item> items = new ArrayList<Item>();
public CheckListAdapter(Context context, int textViewResourceId, List<CheckItem> objects, Activity activity) { public CatalogsListAdapter(int textViewResourceId, List<Item> objects) {
super(context, textViewResourceId, objects); super(AllCatalogsActivity.this, textViewResourceId, objects);
myActivity = activity;
items.addAll(objects); items.addAll(objects);
} }
public ArrayList<CheckItem> getItems() { public ArrayList<Item> getItems() {
return items; return items;
} }
@Override @Override
public View getView(int position, View convertView, final ViewGroup parent) { public View getView(int position, View convertView, final ViewGroup parent) {
View v = convertView; View v = convertView;
final CheckItem item = this.getItem(position); final Item item = this.getItem(position);
if (item instanceof SectionItem) { if (item instanceof SectionItem) {
v = LayoutInflater.from(getContext()).inflate(R.layout.checkbox_section, null); v = LayoutInflater.from(getContext()).inflate(R.layout.checkbox_section, null);
TextView tt = (TextView)v.findViewById(R.id.title); TextView tt = (TextView)v.findViewById(R.id.title);
if (tt != null) { if (tt != null) {
tt.setText(item.Id); tt.setText(((SectionItem)item).Title);
} }
} else /* if (item instanceof CatalogItem) */ { } else /* if (item instanceof CatalogItem) */ {
final CatalogItem catalogItem = (CatalogItem)item; final CatalogItem catalogItem = (CatalogItem)item;
if (myCoverManager == null) { if (myCoverManager == null) {
v.measure(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); v.measure(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int coverHeight = v.getMeasuredHeight(); final int coverHeight = v.getMeasuredHeight();
myCoverManager = new CoverManager(myActivity, coverHeight * 15 / 12, coverHeight); myCoverManager = new CoverManager(AllCatalogsActivity.this, coverHeight * 15 / 12, coverHeight);
v.requestLayout(); v.requestLayout();
} }