protected override async void OnCreate (Bundle bundle) { //Window.RequestFeature(WindowFeatures.NoTitle); try{ base.OnCreate (bundle); SetContentView (Resource.Layout.PicksLayout); pb = FindViewById<ProgressBar> (Resource.Id.progressBar3); ActionBarTitle.SetTitle (this,Resource.Layout.ActionBarLayout,Resources.GetString(Resource.String.capitanMod),"DOTA 2"); buttonRefresh=FindViewById<Button>(Resource.Id.buttonRefreshActionBar); buttonRefresh.Click+=ButtonRefreshClick; buttonRefresh.Visibility=ViewStates.Invisible; var buttonBack=FindViewById<Button>(Resource.Id.buttonBackActionBar); buttonBack.Click+=ButtonBackClick; pb=FindViewById<ProgressBar> (Resource.Id.progressBar3); pb.Visibility= ViewStates.Visible; APIRequest ApiReq = new APIRequest (); PicksBansOld pickBans=new PicksBansOld(); Player playerReq=new Player(); gameInfo=Intent.GetStringExtra("matchDetail"); var jDetailMatchInfo= JsonConvert.DeserializeObject<JDetailMatchInfo>(gameInfo); var jMatchDetails=JToken.Parse(jDetailMatchInfo.JMatchDetails); matchInfo=JsonConvert.DeserializeObject<MatchInfo>(jMatchDetails.ToString()); dotaMatchInfo=JsonConvert.DeserializeObject<List<DotaMatchInfo>>(jMatchDetails.SelectToken("DetailsMatch").ToString()); List<DetailInfo> listDetail=new List<DetailInfo>(); listDetail.AddRange(dotaMatchInfo); matchInfo.DetailsMatch=listDetail; liveFlag=Intent.GetStringExtra("liveFlag"); title=Intent.GetStringExtra("title"); TextView radiantName, direName,textRadiant,textDire; ImageView radiantLogo, direLogo; LinearLayout llradiantTeam, lldireTeam; radiantName=FindViewById<TextView>(Resource.Id.radiantTeamName); direName=FindViewById<TextView>(Resource.Id.direTeamName); radiantLogo=FindViewById<ImageView>(Resource.Id.logoRadiantTeam); direLogo=FindViewById<ImageView>(Resource.Id.logoDireTeam); llradiantTeam=FindViewById<LinearLayout>(Resource.Id.llradiantTeam); lldireTeam=FindViewById<LinearLayout>(Resource.Id.lldireTeam); textRadiant=FindViewById<TextView>(Resource.Id.textTeamFP); textDire=FindViewById<TextView>(Resource.Id.textTeamSP); var analisPick=new AnalysisPick(); var value=analisPick.GetAnalysisTeam(dotaMatchInfo[0].RadiantPicks.ListPicks,dotaMatchInfo[0].DirePicks.ListPicks); textRadiant.Text=Resources.GetString(Resource.String.radiant)+" "+value[0].ToString(); textDire.Text=Resources.GetString(Resource.String.dire)+" "+(value[1].ToString()); textRadiant.SetTextAppearance(this,Resource.Style.RadiantName); textDire.SetTextAppearance(this,Resource.Style.DireName); TeamDb teamDb=new TeamDb(); var radiantTeam= await teamDb.GetTeam(matchInfo.Team1Id,"DOTA2"); var direTeam= await teamDb.GetTeam(matchInfo.Team2Id,"DOTA2"); if(radiantTeam != null){ radiantName.Text=radiantTeam.Name; if(radiantTeam.LogoByte!=null){ Bitmap bmp1= BitmapFactory.DecodeByteArray (radiantTeam.LogoByte, 0, radiantTeam.LogoByte.Length); radiantLogo.SetImageBitmap(bmp1); } } if(direTeam != null){ direName.Text=direTeam.Name; if(direTeam.LogoByte!=null){ Bitmap bmp2= BitmapFactory.DecodeByteArray (direTeam.LogoByte, 0, direTeam.LogoByte.Length); direLogo.SetImageBitmap(bmp2); } } var bluePlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer1); var cyanPlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer2); var purpurePlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer3); var yellowPlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer4); var orangePlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer5); var pinkPlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer1); var olivePlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer2); var aquaPlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer3); var darkgreenPlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer4); var chokolatePlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer5); var listTextView = new List<TextView> (){bluePlayer,cyanPlayer,purpurePlayer,yellowPlayer,orangePlayer, pinkPlayer,olivePlayer,aquaPlayer,darkgreenPlayer,chokolatePlayer}; var allPlayerInfo = dotaMatchInfo[0].Players; for (var i = 0; i < allPlayerInfo.Count(); i++) { int color=ColorsOnMatch.GetColorPlayer(i); listTextView [i].Text = allPlayerInfo [i].PlayerName; listTextView[i].SetTextColor(Resources.GetColor(color)); } radiantPB = pickBans.ParseJsonToRadPick (dotaMatchInfo[0].RadiantPicks); direPB = pickBans.ParseJsonToDirePick (dotaMatchInfo[0].DirePicks); cts=new CancellationTokenSource(); cts.Token.ThrowIfCancellationRequested (); await SetHeroesImageInLayout (cts.Token); cts = null; } catch(Exception e){ Console.WriteLine (e); } pb.Visibility= ViewStates.Gone; buttonRefresh.Visibility = ViewStates.Visible; }
async Task OnRefresh(CancellationToken token) { APIRequest ApiReq = new APIRequest (); PicksBansOld pickBans=new PicksBansOld(); //cts = new CancellationTokenSource (); refreshFlag = true; token.ThrowIfCancellationRequested (); var url =SettingsApp.ServerAPIAddress+SettingsApp.GameName+"/GetDetailInfo?match_id="+matchInfo.MatchId; var jMatchResponce = await ApiReq.GetJsonAsync (url); var jDetailMatchInfo= JsonConvert.DeserializeObject<JDetailMatchInfo>(jMatchResponce.ToString()); var jMatchDetails=JToken.Parse(jDetailMatchInfo.JMatchDetails); matchInfo=JsonConvert.DeserializeObject<MatchInfo>(jMatchDetails.ToString()); dotaMatchInfo=JsonConvert.DeserializeObject<List<DotaMatchInfo>>(jMatchDetails.SelectToken("DetailsMatch").ToString()); List<DetailInfo> listDetail=new List<DetailInfo>(); listDetail.AddRange(dotaMatchInfo); matchInfo.DetailsMatch=listDetail; radiantPB = pickBans.ParseJsonToRadPick (dotaMatchInfo[0].RadiantPicks); direPB = pickBans.ParseJsonToDirePick (dotaMatchInfo[0].DirePicks); token.ThrowIfCancellationRequested (); await SetHeroesImageInLayout (token); var analisPick=new AnalysisPick(); var textRadiant=FindViewById<TextView>(Resource.Id.textTeamFP); var textDire=FindViewById<TextView>(Resource.Id.textTeamSP); var value=analisPick.GetAnalysisTeam(dotaMatchInfo[0].RadiantPicks.ListPicks,dotaMatchInfo[0].DirePicks.ListPicks); textRadiant.Text=Resources.GetString(Resource.String.radiant)+" "+value[0].ToString(); textDire.Text=Resources.GetString(Resource.String.dire)+" "+(value[1].ToString()); Toast.MakeText (this, Resources.GetString(Resource.String.updated), ToastLength.Short).Show (); refreshFlag = false; }