Bug 884398 - Use private/anonymous listener for item clicks in BrowserSearch (r=bnicholson)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 25 Jun 2013 17:51:57 +0100
changeset 151337 dff89eb24573650c47235051a3a93692a69a19d5
parent 151336 3561c794b2e4f880411672a4d3fcab0f5582f537
child 151338 c6c7f52d4ce75495018f1d3d1996d8c8355cd50f
push idunknown
push userunknown
push dateunknown
reviewersbnicholson
bugs884398
milestone24.0a1
Bug 884398 - Use private/anonymous listener for item clicks in BrowserSearch (r=bnicholson)
mobile/android/base/BrowserSearch.java
--- a/mobile/android/base/BrowserSearch.java
+++ b/mobile/android/base/BrowserSearch.java
@@ -45,18 +45,17 @@ import android.widget.SimpleCursorAdapte
 import android.widget.TextView;
 
 import java.util.ArrayList;
 
 /**
  * Fragment that displays frecency search results in a ListView.
  */
 public class BrowserSearch extends HomeFragment
-                           implements AdapterView.OnItemClickListener,
-                                      GeckoEventListener {
+                           implements GeckoEventListener {
     // Logging tag name
     private static final String LOGTAG = "GeckoBrowserSearch";
 
     // Cursor loader ID for search query
     private static final int SEARCH_LOADER_ID = 0;
 
     // Cursor loader ID for favicons query
     private static final int FAVICONS_LOADER_ID = 1;
@@ -190,17 +189,29 @@ public class BrowserSearch extends HomeF
         mList = new HomeListView(container.getContext());
         return mList;
     }
 
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
-        mList.setOnItemClickListener(this);
+        mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+                final Cursor c = mAdapter.getCursor();
+                if (c == null || !c.moveToPosition(position)) {
+                    return;
+                }
+
+                final String url = c.getString(c.getColumnIndexOrThrow(URLColumns.URL));
+                mUrlOpenListener.onUrlOpen(url);
+            }
+        });
+
         registerForContextMenu(mList);
     }
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
 
         // Intialize the search adapter
@@ -299,27 +310,16 @@ public class BrowserSearch extends HomeF
     private void registerEventListener(String eventName) {
         GeckoAppShell.getEventDispatcher().registerEventListener(eventName, this);
     }
 
     private void unregisterEventListener(String eventName) {
         GeckoAppShell.getEventDispatcher().unregisterEventListener(eventName, this);
     }
 
-    @Override
-    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-        final Cursor c = mAdapter.getCursor();
-        if (c == null || !c.moveToPosition(position)) {
-            return;
-        }
-
-        final String url = c.getString(c.getColumnIndexOrThrow(URLColumns.URL));
-        mUrlOpenListener.onUrlOpen(url);
-    }
-
     public void filter(String searchTerm) {
         if (TextUtils.isEmpty(searchTerm)) {
             return;
         }
 
         if (TextUtils.equals(mSearchTerm, searchTerm)) {
             return;
         }