From fce20769ed5189b739e0e2ea6c4df283dc8f2b20 Mon Sep 17 00:00:00 2001 From: drizea Date: Fri, 15 Jun 2012 16:34:32 +0300 Subject: [PATCH] added more results list element at the end of the search result list --- .../res/drawable/expander_ic_maximized.9.png | Bin 0 -> 2081 bytes .../res/layout/search_result_footer_view.xml | 18 +++ .../src/Android/res/layout/search_result_list.xml | 18 ++- Open-ILS/src/Android/res/values/colors.xml | 1 + Open-ILS/src/Android/res/values/strings.xml | 2 +- .../android/searchCatalog/ImageDownloader.java | 27 +++- .../android/searchCatalog/RecordInfo.java | 13 +- .../android/searchCatalog/SearchCatalog.java | 19 ++- .../searchCatalog/SearchCatalogListView.java | 144 ++++++++++++++++++--- 9 files changed, 209 insertions(+), 33 deletions(-) create mode 100644 Open-ILS/src/Android/res/drawable/expander_ic_maximized.9.png create mode 100644 Open-ILS/src/Android/res/layout/search_result_footer_view.xml 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 0000000000000000000000000000000000000000..bad4b82026559d9e8aa7825101a83a15207c23e5 GIT binary patch literal 2081 zcmV++2;TRJP)tdT-6oEe|w+HcoKW;n3Ry%5p4MHKN_g7qY+3F>IdG_oWyLSDJW5C?Q-9gDYuA%N3OJ>dU+Ae|5pW^Uwt4gB zCp#*gzZdVLjT<-8-``Jrd&fnCs=d9P4I4Hves-MU;bEKB(R4RWIk*-^By_JU_e)wCbWZ(KeM#n}ue&TolvaY+kdw67Ih&en$>!a0X^4(B}9gLA%dUfj3mp1TX)-@0`x^?Ds^&0W`AbIlznwndl()bW_oH0V-42iIOn+e=9{V2=E!q%eE}pA5!K2-(>1!d zE@xS`&S=e=HEYQ891uhlQ&W>1J$jV=`}cFtJ@^u|R}_pmlBCYj zqet1hcQ09%@$$({U6%{SkqTCL)o?q=; zF&}y45v;Xjxj`$1$uqq7t#*UOg0-17fwgYdImf9}BUo#3&SI^lqtd}se|m~2ib#@# z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ml 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; } } -- 2.11.0