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")));
}
public override void GainAchievement(Achievement achievement) {
if (this.GoogleApi != null)
public override bool GainAchievement(Achievement achievement) {
if (this.GoogleApi != null && this.GoogleApi.IsConnected) {
GamesClass.Achievements.Unlock(this.GoogleApi, AchievementIds[achievement.Name]);
return true;
}
return false;
}
public override void ShowAchievements() {
if (this.GoogleApi == null)
if (this.GoogleApi == null || !this.GoogleApi.IsConnected)
return;
var intent = GamesClass.Achievements.GetAchievementsIntent(this.GoogleApi);
this.activity.StartActivityForResult(intent, ShowAchievementsRequest);

View file

@ -48,8 +48,8 @@ namespace TouchyTickets {
return;
if (!this.condition.Invoke(GameImpl.Instance))
return;
GameImpl.Instance.Platform.GainAchievement(this);
this.unlocked = true;
if (GameImpl.Instance.Platform.GainAchievement(this))
this.unlocked = true;
}
public static void Register(Achievement achievement) {

View file

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

View file

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