예제 #1
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    Log.d("EventsFragment", "Cursor loaded " + data.getCount());

    if (getLoaderManager().getLoader(URL_LOADER).equals(loader)) {
      if (data.getCount() == 0) {
        emptyView.setVisibility(View.VISIBLE);
        recyclerView.setVisibility(View.GONE);
        emptyView.setText(R.string.no_events);
      } else {
        emptyView.setVisibility(View.GONE);
        recyclerView.setVisibility(View.VISIBLE);
        mAdapter.swapCursor(data);
      }
    }

    swipeContainer.setRefreshing(false);
  }
예제 #2
0
  @Override
  public void onRefresh() {
    swipeContainer.setRefreshing(true);
    BackendSyncAdapter.syncImmediately(EventsFragment.this.getContext());
    mAdapter.notifyDataSetChanged();

    // stop refresh icon animation when offline
    if (!hasInternetConnection(getContext())) {
      // wait 1.5 seconds
      new Handler()
          .postDelayed(
              new Runnable() {
                public void run() {
                  // stop refresh animation
                  swipeContainer.setRefreshing(false);
                  Toast.makeText(
                          getContext(), "No internet connection available", Toast.LENGTH_SHORT)
                      .show();
                }
              },
              1500);
    }
  }
예제 #3
0
 @Override
 public void onLoaderReset(Loader<Cursor> loader) {
   mAdapter.swapCursor(null);
 }