Minor changes from code inspection results
[zxing.git] / android / src / com / google / zxing / client / android / book / SearchBookContentsActivity.java
index 9376989..1bfecc2 100644 (file)
@@ -60,7 +60,8 @@ import com.google.zxing.client.android.AndroidHttpClient;
  */
 public final class SearchBookContentsActivity extends Activity {
 
-  private static final String TAG = "SearchBookContents";
+  private static final String TAG = SearchBookContentsActivity.class.getSimpleName();
+
   private static final String USER_AGENT = "ZXing (Android)";
   private static final Pattern TAG_PATTERN = Pattern.compile("\\<.*?\\>");
   private static final Pattern LT_ENTITY_PATTERN = Pattern.compile("&lt;");
@@ -198,7 +199,7 @@ public final class SearchBookContentsActivity extends Activity {
         for (int x = 0; x < count; x++) {
           items.add(parseResult(results.getJSONObject(x)));
         }
-             resultListView.setOnItemClickListener(new BrowseBookListener(this, items));
+        resultListView.setOnItemClickListener(new BrowseBookListener(this, items));
         resultListView.setAdapter(new SearchBookContentsAdapter(this, items));
       } else {
         String searchable = json.optString("searchable");
@@ -208,7 +209,7 @@ public final class SearchBookContentsActivity extends Activity {
         resultListView.setAdapter(null);
       }
     } catch (JSONException e) {
-      Log.e(TAG, e.toString());
+      Log.w(TAG, "Bad JSON from book search", e);
       resultListView.setAdapter(null);
       headerView.setText(R.string.msg_sbc_failed);
     }
@@ -242,7 +243,7 @@ public final class SearchBookContentsActivity extends Activity {
       return new SearchBookContentsResult(pageId, pageNumber, snippet, valid);
     } catch (JSONException e) {
       // Never seen in the wild, just being complete.
-           return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false);
+      return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false);
     }
   }
 
@@ -266,7 +267,7 @@ public final class SearchBookContentsActivity extends Activity {
         // website, we don't use LocaleManager to change the TLD.
         URI uri;
         if (isbn.startsWith("http://google.com/books?id=")) {
-               int equals = isbn.indexOf('=');
+          int equals = isbn.indexOf('=');
           String volumeId = isbn.substring(equals + 1);
           uri = new URI("http", null, "www.google.com", -1, "/books", "id=" + volumeId +
                         "&jscmd=SearchWithinVolume2&q=" + query, null);
@@ -290,12 +291,12 @@ public final class SearchBookContentsActivity extends Activity {
           message.obj = json;
           message.sendToTarget();
         } else {
-          Log.e(TAG, "HTTP returned " + response.getStatusLine().getStatusCode() + " for " + uri);
+          Log.w(TAG, "HTTP returned " + response.getStatusLine().getStatusCode() + " for " + uri);
           Message message = Message.obtain(handler, R.id.search_book_contents_failed);
           message.sendToTarget();
         }
       } catch (Exception e) {
-        Log.e(TAG, e.toString());
+        Log.w(TAG, "Error accessing book search", e);
         Message message = Message.obtain(handler, R.id.search_book_contents_failed);
         message.sendToTarget();
       } finally {
@@ -311,7 +312,7 @@ public final class SearchBookContentsActivity extends Activity {
     private static String getCookie(String url) {
       String cookie = CookieManager.getInstance().getCookie(url);
       if (cookie == null || cookie.length() == 0) {
-        Log.v(TAG, "Book Search cookie was missing or expired");
+        Log.d(TAG, "Book Search cookie was missing or expired");
         HttpUriRequest head = new HttpHead(url);
         AndroidHttpClient client = AndroidHttpClient.newInstance(USER_AGENT);
         try {
@@ -325,7 +326,7 @@ public final class SearchBookContentsActivity extends Activity {
             cookie = CookieManager.getInstance().getCookie(url);
           }
         } catch (IOException e) {
-          Log.e(TAG, e.toString());
+          Log.w(TAG, "Error setting book search cookie", e);
         }
         client.close();
       }