Bug 1299224 - pass OnUrlOpenListener into StreamRecyclerAdapter r=sebastian

This has the side effect of enabling click support for topsites.

MozReview-Commit-ID: DW7WX4QDO6n

--HG--
extra : histedit_source : 841fa42364397965d237c36540afc20a86bb2922
This commit is contained in:
Andrzej Hunt 2016-08-31 12:53:46 -07:00
parent b635c55c15
commit f0f7b67705
3 changed files with 11 additions and 3 deletions

View File

@ -16,6 +16,7 @@ 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;
@ -39,6 +40,10 @@ public class ActivityStream extends FrameLayout {
rv.setHasFixedSize(true);
}
void setOnUrlOpenListener(HomePager.OnUrlOpenListener listener) {
adapter.setOnUrlOpenListener(listener);
}
public void load(LoaderManager lm) {
CursorLoaderCallbacks callbacks = new CursorLoaderCallbacks();

View File

@ -29,7 +29,10 @@ public class ActivityStreamHomeFragment
@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;
}

View File

@ -22,9 +22,9 @@ 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;
}