@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "onActivityResult"); super.onActivityResult(requestCode, resultCode, data); if (data == null) { Log.d(TAG, "onActivityResult but data is null"); return; } switch (requestCode) { case SelectLeagueActivity.ACTION_SELECT_LEAGUE: { // handle select league result (return a league id list) ArrayList<String> selectedList = null; selectedList = data.getStringArrayListExtra(SelectLeagueActivity.KEY_SELECTED_LEAGUE); if (selectedList == null) { Log.d(TAG, "onActivityResult but select league list is null"); return; } Log.d(TAG, "onActivityResult, select league list is " + selectedList); // Set<String> selectedSet = new HashSet<String>(); selectedSet.clear(); selectedSet.addAll(selectedList); leagueManager.setFilterLeagueSet(selectedSet); oddsManager.setFilterLeagueIdList(selectedList); this.reloadListDataAndView(); } break; case SelectCompanyActivity.ACTION_SELECT_COMPANY: { // handle companyId here ArrayList<String> selectedList = null; selectedList = data.getStringArrayListExtra(SelectCompanyActivity.KEY_SELECTED_COMPANY); if (selectedList == null) { Log.d(TAG, "onActivityResult but select company list is null"); return; } Log.d(TAG, "onActivityResult, select company list is " + selectedList); setCompanyIdFromList(selectedList); loadAllOddsData(); this.reloadListDataAndView(); } break; default: break; } }
private void selectTopLeagues() { List<String> filterLeagueIdList2 = new ArrayList<String>(); for (League league : topLeagues) { filterLeagueIdList2.add(league.getLeagueId()); } Set<String> selectedSet2 = new HashSet<String>(); selectedSet2.addAll(filterLeagueIdList2); leagueManager.setLeagueList(topLeagues); leagueManager.setFilterLeagueSet(selectedSet2); oddsManager.setFilterLeagueIdList(filterLeagueIdList2); }
private void reloadListDataAndView() { if (firstLoad) { // 默认一级赛事 List<String> filterLeagueIdList = new ArrayList<String>(); for (League league : topLeagues) { filterLeagueIdList.add(league.getLeagueId()); } oddsManager.setFilterLeagueIdList(filterLeagueIdList); // 设置筛选的联赛 leagueManager.setLeagueList(topLeagues); Set<String> filterSet = new HashSet<String>(); filterSet.addAll(filterLeagueIdList); leagueManager.setFilterLeagueSet(filterSet); firstLoad = false; } matchOddsMap = oddsManager.filterOddsByOddsType(companyManager.getOddsType()); updateMatchOddsMap(); updateNoOddsTextView(); adapter.notifyDataSetChanged(); }
@Override public void loadOddsDataFinish(ResultCodeType resultCode) { switch (resultCode) { case SUCCESS: topLeagues = leagueManager.findAllTopLeagues(); allLeagues = leagueManager.findAllLeagues(); // for refresh if (selectedSet != null && selectedSet.size() > 0) { List<String> selectedlist = new ArrayList<String>(); selectedlist.addAll(selectedSet); oddsManager.setFilterLeagueIdList(selectedlist); } else { switch (oddsManager.getFilterScoreType()) { case FIRST: selectTopLeagues(); break; case ALL: selectAllLeagues(); break; case DANCHANGE: selectAllLeagues(); break; case JINGCAI: selectAllLeagues(); break; case ZUCAI: selectAllLeagues(); default: break; } } this.reloadListDataAndView(); break; default: break; } }
public void updateMatchOddsMap() { groups.clear(); Map.Entry[] entries = getSortedMapEntry(matchOddsMap); for (int i = 0; i < entries.length; i++) { Match match = (Match) entries[i].getKey(); if (!oddsManager.canDisplayOdds(match, date)) { // Log.d(TAG, "match of match id: " + match.getMatchId() + " not to display because match // status: " + match.getStatus()); continue; } List<Odds> group_childrenList = (List<Odds>) entries[i].getValue(); OddsGroup oddsGroup = new OddsGroup(match, group_childrenList); groups.add(oddsGroup); } // expand all groups int groupCount = adapter.getGroupCount(); for (int i = 0; i < groupCount; i++) { listView.expandGroup(i); } }
private void updateScoreTypeButton() { Button button = (Button) findViewById(R.id.button_filter_score_type); button.setText(getScoreTypeString(oddsManager.getFilterScoreType())); }