diff --git a/src/org/geometerplus/android/fbreader/network/AllCatalogsActivity.java b/src/org/geometerplus/android/fbreader/network/AllCatalogsActivity.java index aef233436..ee6bafb78 100644 --- a/src/org/geometerplus/android/fbreader/network/AllCatalogsActivity.java +++ b/src/org/geometerplus/android/fbreader/network/AllCatalogsActivity.java @@ -34,7 +34,7 @@ import org.geometerplus.android.fbreader.covers.CoverManager; public class AllCatalogsActivity extends Activity { final NetworkLibrary myLibrary = NetworkLibrary.Instance(); - CatalogsListAdapter myAdapter; + private ArrayList myAllItems = new ArrayList(); ArrayList myIds = new ArrayList(); ArrayList myInactiveIds = new ArrayList(); @@ -58,29 +58,28 @@ public class AllCatalogsActivity extends Activity { protected void onStart() { super.onStart(); - final ArrayList idItems = new ArrayList(); + myAllItems.clear(); if (myIds.size() > 0) { - idItems.add(new SectionItem(getLabelByKey("active"))); - final TreeSet items = new TreeSet(); + myAllItems.add(new SectionItem(getLabelByKey("active"))); + final TreeSet cItems = new TreeSet(); for (String id : myIds) { - items.add(new CatalogItem(id, true, myLibrary.getCatalogTreeByUrlAll(id))); + cItems.add(new CatalogItem(id, true, myLibrary.getCatalogTreeByUrlAll(id))); } - idItems.addAll(items); + myAllItems.addAll(cItems); } if (myInactiveIds.size() > 0) { - idItems.add(new SectionItem(getLabelByKey("inactive"))); - final TreeSet items = new TreeSet(); + myAllItems.add(new SectionItem(getLabelByKey("inactive"))); + final TreeSet cItems = new TreeSet(); for (String id : myInactiveIds) { - items.add(new CatalogItem(id, false, myLibrary.getCatalogTreeByUrlAll(id))); + cItems.add(new CatalogItem(id, false, myLibrary.getCatalogTreeByUrlAll(id))); } - idItems.addAll(items); + myAllItems.addAll(cItems); } final ListView selectedList = (ListView)findViewById(R.id.selectedList); - myAdapter = new CatalogsListAdapter(R.layout.checkbox_item, idItems); - selectedList.setAdapter(myAdapter); + selectedList.setAdapter(new CatalogsListAdapter(R.layout.checkbox_item)); } private String getLabelByKey(String keyName) { @@ -102,7 +101,7 @@ public class AllCatalogsActivity extends Activity { super.onStop(); if (myIsChanged) { final ArrayList ids = new ArrayList(); - for (Item item : myAdapter.getItems()) { + for (Item item : myAllItems) { if (item instanceof CatalogItem) { final CatalogItem catalogItem = (CatalogItem)item; if (catalogItem.IsChecked) { @@ -153,21 +152,15 @@ public class AllCatalogsActivity extends Activity { private class CatalogsListAdapter extends ArrayAdapter { private CoverManager myCoverManager; - private ArrayList items = new ArrayList(); - public CatalogsListAdapter(int textViewResourceId, List objects) { - super(AllCatalogsActivity.this, textViewResourceId, objects); - items.addAll(objects); - } - - public ArrayList getItems() { - return items; + public CatalogsListAdapter(int textViewResourceId) { + super(AllCatalogsActivity.this, textViewResourceId, myAllItems); } @Override public View getView(int position, View convertView, final ViewGroup parent) { View v = convertView; - final Item item = this.getItem(position); + final Item item = getItem(position); if (item instanceof SectionItem) { v = LayoutInflater.from(getContext()).inflate(R.layout.checkbox_section, null);