public async Task<List<CSMatchInfo_2>> ParseMatchTitle(MatchInfo matchInfo) { var matchInfo_2 = new MatchInfo_2 (); var listMatchDetail = new List<CSMatchInfo_2> (); TeamDb teamDb = new TeamDb (); CSMapDb mapDb = new CSMapDb (); LeagueDb leagDb = new LeagueDb (); var radiantWin = matchInfo.Winner; var team1 = await teamDb.GetTeam (matchInfo.Team1Id, "CSGO"); var team2 = await teamDb.GetTeam (matchInfo.Team2Id, "CSGO"); var leag = await leagDb.GetLeague (matchInfo.LeagueId, "CSGO"); var csMatchDetail = matchInfo.DetailsMatch.Cast<CSMatchInfo> ().ToList (); foreach (var match in csMatchDetail) { var csMatchInfo_2 = new CSMatchInfo_2 (); csMatchInfo_2.Team1 = team1; csMatchInfo_2.Team2 = team2; csMatchInfo_2.DeteilScoreTeam1 = match.DeteilScoreTeam1; csMatchInfo_2.DeteilScoreTeam2 = match.DeteilScoreTeam2; csMatchInfo_2.Team1Score = match.Team1Score; csMatchInfo_2.Team2Score = match.Team2Score; csMatchInfo_2.StartTime = matchInfo.StartTime; csMatchInfo_2.Url = matchInfo.Url; csMatchInfo_2.Team1Win = matchInfo.Winner; csMatchInfo_2.MatchLeague = leag; csMatchInfo_2.Map = await mapDb.GetMap(match.CSMapId); listMatchDetail.Add (csMatchInfo_2); } return listMatchDetail; }
protected async override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.CSMatchInfoLayout); title=Intent.GetStringExtra("title"); pb = FindViewById<ProgressBar> (Resource.Id.progressBar3); ActionBarTitle.SetTitle (this,Resource.Layout.ActionBarLayout,title,Resources.GetString(Resource.String.nameCSGO)); var buttonBack=FindViewById<Button>(Resource.Id.buttonBackActionBar); buttonBack.Click+=ButtonBackClick; buttonRefresh=FindViewById<Button>(Resource.Id.buttonRefreshActionBar); buttonRefresh.Click+=ButtonRefreshClick; buttonRefresh.Visibility=ViewStates.Invisible; pb=FindViewById<ProgressBar> (Resource.Id.progressBar3); pb.Visibility= ViewStates.Visible; APIRequest apiReq = new APIRequest (); int match_id=Convert.ToInt32( Intent.GetStringExtra("match_id")); var url =SettingsApp.ServerAPIAddress+SettingsApp.GameName+"/GetDetailInfo?match_id=" + match_id; var jMatchResponce = await apiReq.GetJsonAsync (url); gameInfo=jMatchResponce.ToString (); liveFlag=Intent.GetStringExtra("liveFlag"); var jDetailMatchInfo= JsonConvert.DeserializeObject<JDetailMatchInfo>(gameInfo); var jMatchDetails=JToken.Parse(jDetailMatchInfo.JMatchDetails); matchInfo=JsonConvert.DeserializeObject<MatchInfo>(jMatchDetails.ToString()); csMatchInfo=JsonConvert.DeserializeObject<List<CSMatchInfo>>(jMatchDetails.SelectToken("DetailsMatch").ToString()); List<DetailInfo> listDetail=new List<DetailInfo>(); listDetail.AddRange(csMatchInfo); matchInfo.DetailsMatch=listDetail; cts = new CancellationTokenSource (); matchInfo_2 = new CSMatchInfo_2 (); listMatchInfo = await matchInfo_2.ParseMatchTitle (matchInfo); if (listMatchInfo.Count > 0) { matchInfo_2 = listMatchInfo [0]; } FillTitleMatch (); CreateFragment (Resource.Id.cs_llayout_match_draft, new FragmentCSMatchDraft (listMatchInfo)); cts = null; pb.Visibility= ViewStates.Gone; buttonRefresh.Visibility = ViewStates.Visible; // Create your application here }
async Task OnRefresh (CancellationToken token){ APIRequest ApiReq = new APIRequest (); refreshFlag = true; titleFlag = false; token.ThrowIfCancellationRequested (); if (listMatchInfo.Count > 0) { matchInfo_2 = listMatchInfo [0]; } FillTitleMatch (); CreateFragment (Resource.Id.cs_llayout_match_draft, new FragmentCSMatchDraft (listMatchInfo)); cts = null; refreshFlag = false; Toast.MakeText (this, Resources.GetString(Resource.String.updated), ToastLength.Short).Show (); }