Search in sources :

Example 1 with User

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);
}
Also used : BottomSheetMessage(com.mxt.anitrend.view.sheet.BottomSheetMessage) User(com.mxt.anitrend.model.entity.anilist.User)

Example 2 with User

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;
    }
}
Also used : User(com.mxt.anitrend.model.entity.anilist.User) NotificationActivity(com.mxt.anitrend.view.activity.detail.NotificationActivity) Intent(android.content.Intent)

Example 3 with User

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();
    }
}
Also used : User(com.mxt.anitrend.model.entity.anilist.User) DatabaseHelper(com.mxt.anitrend.data.DatabaseHelper) IOException(java.io.IOException)

Aggregations

User (com.mxt.anitrend.model.entity.anilist.User)3 Intent (android.content.Intent)1 DatabaseHelper (com.mxt.anitrend.data.DatabaseHelper)1 NotificationActivity (com.mxt.anitrend.view.activity.detail.NotificationActivity)1 BottomSheetMessage (com.mxt.anitrend.view.sheet.BottomSheetMessage)1 IOException (java.io.IOException)1