image download fixed
authordrizea <danielrizea27@gmail.com>
Tue, 31 Jul 2012 10:11:43 +0000 (13:11 +0300)
committerdrizea <danielrizea27@gmail.com>
Tue, 31 Jul 2012 10:11:43 +0000 (13:11 +0300)
Open-ILS/src/Android/res/layout/record_details_basic_fragment.xml
Open-ILS/src/Android/res/layout/search_result_item.xml
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/ImageDownloader.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java
Open-ILS/src/Android/src/org/evergreen/android/utils/ui/BasicDetailsFragment.java

index b994b54..5b001cf 100644 (file)
                 </LinearLayout>
                 
                 <ImageView 
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
+                    android:id="@+id/record_details_simple_image"
+                    android:layout_width="140dip"
+                    android:layout_height="180dip"
                     android:src="@drawable/no_image"
                     android:layout_marginRight="5dip"
                     android:layout_marginBottom="5dip"
+                    android:padding="5dip"
+                    android:background="@color/white"
                     />
                 
             </LinearLayout>
index 045d540..2b3270d 100644 (file)
 
        <ImageView
                android:id="@+id/search_record_img"
-               android:layout_width="wrap_content"
-        android:layout_height="fill_parent"
+               android:layout_width="64dip"
+        android:layout_height="96dip"
         android:layout_marginRight="6dip"
-               android:src="@drawable/address_book"/>
+               android:src="@drawable/address_book"
+               android:padding="4dip"
+               />
        
        
        
index 5451405..b8711ca 100644 (file)
@@ -44,6 +44,24 @@ public class ImageDownloader {
    
     private int MIN_IMG_HEIGHT = 75;
     
+    private int bitmap_width;
+    private int bitmap_height;
+    private boolean scale;
+    
+    public ImageDownloader(int min_img_height){
+       
+       MIN_IMG_HEIGHT = min_img_height;
+    }
+    
+    public ImageDownloader(){
+       
+    }
+    
+    public ImageDownloader(int w, int h, boolean scale){
+       this.bitmap_height = h;
+       this.bitmap_width = w;
+       this.scale = scale;
+    }
     /**
      * Download the specified image from the Internet and binds it to the provided ImageView. The
      * binding is immediate if the image is found in the cache and will be done asynchronously
@@ -269,12 +287,18 @@ public class ImageDownloader {
                 // Change bitmap only if this process is still associated with it
                 // Or if we don't use any bitmap to task association (NO_DOWNLOADED_DRAWABLE mode)
                 if ((this == bitmapDownloaderTask) || (mode != Mode.CORRECT)) {
-                       imageView.setImageBitmap(bitmap);
+                       Bitmap newScaledBitmap = null;
+                       if(bitmap != null && scale == true){
+                               newScaledBitmap = Bitmap.createScaledBitmap(bitmap, bitmap_width, bitmap_height, true);
+                               imageView.setImageBitmap(newScaledBitmap);
+                       }else{
+                               imageView.setImageBitmap(bitmap);
+                       }
                 }   
 
                 if(bitmap == null){
                        if(imageView != null)
-                               imageView.setImageResource(R.drawable.address_book);
+                               imageView.setImageResource(R.drawable.no_image);
                 }
             }
 
index f2cb753..a60c581 100644 (file)
@@ -650,28 +650,28 @@ public class SearchCatalogListView extends Activity{
                                                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 
-               imageDownloader.download(imageHref, recordImage);
-               // Get reference to TextView - title
-               recordTitle = (TextView) row.findViewById(R.id.search_record_title);
-               
-               // Get reference to TextView - author
-               recordAuthor = (TextView) row.findViewById(R.id.search_record_author);
-
-               //Get referance to TextView - record Publisher date+publisher
-               recordPublisher = (TextView) row.findViewById(R.id.search_record_publishing);
-    
-               //set text
-               
-               recordTitle.setText(record.title);
-               recordAuthor.setText(record.author);
-               recordPublisher.setText(record.pubdate + " " + record.publisher);
+                                       
+                       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 
+                       imageDownloader.download(imageHref, recordImage);
+                       // Get reference to TextView - title
+                       recordTitle = (TextView) row.findViewById(R.id.search_record_title);
+                       
+                       // Get reference to TextView - author
+                       recordAuthor = (TextView) row.findViewById(R.id.search_record_author);
+       
+                       //Get referance to TextView - record Publisher date+publisher
+                       recordPublisher = (TextView) row.findViewById(R.id.search_record_publishing);
+           
+                       //set text
+                       
+                       recordTitle.setText(record.title);
+                       recordAuthor.setText(record.author);
+                       recordPublisher.setText(record.pubdate + " " + record.publisher);
                }               
                return row;
        }
index 2a10eea..515e9a3 100644 (file)
@@ -14,12 +14,14 @@ import org.evergreen.android.globals.GlobalConfigs;
 import org.evergreen.android.globals.NoAccessToServer;
 import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.searchCatalog.CopyInformation;
+import org.evergreen.android.searchCatalog.ImageDownloader;
 import org.evergreen.android.searchCatalog.RecordInfo;
 import org.evergreen.android.searchCatalog.SearchCatalog;
 
 import android.app.Dialog;
 import android.app.ProgressDialog;
 import android.content.Intent;
+import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.view.LayoutInflater;
@@ -31,6 +33,7 @@ import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
+import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.Spinner;
 import android.widget.TextView;
@@ -73,7 +76,10 @@ public class BasicDetailsFragment extends Fragment{
        private Dialog dialog;
        
        private ArrayList<BookBag> bookBags;
+       
+       private final ImageDownloader imageDownloader = new ImageDownloader();
 
+       private ImageView recordImage;
        //max display info
        private int list_size = 3;
        
@@ -129,6 +135,8 @@ public class BasicDetailsFragment extends Fragment{
                        synopsisTextView = (TextView) layout.findViewById(R.id.record_details_simple_synopsis);
                        isbnTextView = (TextView) layout.findViewById(R.id.record_details_simple_isbn);
 
+                       recordImage = (ImageView) layout.findViewById(R.id.record_details_simple_image);
+                       
                placeHoldButton = (Button) layout.findViewById(R.id.simple_place_hold_button);
                addToBookbagButton = (Button) layout.findViewById(R.id.simple_add_to_bookbag_button);
 
@@ -142,6 +150,12 @@ public class BasicDetailsFragment extends Fragment{
                                }
                        });
 
+               String imageHref = GlobalConfigs.httpAddress + "/opac/extras/ac/jacket/large/"+record.isbn;
+
+               //start async download of image 
+               imageDownloader.download(imageHref, recordImage);
+               
+               
                        AccountAccess ac = AccountAccess.getAccountAccess();
 
                        bookBags = ac.bookBags;