Exemplo n.º 1
0
  /**
   * @param page
   * @param recommends
   * @param mException
   */
  public void onTaskComplete(Group<Event> events, int page, Exception ex) {
    mStateHolder.setRanOnce(true);
    mStateHolder.setIsRunningTask(false);
    mStateHolder.setCurrentPage(page);
    setProgressBarIndeterminateVisibility(false);

    ProgressBar pbRefresh = (ProgressBar) findViewById(R.id.list_refresh_progress);
    pbRefresh.setVisibility(View.GONE);
    ImageView ivRefresh = (ImageView) findViewById(R.id.list_refresh);
    ivRefresh.setVisibility(View.VISIBLE);

    // Clear list for new batch.
    mListAdapter.removeObserver();
    mListAdapter.clear();
    // if(mListAdapter == null){
    mListAdapter = new SeparatedListAdapter(this);
    // }

    if (events != null) {
      Group<RecommendMsg> recommends = filterEventsFromJiepang(events);

      if (mStateHolder.getCurrentPage() <= 1) {
        mStateHolder.setRecommends(recommends);
      } else {
        mStateHolder.addRecommends(recommends);
      }

      if (mStateHolder.getSortMethod() == SORT_METHOD_RECENT) {
        sortRecommendsRecent(mStateHolder.getRecommends(), mListAdapter);
      } else {
        sortRecommendsDistance(mStateHolder.getRecommends(), mListAdapter);
      }
    } else if (ex != null) {
      if (mStateHolder.getRecommends() == null) {
        Group<RecommendMsg> recommends = new Group<RecommendMsg>();
        mStateHolder.setRecommends(recommends);
      }

      NotificationsUtil.ToastReasonForFailure(this, ex);
    }

    if (mStateHolder.getRecommends().size() == 0) {
      setEmptyView(mLayoutEmpty);
    }

    getListView().setAdapter(mListAdapter);

    if (mStateHolder.getRecommends() != null && !mStateHolder.getRecommends().isHasMore()) {
      footerview.setVisibility(View.GONE);
    }
    // -1 footerview
    getListView().setSelection(mStateHolder.getCurrentListItem() - 2);
    // getListView().setSelection(3);
  }
Exemplo n.º 2
0
  @Override
  public void onPause() {
    super.onPause();

    ((Jianjianroid) getApplication()).removeLocationUpdates();

    if (isFinishing()) {
      if (mListAdapter != null) {
        mListAdapter.removeObserver();
      }

      unregisterReceiver(mLoggedOutReceiver);
      mStateHolder.cancel();
    }
  }