Bug 996850 - Part 1: Don't show context menu for empty sites. r=lucasr
authorChenxia Liu <liuche@mozilla.com>
Tue, 22 Apr 2014 11:09:44 -0700
changeset 198129 a4891371e28e122c257f16bd026a5bc051b4ce13
parent 198107 9916435dfb0097ad79aea876a89ed9e6e1daf079
child 198130 fcd1191c12b5cc2e875111836ce27e747eb8bcf4
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs996850
milestone31.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 996850 - Part 1: Don't show context menu for empty sites. r=lucasr
mobile/android/base/home/TopSitesGridItemView.java
mobile/android/base/home/TopSitesGridView.java
--- a/mobile/android/base/home/TopSitesGridItemView.java
+++ b/mobile/android/base/home/TopSitesGridItemView.java
@@ -103,16 +103,23 @@ public class TopSitesGridItemView extend
     /**
      * @return true, if this view is pinned, false otherwise.
      */
     public boolean isPinned() {
         return mIsPinned;
     }
 
     /**
+     * @return true, if this view has no content to show.
+     */
+    public boolean isEmpty() {
+        return mIsEmpty;
+    }
+
+    /**
      * @param title The title for this view.
      */
     public void setTitle(String title) {
         if (mTitle != null && mTitle.equals(title)) {
             return;
         }
 
         mTitle = title;
--- a/mobile/android/base/home/TopSitesGridView.java
+++ b/mobile/android/base/home/TopSitesGridView.java
@@ -120,17 +120,18 @@ public class TopSitesGridView extends Gr
             }
         });
 
         setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
             @Override
             public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                 Cursor cursor = (Cursor) parent.getItemAtPosition(position);
 
-                if (cursor == null) {
+                TopSitesGridItemView gridView = (TopSitesGridItemView) view;
+                if (cursor == null || gridView.isEmpty()) {
                     mContextMenuInfo = null;
                     return false;
                 }
 
                 mContextMenuInfo = new TopSitesGridContextMenuInfo(view, position, id);
                 updateContextMenuFromCursor(mContextMenuInfo, cursor);
                 return showContextMenuForChild(TopSitesGridView.this);
             }