I have an applet that has a main activity that shows a gridView filled with movie poster images. When you click on an image, an intent that shows additional details about the movie is called. The movie information is downloaded from a movie api and is saved to hard storage via a sqlite database. The gridView is populated via a loader.
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view);
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);
// use a grid layout manager
mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), (returnScreenSize()) ? 2 : numberOfColumns()));
View emptyView = rootView.findViewById(R.id.recyclerview_empty);
mAdapter = new MovieAdapter(getActivity(), new MovieAdapter.MovieOnClickHandler() {
@Override
public void onClick(long id ,MovieAdapter.MovieViewHolder vh, int api) {
((Callback) getActivity())
.onItemSelected(MovieContract.MovieEntry.buildMovieUri(id+1), api);
}
}, emptyView);
// specify an adapter (see also next example)
mRecyclerView.setAdapter(mAdapter);
return rootView;
this is the code used from onCreateView() in the fragment embedded in the activity. The MainFragment shows all the poster images fine, so the code from onLoadFinisihed() in this fragment will be omitted. Notice in the onClick() method, the onItemSelected() method is called which should return the uri the Detail Activity uses in onLoadFinished(). When I log the uri, the format looks correct,
content://com.example.damienmiller.reely.app/Movie_Info/#
but more than one row is returned (all rows are returned). How can I ensure the uri sent to the Details Fragment returns one row using the appended ID number from the sqlite database in my app?