Bug 900148 - Handle taps on search/suggestion rows. r=lucasr
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Mon, 05 Aug 2013 11:59:49 -0700
changeset 143497 9972d89f09bbf393b238cb2bdd86cba47026801c
parent 143496 2c24acf4816b28a62c3871555c6e3c3e33bdb736
child 143498 3b8b3ae28b70cb3dcd5b31d898416b7292976f0c
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs900148
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 900148 - Handle taps on search/suggestion rows. r=lucasr
mobile/android/base/home/SearchEngineRow.java
--- a/mobile/android/base/home/SearchEngineRow.java
+++ b/mobile/android/base/home/SearchEngineRow.java
@@ -104,16 +104,33 @@ class SearchEngineRow extends AnimatedHe
         mSuggestionView = (FlowLayout) findViewById(R.id.suggestion_layout);
         mIconView = (FaviconView) findViewById(R.id.suggestion_icon);
 
         // User-entered search term is first suggestion
         mUserEnteredView = (LinearLayout) findViewById(R.id.suggestion_user_entered);
         mUserEnteredView.setOnClickListener(mClickListener);
 
         mUserEnteredTextView = (TextView) findViewById(R.id.suggestion_text);
+
+        // Handle clicks on this row that don't happen on individual suggestion views.
+        setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                // Don't do anything if we are showing suggestions.
+                if (mSearchEngine.suggestions.size() > 0) {
+                    return;
+                }
+
+                // Otherwise, perform a search for the user entered term.
+                String searchTerm = getSuggestionTextFromView(mUserEnteredView);
+                if (mSearchListener != null) {
+                    mSearchListener.onSearch(mSearchEngine.name, searchTerm);
+                }
+            }
+        });
     }
 
     private String getSuggestionTextFromView(View v) {
         final TextView suggestionText = (TextView) v.findViewById(R.id.suggestion_text);
         return suggestionText.getText().toString();
     }
 
     private void setSuggestionOnView(View v, String suggestion) {