MrStahlfelge / gdx-gamesvcs

Easy integration of gameservices in your libGDX game: Google Play Games, Apple Game Center, Amazon GameCircle and more
Apache License 2.0
113 stars 20 forks source link

android-gpgs: Refactor GPGS Client code #47

Closed karivatj closed 2 years ago

karivatj commented 2 years ago

Hello,

Here is a proposal for a refactored version of android-gpgs client. The current version uses deprecated Google APIs and should be updated or eventually the code stops working.

I've updated all of the API calls with current versions as described in the Google docs.

All AsynTasks have been removed because the API calls use Tasks API which are asynchronous by default. No need for AsyncTasks as they might leak memory.

Remove obsolete interfaces from android-gpgs and remove unneeded method overrides.

Modify IGameServiceListener to include a Integer resultCode in the callback methods. This is useful to inform the client of the statuscode of the callback e.g. if operation was cancelled, a network error occurred etc. The result is especially important when the client requests a explicit sign out from the Game Service. If this happens we shouldn't try to connect to the server until the user explicitly requests to sign in.

Modify IGameService interface to add getPlayerData method. The method is implemented in android-gpgs client and allows the client to fetch player related data. I've added method stubs to other clients and made them throw UnsupportedOperationException exception if invoked.

Add new package playerdata and within the package create IPlayerData interface which describes the fields related to the player. Also, add IPlayerDataResponseListener interface which is used for player data update callbacks.

Finally, I noticed the build produces a lot of warnings because of missing Javadoc stuff. I added descriptions here and there to get rid of the warnings.

karivatj commented 2 years ago

This depends on PR #46

MrStahlfelge commented 2 years ago

Converted to draft because it depends on an unmerged PR. That being said, I think it is better to separate behaviour changes affecting all platforms and services and refactoring that only changes internal code to different PRs.

karivatj commented 2 years ago

Alrighty I will split these into different PR:s maybe this PR could be rejected in that case.