@Override public void loadMore() { if (state == STATE_SEARCH && !searcher.isKeywordEmpty()) { mFootUpdate.showLoading(); searcher.search(); } }
void reload(String keyword) { keyword = keyword == null ? "" : keyword.trim(); if (!keyword.equals(searcher.getKeyword())) { state = STATE_SEARCH; list.clear(); notifyDataSetChanged(); mFootUpdate.dismiss(); searcher.setKeyword(keyword); if (searcher.isKeywordEmpty()) { mFootUpdate.dismiss(); } else { loadMore(); } } }
@Override public void loadMore() { if (TextUtils.isEmpty(currentCity)) { reloadLocation(); } else { searcher.search(); } }
@Override public void onSearchResult(List<LocationObject> locations) { if (locations != null) { list.addAll(locations); } if (searcher.isComplete()) { complete(); } searchAdapter.notifyDataSetChanged(); }
@Override public void onSearchResult(List<LocationObject> locations) { if (LocationSearchActivity.this.isFinishing()) return; addToList(locations); notifyDataSetChanged(); if (searcher.isComplete()) { mFootUpdate.dismiss(); } else { mFootUpdate.showLoading(); } }
private void complete() { if (state == STATE_SEARCH) { state = STATE_COMPLETE; mFootUpdate.dismiss(); String keyword = searcher.getKeyword(); if (!TextUtils.isEmpty(keyword)) { boolean notFound = true; for (LocationObject item : list) { if (keyword.equals(item.name)) { notFound = false; break; } } if (notFound) { list.add(LocationObject.newCustom(keyword, latitude, longitude)); customTextView.setText("创建新的位置: " + keyword); } } } }
SearchAdapter() { searcher = new LocationSearcherGroup(); searcher.configure(LocationSearchActivity.this, new LatLng(latitude, longitude), this); footView = getLayoutInflater().inflate(R.layout.location_list_custom, listView, false); customTextView = (TextView) footView.findViewById(R.id.secondary); }