示例#1
0
		public async Task<List<HSMatchInfo_2>> ParseMatchTitle(MatchInfo matchInfo)
		{
			var matchInfo_2 = new MatchInfo_2 ();
			var listMatchDetail = new List<HSMatchInfo_2> ();
			TeamDb teamDb = new TeamDb ();
			DeckOfCardsDb deck = new DeckOfCardsDb();
			LeagueDb leagDb = new LeagueDb ();
			var radiantWin = matchInfo.Winner;
			var team1 = await teamDb.GetTeam (matchInfo.Team1Id, "Hearthstone");
			var team2 = await teamDb.GetTeam (matchInfo.Team2Id, "Hearthstone");
			var leag = await leagDb.GetLeague (matchInfo.LeagueId, "Hearthstone");

			var hsMatchDetail = matchInfo.DetailsMatch.Cast<HSMatchInfo> ().ToList ();
			foreach (var match in hsMatchDetail) {
				var hsMatchInfo_2 = new HSMatchInfo_2 ();
				hsMatchInfo_2.Team1 = team1;
				hsMatchInfo_2.Team2 = team2;
				hsMatchInfo_2.Team1Score = match.Team1Score;
				hsMatchInfo_2.Team2Score = match.Team2Score;
				hsMatchInfo_2.StartTime = matchInfo.StartTime;
				hsMatchInfo_2.Url = matchInfo.Url;
				hsMatchInfo_2.Team1Win = matchInfo.Winner;
				hsMatchInfo_2.Team1Deck = await deck.GetDeckFromSQL (match.Team1Deck);
				hsMatchInfo_2.Team2Deck = await deck.GetDeckFromSQL (match.Team2Deck);
				hsMatchInfo_2.MatchLeague = leag;
				listMatchDetail.Add (hsMatchInfo_2);
			}


			return listMatchDetail;
		}
示例#2
0
		protected async override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.HSMatchInfoLayout);
			title=Intent.GetStringExtra("title");
			pb = FindViewById<ProgressBar> (Resource.Id.progressBar3);
			ActionBarTitle.SetTitle (this,Resource.Layout.ActionBarLayout,title,Resources.GetString(Resource.String.nameHS));
			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;
			// Create your application here
			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());
			hsMatchInfo=JsonConvert.DeserializeObject<List<HSMatchInfo>>(jMatchDetails.SelectToken("DetailsMatch").ToString());
			List<DetailInfo> listDetail=new List<DetailInfo>();
			listDetail.AddRange(hsMatchInfo);
			matchInfo.DetailsMatch=listDetail;

			cts = new CancellationTokenSource ();
			hsMatchInfo_2 = new HSMatchInfo_2 ();
			listMatchInfo = await hsMatchInfo_2.ParseMatchTitle (matchInfo);
			if (listMatchInfo.Count > 0) {
				hsMatchInfo_2 = listMatchInfo [0];
			}
			FillTitleMatch ();
			CreateFragment (Resource.Id.hs_llayout_match_draft, new FragmentHSMatchDraft (listMatchInfo));
			cts = null;
			pb.Visibility= ViewStates.Gone;
			buttonRefresh.Visibility = ViewStates.Visible;
			//this.ListAdapter
		}
示例#3
0
		async Task OnRefresh (CancellationToken token){

			APIRequest ApiReq = new APIRequest ();
			//cts = new CancellationTokenSource ();
			PicksBansOld PB = new PicksBansOld ();
			refreshFlag = true;
			titleFlag = false;

			token.ThrowIfCancellationRequested ();
			if (listMatchInfo.Count > 0) {
				hsMatchInfo_2 = listMatchInfo [0];
			}
			FillTitleMatch ();
			CreateFragment (Resource.Id.hs_llayout_match_draft, new FragmentHSMatchDraft (listMatchInfo));
			Toast.MakeText (this, Resources.GetString(Resource.String.updated), ToastLength.Short).Show ();
			//await RefreshData (token);
			refreshFlag = false;

		}