ListNetworksFragment

public class ListNetworksFragment extends Fragment implements NetworkSummaryAdapter.OnNetworkTapListener

Fragment for displaying lists of clickable networks

Fields

SELECTED_USER

static final String SELECTED_USER

Key stored in the fragment’s arguments and whose value is the ID of the user whose networks are to be displayed.

emptyText

TextView emptyText

Displays R.string.no_networks if there are no networks to display

queue

RequestQueue queue

Queue for asynchronous tasks

root

View root

Inflated user interface created by ListNetworksFragment.onCreate(Bundle)

rv

RecyclerView rv

Scrollable list of networks

Methods

newInstance

public static ListNetworksFragment 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)

Setup the user interface to display the list of networks and populate that list with the result of calling API.Get.userNetworks(RequestQueue,long,Response.Listener).

Parameters:
  • inflater – Inflates the user interface specified in R.layout.rv_container
  • container – Parent of the generated hierarchy of user interface elements
  • savedInstanceState – Saved state to restore
Returns:

Inflated user interface

onItemClick

public void onItemClick(View v, Network network)

This is the onClick() passed to NetworkSummaryAdapter. Thus, this is executed when the user taps on of the network card views. We want to view the tapped network in TimelineActivity.

Parameters:
  • v – the CardView.
  • network – The Network

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)