@Override protected void callBackForGetDataFailed(int type, XtomNetTask task) { switch (task.getId()) { case TaskConstant.GET_ACCOUNT_LIST: if ("刷新".equals(task.getDescription())) { layout.refreshFailed(); failed(); } if ("加载".equals(task.getDescription())) { layout.loadmoreFailed(); } break; } }
@Override protected void noNetWork(XtomNetTask task) { switch (task.getId()) { case TaskConstant.GET_ACCOUNT_LIST: if ("刷新".equals(task.getDescription())) { layout.refreshFailed(); failed(); } if ("加载".equals(task.getDescription())) { layout.loadmoreFailed(); } break; } super.noNetWork(task); }
@Override protected void setListener() { title.setText(R.string.project_account); right.setVisibility(View.INVISIBLE); left.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { finish(); } }); layout.setOnStartListener( new OnStartListener() { @Override public void onStartRefresh(XtomRefreshLoadmoreLayout v) { page = 0; getInfor(page, "刷新"); } @Override public void onStartLoadmore(XtomRefreshLoadmoreLayout v) { page++; getInfor(page, "加载"); } }); }
@Override protected void callBackForServerFailed(int taskID, XtomNetTask task, BaseResult result) { switch (task.getId()) { case TaskConstant.GET_ACCOUNT_LIST: if ("刷新".equals(task.getDescription())) { layout.refreshFailed(); failed(); } if ("加载".equals(task.getDescription())) { layout.loadmoreFailed(); } break; default: break; } }
@Override protected void callBackForServerSuccess(int taskID, XtomNetTask netTask, BaseResult result) { switch (netTask.getId()) { case TaskConstant.GET_ACCOUNT_DETAIL: @SuppressWarnings("unchecked") MResult<AccountDetailInfor> base = (MResult<AccountDetailInfor>) result; layout.refreshSuccess(); infor = base.getObjects().get(0); mClient.insertOrUpdate(infor); managedata(); break; case TaskConstant.ADD_WITHDRAW: XtomToastUtil.showShortToast(mContext, result.getMsg()); switch (result.getStatus()) { case ServiceConstant.STATUS_SUCCESS: XtomToastUtil.showShortToast(mContext, result.getMsg()); finish(); break; case ServiceConstant.STATUS_FAILED: XtomToastUtil.showShortToast(mContext, result.getMsg()); break; } break; } super.callBackForServerSuccess(taskID, netTask, result); }
private void getDataFromCache() { infors = mClient.selectAll(); layout.setVisibility(View.VISIBLE); progressBar.setVisibility(View.GONE); adapter = new ProjectAccountAdapter(mContext, this.infors); adapter.setEmptyString(getEmptyString()); mListView.setAdapter(adapter); }
@Override protected void callAfterDataBack(int TaskID) { switch (TaskID) { case TaskConstant.GET_ACCOUNT_DETAIL: progressBar.setVisibility(View.GONE); layout.setVisibility(View.VISIBLE); break; } }
@Override protected void callBackForServerSuccess(int taskID, XtomNetTask task, BaseResult result) { switch (taskID) { case TaskConstant.GET_ACCOUNT_LIST: @SuppressWarnings("unchecked") MResult<AccountListInfor> base = (MResult<AccountListInfor>) result; ArrayList<AccountListInfor> users = base.getObjects(); if ("刷新".equals(task.getDescription())) { layout.refreshSuccess(); this.infors.clear(); this.infors.addAll(users); if (infors.size() > 0) mClient.clear(SysCache.getUser().getUid()); mClient.insertOrUpdate(infors); if (users.size() >= Integer.parseInt(SysCache.getSysInfo().getSys_pagesize())) { layout.setLoadmoreable(true); } else { layout.setLoadmoreable(false); } } if ("加载".equals(task.getDescription())) { layout.loadmoreSuccess(); if (users.size() > 0) { this.infors.addAll(users); } else { layout.setLoadmoreable(false); XtomToastUtil.showShortToast(this, "已经到最后啦"); } } if (adapter == null) { adapter = new ProjectAccountAdapter(mContext, this.infors); adapter.setEmptyString(getEmptyString()); mListView.setAdapter(adapter); } else { adapter.setEmptyString(getEmptyString()); adapter.notifyDataSetChanged(); } break; default: break; } }
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_projectaccount); super.onCreate(savedInstanceState); mClient = ProjectAccount_DBClient.get(mContext); if (!mClient.isEmpty()) getDataFromCache(); else { if (hasNetWork()) getInfor(0, "刷新"); else { layout.setVisibility(View.VISIBLE); progressBar.setVisibility(View.GONE); adapter = new ProjectAccountAdapter(mContext, this.infors); adapter.setEmptyString(getEmptyString()); mListView.setAdapter(adapter); XtomToastUtil.showShortToast(mContext, R.string.nonetwork); return; } } }
private void getDataFromCache() { infor = mClient.selectByPid(pid); layout.setVisibility(View.VISIBLE); progressBar.setVisibility(View.GONE); managedata(); }
@Override protected void setListener() { title.setText(R.string.detail); right.setVisibility(View.INVISIBLE); left.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { finish(); } }); edit_need.setText("0"); btn_tixian.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { String content = edit_need.getText().toString(); if (Integer.parseInt(content) > (yue / 100)) { XtomToastUtil.showShortToast(mContext, "目前账户内没有如此金额的余额,请重新填写"); return; } if (isNull(content)) { XtomToastUtil.showShortToast(mContext, "提现金额不能为空,请重新填写"); return; } if (Integer.parseInt(content) == 0) { XtomToastUtil.showShortToast(mContext, "提现金额不能为0,请重新填写"); return; } HashMap<String, String> params = new HashMap<String, String>(); params.put("token", SysCache.getUser().getToken()); params.put("pid", pid); params.put("money", String.valueOf(Integer.parseInt(content) * 100)); RequestInformation information = RequestInformation.ADD_WITHDRAW; getDataFromServer( new XtomNetTask(information.getTaskID(), information.getUrlPath(), params) { @Override public Object parse(JSONObject jsonObject) throws DataParseException { return new BaseResult(jsonObject); } }); } }); layout.setOnStartListener( new OnStartListener() { @Override public void onStartRefresh(XtomRefreshLoadmoreLayout v) { getDetailInfor(); } @Override public void onStartLoadmore(XtomRefreshLoadmoreLayout v) {} }); layout.setLoadmoreable(false); layout.scrollTo(0, 0); }