Created
December 25, 2016 07:41
-
-
Save janishar/c960f7b0a9ef4f84f41a39e58d18494d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
public class DataManager { | |
private Context mContext; | |
private DbHelper mDbHelper; | |
private SharedPrefsHelper mSharedPrefsHelper; | |
@Inject | |
public DataManager(@ApplicationContext Context context, | |
DbHelper dbHelper, | |
SharedPrefsHelper sharedPrefsHelper) { | |
mContext = context; | |
mDbHelper = dbHelper; | |
mSharedPrefsHelper = sharedPrefsHelper; | |
} | |
public void saveAccessToken(String accessToken) { | |
mSharedPrefsHelper.put(SharedPrefsHelper.PREF_KEY_ACCESS_TOKEN, accessToken); | |
} | |
public String getAccessToken(){ | |
return mSharedPrefsHelper.get(SharedPrefsHelper.PREF_KEY_ACCESS_TOKEN, null); | |
} | |
public Long createUser(User user) throws Exception { | |
return mDbHelper.insertUser(user); | |
} | |
public User getUser(Long userId) throws Resources.NotFoundException, NullPointerException { | |
return mDbHelper.getUser(userId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's against architectural patterns because of injecting a God object (
DataManager
class here)