ListUserPostsFragment

public class ListUserPostsFragment extends Fragment implements RVAdapter.OnItemClickListener

Creates screen that displays the Posts a org.codethechange.culturemesh.models.User has made.

Fields

emptyText

TextView emptyText

Displays R.string.no_posts if there are no Posts to display

queue

RequestQueue queue

Queue for asynchronous tasks

root

View root

The inflated user interface

rv

RecyclerView rv

Scrollable list of Posts

Methods

newInstance

public static ListUserPostsFragment newInstance(long selUser)

Returns a new instance of this fragment for the given section number.

onCreateView

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

Create the user interface. Also populate the list of Posts with the result from API.Get.userPosts(RequestQueue,long,Response.Listener)

Parameters:
  • inflater – Inflates the user interface from R.layout.rv_container with the provided container as the parent.
  • container – Parent used by inflater
  • savedInstanceState – Not used
Returns:

The inflated user interface

onItemClick

public void onItemClick(FeedItem item)

When the user clicks on an item, redirect them to SpecificPostActivity where more details, including comments, are displayed.

Parameters:
  • item – The clicked item.

onStop

public void onStop()

This ensures that we are canceling all network requests if the user is leaving this activity. We use a RequestFilter that accepts all requests (meaning it cancels all requests)