From 761b974aaf8f3f013b570a801f29100552c546ea Mon Sep 17 00:00:00 2001 From: kenstir Date: Thu, 3 Dec 2015 20:58:36 -0500 Subject: [PATCH] Use volley for search results and record details. OMG is it faster. Way faster. --- .../res/layout/record_details_basic_fragment.xml | 3 +-- .../Android/core/res/layout/search_result_item.xml | 3 +-- .../evergreen_ils/accountAccess/AccountUtils.java | 3 +-- .../evergreen_ils/auth/AccountAuthenticator.java | 2 -- .../evergreen_ils/auth/AuthenticatorActivity.java | 4 +--- .../org/evergreen_ils/globals/GlobalConfigs.java | 1 + .../org/evergreen_ils/searchCatalog/Library.java | 23 ---------------------- .../searchCatalog/SearchCatalogListView.java | 17 ++++++++-------- .../utils/ui/BasicDetailsFragment.java | 18 +++++++++-------- .../views/splashscreen/LoadingTask.java | 5 +---- 10 files changed, 25 insertions(+), 54 deletions(-) delete mode 100644 Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/Library.java diff --git a/Open-ILS/src/Android/core/res/layout/record_details_basic_fragment.xml b/Open-ILS/src/Android/core/res/layout/record_details_basic_fragment.xml index 174c8626b5..a77501f913 100644 --- a/Open-ILS/src/Android/core/res/layout/record_details_basic_fragment.xml +++ b/Open-ILS/src/Android/core/res/layout/record_details_basic_fragment.xml @@ -72,11 +72,10 @@ /> - diff --git a/Open-ILS/src/Android/core/res/layout/search_result_item.xml b/Open-ILS/src/Android/core/res/layout/search_result_item.xml index d4b1eab060..a8fbf95b28 100644 --- a/Open-ILS/src/Android/core/res/layout/search_result_item.xml +++ b/Open-ILS/src/Android/core/res/layout/search_result_item.xml @@ -10,12 +10,11 @@ android:background="@color/background" > - diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountUtils.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountUtils.java index 8a3e88cd7f..b9a3b255e0 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountUtils.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountUtils.java @@ -8,8 +8,7 @@ import android.text.TextUtils; import android.util.Log; import org.evergreen_ils.R; import org.evergreen_ils.auth.Const; -import org.evergreen_ils.searchCatalog.Library; -import org.w3c.dom.Text; +import org.evergreen_ils.globals.Library; import java.io.IOException; diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AccountAuthenticator.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AccountAuthenticator.java index 658260c5fe..2cf9211e07 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AccountAuthenticator.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AccountAuthenticator.java @@ -10,8 +10,6 @@ import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; -import org.evergreen_ils.searchCatalog.Library; -import org.w3c.dom.Text; public class AccountAuthenticator extends AbstractAccountAuthenticator { diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java index af4216226e..61d7de78fb 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java @@ -1,6 +1,5 @@ package org.evergreen_ils.auth; -import android.app.DownloadManager; import android.content.Context; import android.content.pm.ApplicationInfo; import android.location.Location; @@ -30,9 +29,8 @@ import android.view.View; import android.widget.TextView; import org.evergreen_ils.accountAccess.AccountUtils; import org.evergreen_ils.globals.AppPrefs; -import org.evergreen_ils.globals.Utils; import org.evergreen_ils.net.VolleyWrangler; -import org.evergreen_ils.searchCatalog.Library; +import org.evergreen_ils.globals.Library; import org.opensrf.util.JSONException; import org.opensrf.util.JSONReader; diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java index 6f3794d5d4..e4dc5fb63c 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java @@ -167,6 +167,7 @@ public class GlobalConfigs { } }, null); + Log.d(TAG, "volley queuing request"); q.add(stringRequest); } diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/Library.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/Library.java deleted file mode 100644 index 648f0af21e..0000000000 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/Library.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.evergreen_ils.searchCatalog; - -import android.location.Location; -import android.text.TextUtils; - -/** value class - * Created by kenstir on 11/5/2015. - */ -public class Library { - public String url; // e.g. "https://catalog.cwmars.org" - public String name; // e.g. "C/W MARS" - public String directory_name; // e.g. "Massachusetts, US (C/W MARS)" - public Location location; - public Library(String url, String name, String directory_name, Location location) { - this.url = url; - this.name = name; - this.directory_name = directory_name; - this.location = location; - } - public Library(String url, String name) { - this(url, name, null, null); - } -} diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java index c5461a41f6..06c2dedc86 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java @@ -23,6 +23,8 @@ import java.util.*; import android.support.v7.app.ActionBarActivity; import android.view.*; +import com.android.volley.toolbox.ImageLoader; +import com.android.volley.toolbox.NetworkImageView; import org.evergreen_ils.R; import org.evergreen_ils.accountAccess.AccountAccess; import org.evergreen_ils.accountAccess.SessionNotFoundException; @@ -30,6 +32,7 @@ import org.evergreen_ils.accountAccess.bookbags.BookBag; import org.evergreen_ils.accountAccess.holds.PlaceHold; import org.evergreen_ils.barcodescan.CaptureActivity; import org.evergreen_ils.globals.GlobalConfigs; +import org.evergreen_ils.net.VolleyWrangler; import org.evergreen_ils.utils.ui.ActionBarUtils; import org.evergreen_ils.views.splashscreen.SplashActivity; @@ -651,7 +654,7 @@ public class SearchCatalogListView extends ActionBarActivity { private static final String tag = "SearchArrayAdapter"; private Context context; - private ImageView recordImage; + private NetworkImageView recordImage; private TextView recordTitle; private TextView recordAuthor; private TextView recordFormat; @@ -689,13 +692,11 @@ public class SearchCatalogListView extends ActionBarActivity { false); } - // Get reference to ImageView - recordImage = (ImageView) row.findViewById(R.id.search_record_img); - String imageHref = GlobalConfigs.getUrl("/opac/extras/ac/jacket/small/r/" + record.doc_id); - //Log.d(TAG, "image url " + imageHref); - - // start async download of image - imageDownloader.download(imageHref, recordImage); + // Start async image load + recordImage = (NetworkImageView) row.findViewById(R.id.search_record_img); + final String imageHref = GlobalConfigs.getUrl("/opac/extras/ac/jacket/small/r/" + record.doc_id); + ImageLoader imageLoader = VolleyWrangler.getInstance(context).getImageLoader(); + recordImage.setImageUrl(imageHref, imageLoader); recordTitle = (TextView) row.findViewById(R.id.search_record_title); recordAuthor = (TextView) row.findViewById(R.id.search_record_author); diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/utils/ui/BasicDetailsFragment.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/utils/ui/BasicDetailsFragment.java index 1bead8742b..d4b7121df9 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/utils/ui/BasicDetailsFragment.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/utils/ui/BasicDetailsFragment.java @@ -25,12 +25,15 @@ import java.util.Map.Entry; import java.util.Set; import android.util.Log; +import com.android.volley.toolbox.ImageLoader; +import com.android.volley.toolbox.NetworkImageView; import org.evergreen_ils.R; import org.evergreen_ils.accountAccess.AccountAccess; import org.evergreen_ils.accountAccess.SessionNotFoundException; import org.evergreen_ils.accountAccess.bookbags.BookBag; import org.evergreen_ils.accountAccess.holds.PlaceHold; import org.evergreen_ils.globals.GlobalConfigs; +import org.evergreen_ils.net.VolleyWrangler; import org.evergreen_ils.searchCatalog.*; import android.app.Dialog; @@ -95,7 +98,7 @@ public class BasicDetailsFragment extends Fragment { private final ImageDownloader imageDownloader = new ImageDownloader(); - private ImageView recordImage; + private NetworkImageView recordImage; // max display info private int list_size = 3; @@ -153,7 +156,7 @@ 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); + recordImage = (NetworkImageView) 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); @@ -169,14 +172,13 @@ public class BasicDetailsFragment extends Fragment { } }); - //String imageHref = GlobalConfigs.getUrl("/opac/extras/ac/jacket/large/r/" + record.doc_id); - String imageHref = GlobalConfigs.getUrl("/opac/extras/ac/jacket/medium/r/" + record.doc_id); - - // start async download of image - imageDownloader.download(imageHref, recordImage); + // Start async image load + //final String imageHref = GlobalConfigs.getUrl("/opac/extras/ac/jacket/large/r/" + record.doc_id); + final String imageHref = GlobalConfigs.getUrl("/opac/extras/ac/jacket/medium/r/" + record.doc_id); + ImageLoader imageLoader = VolleyWrangler.getInstance(getActivity()).getImageLoader(); + recordImage.setImageUrl(imageHref, imageLoader); AccountAccess ac = AccountAccess.getAccountAccess(); - bookBags = ac.getBookbags(); String array_spinner[] = new String[bookBags.size()]; diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/LoadingTask.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/LoadingTask.java index 90cf5dcf16..39d8b1e4d5 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/LoadingTask.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/LoadingTask.java @@ -31,10 +31,7 @@ import android.accounts.AccountManager; import android.app.Activity; import android.os.Bundle; import android.util.Log; -import org.evergreen_ils.searchCatalog.Library; -import org.opensrf.util.OSRFObject; - -import java.util.Map; +import org.evergreen_ils.globals.Library; /** This is basically the same as an AsyncTask, except that it uses * a Thread. Starting with HONEYCOMB, tasks are executed on a single thread and the 2nd -- 2.11.0