예제 #1
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View rootView = inflater.inflate(R.layout.fragment_list, container, false);
   RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
   recyclerView = (EmptyAbleRecyclerView) rootView.findViewById(R.id.list_recycler_view);
   FloatingActionButton addContextButton =
       (FloatingActionButton) rootView.findViewById(R.id.list_add_button);
   SwipeRefreshLayout refreshLayout =
       (SwipeRefreshLayout) rootView.findViewById(R.id.fragment_list_swipe_refresh_container);
   refreshLayout.setEnabled(false);
   recyclerView.setLayoutManager(layoutManager);
   TextView emptyTextView =
       (TextView) rootView.findViewById(R.id.fragment_list_recycler_view_empty);
   emptyTextView.setText(R.string.fragment_contextsummary_empty_list_text);
   recyclerView.setEmptyView(emptyTextView);
   addContextButton.setOnClickListener(this);
   return rootView;
 }
예제 #2
0
  @Override
  public void onStart() {
    super.onStart();
    if (backingList == null) {
      backingList = BluifyDbHelper.getAllPlaybackContexts();

      contextSummaryAdapter = new ContextSummaryAdapter(backingList);
      contextSummaryAdapter.setOnItemClickListener(this);
      recyclerView.setAdapter(contextSummaryAdapter);
      refreshListener = new QueryListRefreshListener(contextSummaryAdapter, recyclerView);
      backingList.addOnCursorRefreshListener(refreshListener);
    } else {
      if (contextSummaryAdapter != null) {
        contextSummaryAdapter.setOnItemClickListener(this);
      }
      refreshListener = new QueryListRefreshListener(contextSummaryAdapter, recyclerView);
      backingList.addOnCursorRefreshListener(refreshListener);
      backingList.refreshAsync();
    }
  }