/** * @param mode * @param newStatus */ private void refreshList(int mode, List<Status> newStatus) { if (newStatus != null) { if (newStatus.size() > 0) { switch (mode) { case Task.TA_GETSTATUS_MODE_FIRSTTIME: currentStatus = newStatus; adapter = new TaskAdapter(this, currentStatus); xlist_task.setAdapter(adapter); lastestUpdata = TimeUtil.setLastestUpdata(); break; case Task.TA_GETSTATUS_MODE_LOADMORE: currentStatus.addAll(newStatus); adapter.notifyDataSetChanged(); break; default: break; } changeListData(); } else { LinearLayout layout = (LinearLayout) findViewById(R.id.layout_no_info); TextView txt_no_info = (TextView) findViewById(R.id.txt_no_info); txt_no_info.setText("还没有报名过任务"); layout.setVisibility(View.VISIBLE); } } else { xlist_task.stopRefresh(); } /*把标志设为false,这样才能再开获取status的网络连接*/ isRefresh = false; }
/* * 改变list相关的保存的数据 */ private void changeListData() { xlist_task.stopRefresh(); xlist_task.stopLoadMore(); xlist_task.setRefreshTime(lastestUpdata); if (currentStatus.size() >= 10) { oldestStatusId = currentStatus.get(currentStatus.size() - 1).getStatusId(); xlist_task.setPullLoadEnable(true); } }
private void initView() { btn_back = (Button) findViewById(R.id.btn_back_my_signup_status); btn_back.setOnClickListener( new OnClickListener() { public void onClick(View v) { finish(); } }); xlist_task = (XListView) findViewById(R.id.xlist_my_signup_status); xlist_task.setPullLoadEnable(false); if (currentStatus != null) { oldestStatusId = currentStatus.get(currentStatus.size() - 1).getStatusId(); adapter = new TaskAdapter(this, currentStatus); xlist_task.setAdapter(adapter); } xlist_task.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (currentStatus.size() >= arg2) { clickPosition = arg2 - 1; /*全局变量传递数据*/ Intent intent = new Intent(MySignUpStatusActivity.this, TaskDetailActivity.class); TaUpstairsApplication app = (TaUpstairsApplication) getApplication(); app.setStatus(currentStatus.get(arg2 - 1)); startActivityForResult(intent, IntentString.RequestCode.MYRELEASESTATUS_TASKDETAIL); } } }); xlist_task.setXListViewListener( new IXListViewListener() { @Override public void onRefresh() { getStatusFromTask(Task.TA_GETSTATUS_MODE_FIRSTTIME, null); } @Override public void onLoadMore() { getStatusFromTask(Task.TA_GETSTATUS_MODE_LOADMORE, oldestStatusId); } }); }