예제 #1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_itemlist, null);
    ButterKnife.bind(this, v);

    emptyProgressView.setColors(
        getResources().getColor(R.color.refresh_1),
        getResources().getColor(R.color.refresh_2),
        getResources().getColor(R.color.refresh_3),
        getResources().getColor(R.color.refresh_4));
    View headerView = inflater.inflate(R.layout.row_loading_throbber, null);
    headerProgressView = (ProgressThrobber) headerView.findViewById(R.id.itemlist_loading_throb);
    headerProgressView.setColors(
        getResources().getColor(R.color.refresh_1),
        getResources().getColor(R.color.refresh_2),
        getResources().getColor(R.color.refresh_3),
        getResources().getColor(R.color.refresh_4));
    itemList.addHeaderView(headerView, null, false);
    itemList.setHeaderDividersEnabled(false);

    View footerView = inflater.inflate(R.layout.row_loading_throbber, null);
    footerProgressView = (ProgressThrobber) footerView.findViewById(R.id.itemlist_loading_throb);
    footerProgressView.setColors(
        getResources().getColor(R.color.refresh_1),
        getResources().getColor(R.color.refresh_2),
        getResources().getColor(R.color.refresh_3),
        getResources().getColor(R.color.refresh_4));
    itemList.addFooterView(footerView, null, false);
    itemList.setFooterDividersEnabled(false);

    itemList.setEmptyView(v.findViewById(R.id.empty_view));
    setupBezelSwipeDetector(itemList);
    itemList.setOnScrollListener(this);
    itemList.setOnItemClickListener(this);
    itemList.setOnCreateContextMenuListener(this);
    if (adapter != null) {
      // normally the adapter is set when it is created in onLoadFinished(), but sometimes
      // onCreateView gets re-called thereafter.
      itemList.setAdapter(adapter);
    }
    return v;
  }
예제 #2
0
 /**
  * Turns on/off the loading indicator. Note that the text component of the loading indicator
  * requires a cursor and is handled below.
  */
 public void setLoading(boolean isLoading) {
   if (footerProgressView != null) {
     if (isLoading) {
       if (NBSyncService.isFeedSetStoriesFresh(getFeedSet())) {
         headerProgressView.setVisibility(View.INVISIBLE);
         footerProgressView.setVisibility(View.VISIBLE);
       } else {
         headerProgressView.setVisibility(View.VISIBLE);
         footerProgressView.setVisibility(View.GONE);
       }
       emptyProgressView.setVisibility(View.VISIBLE);
     } else {
       headerProgressView.setVisibility(View.INVISIBLE);
       footerProgressView.setVisibility(View.GONE);
       emptyProgressView.setVisibility(View.GONE);
     }
   }
 }