From e53264b6d60b6a1e6bb2732a1867a994b9310320 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 25 Oct 2017 20:27:29 +0300 Subject: [PATCH] Default Avatar when user has none Disabled topic title's scrollability --- .../activities/topic/TopicActivity.java | 1 + .../gr/thmmy/mthmmy/base/BaseActivity.java | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 0df26fb0..8396a697 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -214,6 +214,7 @@ public class TopicActivity extends BaseActivity { toolbarTitle.setMarqueeRepeatLimit(-1); toolbarTitle.setText(topicTitle); toolbarTitle.setSelected(true); + toolbarTitle.setEnabled(false); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index 6a837038..1724d0f7 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -358,14 +358,15 @@ public abstract class BaseActivity extends AppCompatActivity { { drawer.removeItem(DOWNLOADS_ID); loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login - profileDrawerItem.withName(sessionManager.getUsername()).withIcon(new IconicsDrawable(this) - .icon(FontAwesome.Icon.faw_user) - .paddingDp(10) - .color(ContextCompat.getColor(this, R.color.primary_light)) - .backgroundColor(ContextCompat.getColor(this, R.color.primary))); + profileDrawerItem.withName(sessionManager.getUsername()); + setDefaultAvatar(); } else { loginLogoutItem.withName(R.string.logout).withIcon(logoutIcon); //Swap login with logout - profileDrawerItem.withName(sessionManager.getUsername()).withIcon(sessionManager.getAvatarLink()); + profileDrawerItem.withName(sessionManager.getUsername()); + if(sessionManager.hasAvatar()) + profileDrawerItem.withIcon(sessionManager.getAvatarLink()); + else + setDefaultAvatar(); } accountHeader.updateProfile(profileDrawerItem); drawer.updateItem(loginLogoutItem); @@ -373,6 +374,13 @@ public abstract class BaseActivity extends AppCompatActivity { } } + private void setDefaultAvatar() { + profileDrawerItem.withIcon(new IconicsDrawable(this) + .icon(FontAwesome.Icon.faw_user) + .paddingDp(10) + .color(ContextCompat.getColor(this, R.color.primary_light)) + .backgroundColor(ContextCompat.getColor(this, R.color.primary))); + } //-------------------------------------------LOGOUT-------------------------------------------------