Fixed a google play connection crash

This commit is contained in:
Ellpeck 2020-07-26 02:47:26 +02:00
parent 4832ccd5ee
commit d45a49f809
4 changed files with 10 additions and 7 deletions

View file

@ -111,13 +111,16 @@ namespace Android {
this.activity.StartActivity(new Intent(Intent.ActionView, Uri.Parse("https://play.google.com/store/apps/details?id=de.ellpeck.touchytickets"))); this.activity.StartActivity(new Intent(Intent.ActionView, Uri.Parse("https://play.google.com/store/apps/details?id=de.ellpeck.touchytickets")));
} }
public override void GainAchievement(Achievement achievement) { public override bool GainAchievement(Achievement achievement) {
if (this.GoogleApi != null) if (this.GoogleApi != null && this.GoogleApi.IsConnected) {
GamesClass.Achievements.Unlock(this.GoogleApi, AchievementIds[achievement.Name]); GamesClass.Achievements.Unlock(this.GoogleApi, AchievementIds[achievement.Name]);
return true;
}
return false;
} }
public override void ShowAchievements() { public override void ShowAchievements() {
if (this.GoogleApi == null) if (this.GoogleApi == null || !this.GoogleApi.IsConnected)
return; return;
var intent = GamesClass.Achievements.GetAchievementsIntent(this.GoogleApi); var intent = GamesClass.Achievements.GetAchievementsIntent(this.GoogleApi);
this.activity.StartActivityForResult(intent, ShowAchievementsRequest); this.activity.StartActivityForResult(intent, ShowAchievementsRequest);

View file

@ -48,7 +48,7 @@ namespace TouchyTickets {
return; return;
if (!this.condition.Invoke(GameImpl.Instance)) if (!this.condition.Invoke(GameImpl.Instance))
return; return;
GameImpl.Instance.Platform.GainAchievement(this); if (GameImpl.Instance.Platform.GainAchievement(this))
this.unlocked = true; this.unlocked = true;
} }

View file

@ -11,7 +11,7 @@ namespace TouchyTickets {
public abstract void OpenRateLink(); public abstract void OpenRateLink();
public abstract void GainAchievement(Achievement achievement); public abstract bool GainAchievement(Achievement achievement);
public abstract void ShowAchievements(); public abstract void ShowAchievements();

View file

@ -20,7 +20,7 @@ namespace iOS {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
public override void GainAchievement(Achievement achievement) { public override bool GainAchievement(Achievement achievement) {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }