From: drizea Date: Fri, 15 Jun 2012 13:34:32 +0000 (+0300) Subject: added more results list element at the end of the search result list X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fce20769ed5189b739e0e2ea6c4df283dc8f2b20;p=working%2FEvergreen.git added more results list element at the end of the search result list --- diff --git a/Open-ILS/src/Android/res/drawable/expander_ic_maximized.9.png b/Open-ILS/src/Android/res/drawable/expander_ic_maximized.9.png new file mode 100644 index 0000000000..bad4b82026 Binary files /dev/null and b/Open-ILS/src/Android/res/drawable/expander_ic_maximized.9.png differ diff --git a/Open-ILS/src/Android/res/layout/search_result_footer_view.xml b/Open-ILS/src/Android/res/layout/search_result_footer_view.xml new file mode 100644 index 0000000000..0ed6c7701c --- /dev/null +++ b/Open-ILS/src/Android/res/layout/search_result_footer_view.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/Android/res/layout/search_result_list.xml b/Open-ILS/src/Android/res/layout/search_result_list.xml index 2c1e7599bd..c8969f1a6c 100644 --- a/Open-ILS/src/Android/res/layout/search_result_list.xml +++ b/Open-ILS/src/Android/res/layout/search_result_list.xml @@ -32,6 +32,22 @@ + + + + + + diff --git a/Open-ILS/src/Android/res/values/colors.xml b/Open-ILS/src/Android/res/values/colors.xml index 5f326a2352..9f562e4452 100644 --- a/Open-ILS/src/Android/res/values/colors.xml +++ b/Open-ILS/src/Android/res/values/colors.xml @@ -33,4 +33,5 @@ #cecbce #ffffff + #1e90ff diff --git a/Open-ILS/src/Android/res/values/strings.xml b/Open-ILS/src/Android/res/values/strings.xml index 9ea23bdc42..e60cab9168 100644 --- a/Open-ILS/src/Android/res/values/strings.xml +++ b/Open-ILS/src/Android/res/values/strings.xml @@ -11,5 +11,5 @@ Holds Fines Book bags - + Search result : \ No newline at end of file diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/ImageDownloader.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/ImageDownloader.java index 66ea35c5e6..48b4f1e33e 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/ImageDownloader.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/ImageDownloader.java @@ -42,7 +42,7 @@ public class ImageDownloader { public enum Mode { NO_ASYNC_TASK, NO_DOWNLOADED_DRAWABLE, CORRECT } private Mode mode = Mode.CORRECT; - private int MIN_IMG_HEIGHT = 100; + private int MIN_IMG_HEIGHT = 75; /** * Download the specified image from the Internet and binds it to the provided ImageView. The @@ -151,8 +151,17 @@ public class ImageDownloader { // AndroidHttpClient is not allowed to be used from the main thread final HttpClient client = (mode == Mode.NO_ASYNC_TASK) ? new DefaultHttpClient() : AndroidHttpClient.newInstance("Android"); - final HttpGet getRequest = new HttpGet(url); - + + HttpGet getRequest = null; + try{ + getRequest = new HttpGet(url); + }catch(Exception e){ + if ((client instanceof AndroidHttpClient)) { + ((AndroidHttpClient) client).close(); + } + return null; + } + try { HttpResponse response = client.execute(getRequest); final int statusCode = response.getStatusLine().getStatusCode(); @@ -251,7 +260,9 @@ public class ImageDownloader { } addBitmapToCache(url, bitmap); + + if (imageViewReference != null) { ImageView imageView = imageViewReference.get(); BitmapDownloaderTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView); @@ -259,10 +270,14 @@ public class ImageDownloader { // Or if we don't use any bitmap to task association (NO_DOWNLOADED_DRAWABLE mode) if ((this == bitmapDownloaderTask) || (mode != Mode.CORRECT)) { imageView.setImageBitmap(bitmap); + } + + if(bitmap == null){ + if(imageView != null) + imageView.setImageResource(R.drawable.address_book); } - else - imageView.setImageResource(R.drawable.address_book); } + } } @@ -302,7 +317,7 @@ public class ImageDownloader { * Garbage Collector. */ - private static final int HARD_CACHE_CAPACITY = 10; + private static final int HARD_CACHE_CAPACITY = 20; private static final int DELAY_BEFORE_PURGE = 10 * 1000; // in milliseconds // Hard cache, with a fixed maximum capacity and a life duration diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordInfo.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordInfo.java index f18c1e62b5..4ebbdd0be1 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordInfo.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/RecordInfo.java @@ -42,11 +42,20 @@ public class RecordInfo implements Serializable{ //tcn field public String image = null; + public boolean dummy = false; + + public RecordInfo(){ + this.title = "Test title"; + this.author = "Test author"; + this.pubdate = "Publication date"; + + //marks the fact that this is a record made from no info + this.dummy = true; + } public RecordInfo(OSRFObject info){ try{ - - + this.title = info.getString("title"); this.author = info.getString("author"); this.pubdate = info.getString("pubdate"); diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java index 5fd6c74aef..ea490a38f8 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalog.java @@ -46,6 +46,13 @@ public class SearchCatalog { private Organisation selectedOrganization = null; private Context context; + + public Integer offset; + + public Integer visible; + + public Integer searchLimit = 10; + /** * Instantiates a new search catalog. * @@ -72,11 +79,11 @@ public class SearchCatalog { /** * Gets the search results - * + * * @param searchWords the search words * @return the search results */ - public ArrayList getSearchResults(String searchWords){ + public ArrayList getSearchResults(String searchWords, Integer offset){ ArrayList resultsRecordInfo = new ArrayList(); @@ -94,7 +101,9 @@ public class SearchCatalog { complexParm.put("depth", this.selectedOrganization.level-1); } //TODO change here, multiple result per page - complexParm.put("limit", 50); + complexParm.put("limit", searchLimit); + + complexParm.put("offset",offset); /* complexParm.put("offset",0); @@ -112,6 +121,7 @@ public class SearchCatalog { method.addParam(searchWords); method.addParam(1); + // sync test HttpRequest req = new GatewayRequest(conn, SERVICE, method).send(); Object resp; @@ -120,6 +130,7 @@ public class SearchCatalog { ArrayList ids = new ArrayList(); + while ( (resp = req.recv()) != null){ System.out.println("Sync Response: " + resp); @@ -128,6 +139,8 @@ public class SearchCatalog { System.out.println(" ids : " + response.get("ids") + " " ); List> result_ids = (List) response.get("ids"); + + visible =Integer.parseInt((String)response.get("count")); for(int i=0;i0){ + + //remove previous more button + recordList.remove(recordList.size()-1); + + for(int j=0;j recordList.size()){ + recordList.add(new RecordInfo()); + searchResultsNumber.setText(adapter.getCount()-1 +" out of "+search.visible); + } + else + searchResultsNumber.setText(adapter.getCount() +" out of "+search.visible); + } + else{ + searchResultsNumber.setText(adapter.getCount() +" out of "+search.visible); + } + adapter.notifyDataSetChanged(); + progressDialog.dismiss(); + } + }); + + } + }); + + searchThreadwithOffset.start(); + } + else{ + //start activity with book details + + Intent intent = new Intent(getBaseContext(),RecordDetails_Simple.class); + //serialize object and pass it to next activity + intent.putExtra("recordInfo", info); + + startActivity(intent); + } } }); @@ -133,7 +207,7 @@ public class SearchCatalogListView extends Activity{ @Override public void run() { - searchResults = search.getSearchResults(text); + searchResults = search.getSearchResults(text,0); runOnUiThread(new Runnable() { @@ -145,10 +219,22 @@ public class SearchCatalogListView extends Activity{ for(int j=0;j recordList.size()){ + recordList.add(new RecordInfo()); + searchResultsNumber.setText(recordList.size()-1 +" out of "+search.visible); + } + else + searchResultsNumber.setText(recordList.size() +" out of "+search.visible); } + else + searchResultsNumber.setText(recordList.size() +" out of "+search.visible); + adapter.notifyDataSetChanged(); progressDialog.dismiss(); + } }); @@ -264,21 +350,38 @@ public class SearchCatalogListView extends Activity{ public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; - if (row == null) { - // ROW INFLATION - Log.d(tag, "Starting XML Row Inflation ... "); + + // Get item + RecordInfo record = getItem(position); + + if(record.dummy == true) + { + Log.d(tag, "Starting XML view more infaltion ... "); LayoutInflater inflater = (LayoutInflater) this.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - row = inflater.inflate(R.layout.search_result_item, parent, false); - Log.d(tag, "Successfully completed XML Row Inflation!"); - } + row = inflater.inflate(R.layout.search_result_footer_view, parent, false); + Log.d(tag, "Successfully completed XML view more Inflation!"); - // Get item - RecordInfo record = getItem(position); + + } + else{ + //if it is the right type of view + if (row == null || row.findViewById(R.id.search_record_title) == null) { + + Log.d(tag, "Starting XML Row Inflation ... "); + LayoutInflater inflater = (LayoutInflater) this.getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + row = inflater.inflate(R.layout.search_result_item, parent, false); + Log.d(tag, "Successfully completed XML Row Inflation!"); + + } + + + + Log.d(TAG, "reord image value " + recordImage); // Get reference to ImageView recordImage = (ImageView) row.findViewById(R.id.search_record_img); - //TODO fix bugs + features String imageHref= GlobalConfigs.httpAddress + "/opac/extras/ac/jacket/small/"+record.isbn; //start async download of image @@ -297,7 +400,8 @@ public class SearchCatalogListView extends Activity{ recordTitle.setText(record.title); recordAuthor.setText(record.author); recordPublisher.setText(record.pubdate + " " + record.publisher); - + } + return row; } }