use of com.mxt.anitrend.model.entity.anilist.User in project anitrend-app by AniTrend.
the class MainActivity method setupUserItems.
private void setupUserItems() {
User user;
if ((user = getPresenter().getDatabase().getCurrentUser()) != null) {
mUserName.setText(user.getName());
mUserAvatar.setImageSrc(user.getAvatar().getLarge());
HeaderImageView.setImage(mHeaderView, user.getBannerImage());
if (getPresenter().getApplicationPref().shouldShowTipFor(KeyUtil.KEY_LOGIN_TIP)) {
NotifyUtil.createLoginToast(MainActivity.this, user);
getPresenter().getApplicationPref().disableTipFor(KeyUtil.KEY_LOGIN_TIP);
mBottomSheet = new BottomSheetMessage.Builder().setText(R.string.login_message).setTitle(R.string.login_title).setNegativeText(R.string.Ok).build();
showBottomSheet();
}
Crashlytics.setUserIdentifier(user.getName());
getApplicationBase().getAnalytics().setUserId(user.getName());
}
mAccountLogin.setVisible(false);
mSignOutProfile.setVisible(true);
mManageMenu.setVisible(true);
mHomeFeed.setVisible(true);
}
use of com.mxt.anitrend.model.entity.anilist.User in project anitrend-app by AniTrend.
the class MainActivity method onClick.
@Override
public void onClick(View view) {
switch(view.getId()) {
case R.id.banner_clickable:
if (getPresenter().getApplicationPref().isAuthenticated()) {
Intent intent = new Intent(this, ProfileActivity.class);
intent.putExtra(KeyUtil.arg_userName, getPresenter().getDatabase().getCurrentUser().getName());
CompatUtil.startSharedImageTransition(MainActivity.this, mHeaderView, intent, R.string.transition_user_banner);
} else
onNavigate(R.id.nav_sign_in);
break;
default:
User current = getPresenter().getDatabase().getCurrentUser();
current.setUnreadNotificationCount(0);
getPresenter().getDatabase().saveCurrentUser(current);
startActivity(new Intent(MainActivity.this, NotificationActivity.class));
break;
}
}
use of com.mxt.anitrend.model.entity.anilist.User in project anitrend-app by AniTrend.
the class NotificationSyncTask method checkNotificationCount.
/**
* Check the notification count for the current user
* @return unread notification count
*/
private void checkNotificationCount(UserModel userModel) {
try {
Response<User> response = userModel.getCurrentUser(GraphUtil.getDefaultQuery(false)).execute();
if (response.isSuccessful() && (user = response.body()) != null) {
DatabaseHelper databaseHelper = presenter.getDatabase();
databaseHelper.saveCurrentUser(user);
} else
Log.e(TAG, ErrorUtil.getError(response));
} catch (IOException e) {
Log.e(TAG, e.getLocalizedMessage());
e.printStackTrace();
}
}
Aggregations