Bug 1299224 - pass OnUrlOpenListener into StreamRecyclerAdapter r=sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 31 Aug 2016 12:53:46 -0700
changeset 353754 3d376f300eac2ed52d331a47b4608c7719013bae
parent 353753 35b31a0d906aa6d618feb11592aaa5aec924db49
child 353755 4f8bafdd88dc6cfdb5b5fe074dfb5d1abdb2f20c
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1299224
milestone51.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 1299224 - pass OnUrlOpenListener into StreamRecyclerAdapter r=sebastian This has the side effect of enabling click support for topsites. MozReview-Commit-ID: DW7WX4QDO6n
mobile/android/base/java/org/mozilla/gecko/home/activitystream/ActivityStream.java
mobile/android/base/java/org/mozilla/gecko/home/activitystream/ActivityStreamHomeFragment.java
mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamRecyclerAdapter.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/ActivityStream.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/ActivityStream.java
@@ -11,16 +11,17 @@ import android.support.v4.app.LoaderMana
 import android.support.v4.content.Loader;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.util.AttributeSet;
 import android.widget.FrameLayout;
 
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.R;
+import org.mozilla.gecko.home.HomePager;
 import org.mozilla.gecko.home.SimpleCursorLoader;
 import org.mozilla.gecko.home.activitystream.topsites.TopSitesPagerAdapter;
 
 public class ActivityStream extends FrameLayout {
     private final StreamRecyclerAdapter adapter;
 
     private static final int LOADER_ID_HIGHLIGHTS = 0;
     private static final int LOADER_ID_TOPSITES = 1;
@@ -34,16 +35,20 @@ public class ActivityStream extends Fram
 
         RecyclerView rv = (RecyclerView) findViewById(R.id.activity_stream_main_recyclerview);
 
         rv.setAdapter(adapter);
         rv.setLayoutManager(new LinearLayoutManager(getContext()));
         rv.setHasFixedSize(true);
     }
 
+    void setOnUrlOpenListener(HomePager.OnUrlOpenListener listener) {
+        adapter.setOnUrlOpenListener(listener);
+    }
+
     public void load(LoaderManager lm) {
         CursorLoaderCallbacks callbacks = new CursorLoaderCallbacks();
 
         lm.initLoader(LOADER_ID_HIGHLIGHTS, null, callbacks);
         lm.initLoader(LOADER_ID_TOPSITES, null, callbacks);
     }
 
     public void unload() {
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/ActivityStreamHomeFragment.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/ActivityStreamHomeFragment.java
@@ -24,13 +24,16 @@ public class ActivityStreamHomeFragment
     protected void load() {
         activityStream.load(getLoaderManager());
     }
 
     @Nullable
     @Override
     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                              @Nullable Bundle savedInstanceState) {
-        activityStream = (ActivityStream) inflater.inflate(R.layout.activity_stream, container, false);
+        if (activityStream == null) {
+            activityStream = (ActivityStream) inflater.inflate(R.layout.activity_stream, container, false);
+            activityStream.setOnUrlOpenListener(mUrlOpenListener);
+        }
 
         return activityStream;
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamRecyclerAdapter.java
@@ -17,19 +17,19 @@ import org.mozilla.gecko.home.activityst
 import org.mozilla.gecko.home.activitystream.StreamItem.TopPanel;
 
 import java.lang.ref.WeakReference;
 
 public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamItem> {
     private Cursor highlightsCursor;
     private Cursor topSitesCursor;
 
-    private final HomePager.OnUrlOpenListener onUrlOpenListener;
+    private HomePager.OnUrlOpenListener onUrlOpenListener;
 
-    StreamRecyclerAdapter(HomePager.OnUrlOpenListener onUrlOpenListener) {
+    void setOnUrlOpenListener(HomePager.OnUrlOpenListener onUrlOpenListener) {
         this.onUrlOpenListener = onUrlOpenListener;
     }
 
     @Override
     public int getItemViewType(int position) {
         if (position == 0) {
             return TopPanel.LAYOUT_ID;
         } else if (position == getItemCount() - 1) {