@Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!et_search.getText().toString().equals("")) { Map<String, String> map = new HashMap<String, String>(); map.put("Page", "1"); map.put("Size", String.valueOf(AppConfig.ORDER_SIZE)); map.put("KeyWord", URLEncoder.encode(et_search.getText().toString())); Http.request( SearchFriendsActivity.this, API.SEARCH_USER, new Object[] {Http.getURL(map)}, new Http.RequestListener<List<UserDetail>>() { @Override public void onSuccess(final List<UserDetail> result) { super.onSuccess(result); swipeRefreshXUser = new SwipeRefreshXUser(SearchFriendsActivity.this, result); lv_mysearch.setAdapter(swipeRefreshXUser); } }); } else { List<UserDetail> result = new ArrayList<UserDetail>(); swipeRefreshXUser = new SwipeRefreshXUser(SearchFriendsActivity.this, result); lv_mysearch.setAdapter(swipeRefreshXUser); } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.tb_back: finish(); break; case R.id.tb_action: Http.request( EditFriendsNickNameActivity.this, API.UPDATE_FRIENDNICK, new Object[] {getIntent().getStringExtra("UserID")}, Http.map( "UserId", String.valueOf(Auth.getCurrentUserId()), "NickName", et_friendnickname.getText().toString()), new Http.RequestListener<String>() { @Override public void onSuccess(String result) { super.onSuccess(result); intent.putExtra("NickName", et_friendnickname.getText().toString()); intent.putExtra("Name", getIntent().getStringExtra("Name")); setResult(RESULT_OK, intent); finish(); } }); break; } }
public void initdata() { Map<String, String> map = new HashMap<String, String>(); map.put("Page", "1"); map.put("Size", String.valueOf(AppConfig.ORDER_SIZE)); map.put("Type", String.valueOf("1")); Http.request( MyMissionActivity.this, API.GET_SELFORDER, new Object[] {Http.getURL(map)}, new Http.RequestListener<List<OrderDetails>>() { @Override public void onSuccess(List<OrderDetails> result) { super.onSuccess(result); progress_bar.setVisibility(View.GONE); swipeRefreshXMyMissionAdapater = new SwipeRefreshXMyMissionAdapater(MyMissionActivity.this, result); listView.setAdapter(swipeRefreshXMyMissionAdapater); if (result != null && result.size() != 0) { tv_empty.setVisibility(View.GONE); } else { tv_empty.setVisibility(View.VISIBLE); } } @Override public void onFail(String code) { super.onFail(code); progress_bar.setVisibility(View.GONE); } }); // 下拉刷新监听器 swipeRefresh.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Map<String, String> map = new HashMap<String, String>(); map.put("Page", "1"); map.put("Size", String.valueOf(AppConfig.ORDER_SIZE)); map.put("Type", String.valueOf("1")); Http.request( MyMissionActivity.this, API.GET_SELFORDER, new Object[] {Http.getURL(map)}, new Http.RequestListener<List<OrderDetails>>() { @Override public void onSuccess(List<OrderDetails> result) { super.onSuccess(result); page = 1; swipeRefresh.setRefreshing(false); swipeRefreshXMyMissionAdapater = new SwipeRefreshXMyMissionAdapater(MyMissionActivity.this, result); listView.setAdapter(swipeRefreshXMyMissionAdapater); if (result != null && result.size() != 0) { tv_empty.setVisibility(View.GONE); } else { tv_empty.setVisibility(View.VISIBLE); } } @Override public void onFail(String code) { super.onFail(code); swipeRefresh.setRefreshing(false); } }); } }); // 加载监听器 swipeRefresh.setOnLoadListener( new SwipeRefreshX.OnLoadListener() { @Override public void onLoad() { page++; Map<String, String> map = new HashMap<String, String>(); map.put("Page", String.valueOf(page)); map.put("Size", String.valueOf(AppConfig.ORDER_SIZE)); map.put("Type", String.valueOf("1")); Http.request( MyMissionActivity.this, API.GET_SELFORDER, new Object[] {Http.getURL(map)}, new Http.RequestListener<List<OrderDetails>>() { @Override public void onSuccess(List<OrderDetails> result) { super.onSuccess(result); if (result != null) { loadMore(swipeRefreshXMyMissionAdapater, result); } swipeRefresh.setLoading(false); } @Override public void onFail(String code) { super.onFail(code); swipeRefresh.setLoading(false); } }); } }); }
@Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!et_search.getText().toString().equals("")) { Map<String, String> map = new HashMap<String, String>(); map.put("KeyWord", URLEncoder.encode(et_search.getText().toString())); map.put("Page", "1"); map.put("Size", String.valueOf(AppConfig.ORDER_SIZE)); Http.request( SearchActivity.this, API.SEARCH_ORDER, new Object[] {Http.getURL(map)}, new Http.RequestListener<SearchResult>() { @Override public void onSuccess(final SearchResult result) { super.onSuccess(result); if (result != null) { tv_empty.setVisibility(View.GONE); if (result.getOrders() != null && !result.getOrders().isEmpty()) { rl_service.setVisibility(View.VISIBLE); List<OrderDetails> orderDetailsList = new ArrayList<OrderDetails>(); for (int i = 0; i < ((result.getOrders().size() > 2) ? 2 : result.getOrders().size()); i++) { orderDetailsList.add(result.getOrders().get(i)); } lv_mysearch.setAdapter( new SwipeRefreshXOrderAdapater( SearchActivity.this, orderDetailsList, AppConfig.ORDERSTATUS_MAIN)); if (result.getOrders().size() > 2) { tv_servicenmore.setVisibility(View.VISIBLE); } else { tv_servicenmore.setVisibility(View.GONE); } setListViewHeightBasedOnChildren(lv_mysearch); } else { rl_service.setVisibility(View.GONE); } if (result.getQuestions() != null && !result.getQuestions().isEmpty()) { rl_question.setVisibility(View.VISIBLE); List<Question> questionList = new ArrayList<Question>(); for (int i = 0; i < ((result.getQuestions().size() > 2) ? 2 : result.getQuestions().size()); i++) { questionList.add(result.getQuestions().get(i)); } lv_myquestion.setAdapter( new SwipeRefreshXQuestionAdapater(SearchActivity.this, questionList)); if (result.getQuestions().size() > 2) { tv_questionmore.setVisibility(View.VISIBLE); } else { tv_questionmore.setVisibility(View.GONE); } setListViewHeightBasedOnChildren(lv_myquestion); } else { rl_question.setVisibility(View.GONE); } } else { tv_empty.setVisibility(View.VISIBLE); } } @Override public void onFail(String code) { super.onFail(code); } }); } else { rl_service.setVisibility(View.GONE); rl_question.setVisibility(View.GONE); tv_questionmore.setVisibility(View.GONE); tv_servicenmore.setVisibility(View.GONE); List<OrderDetails> result = new ArrayList<OrderDetails>(); lv_mysearch.setAdapter( new SwipeRefreshXOrderAdapater( SearchActivity.this, result, AppConfig.ORDERSTATUS_MAIN)); } }