I have created an android app that has a Navigation Drawer with Fragments.
I then started with Social Media Integrations, that is Facebook, Twitter and Google Plus. I am using the official respective SDK's.
Not Social Media Sessions and calls to acquire data are made in the following activities:
Mainactivity
: Where if any of the sessions are lost or revoked, it needs to redirect toLoginActivity
. This is done during activity lifecycle methods.LoginActivity
: Where the permission are granted and redirects to Main after successNavigationDrawerFragment
: The Navigation drawer, I use this to display the user's profile image, name and email address.
In these 3 classes I am making calls to the respective SDK methods and managing the sessions so there is a lot of code duplication.
Also the 3 SDK's have significantly different ways of providing authentication.
- Facebook: uses the
UiLifeCycleHelper
that is implemented on all your standard lifecycle functions of an activity. - Google Plus: You have to implement
GooglePlay
store callbacks in the activity and create aGoogleApiClient
on all activities. - Twitter: Has less of a "taking over your app" attitude and uses retrofit in the same manner of a usual REST API call on android: with Retrofit. However you have to give permissions on every login.
So All of these functions for handling the different social media logins are included in all the required activities making the application code really bulky and hard to manage.
Do you have any suggestions on how to abstract these auth methods into a easily maintainable solutions that makes manging sessions easier? Would I be better off to have separate activities based on what login was used?
Aucun commentaire:
Enregistrer un commentaire