From 91ddfce5e3a867330424fa64945bebda2b52a1c8 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Fri, 6 Jan 2017 13:09:51 +0200 Subject: [PATCH] User can navigate to his profile from drawer --- .../mthmmy/activities/base/BaseActivity.java | 24 ++++++++++++++++--- .../activities/main/forum/ForumFragment.java | 3 --- .../latestPosts/LatestPostsAdapter.java | 1 - 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/base/BaseActivity.java index 24242eef..c0df0b16 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/base/BaseActivity.java @@ -40,10 +40,14 @@ import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.activities.AboutActivity; import gr.thmmy.mthmmy.activities.LoginActivity; import gr.thmmy.mthmmy.activities.main.MainActivity; +import gr.thmmy.mthmmy.activities.profile.ProfileActivity; import gr.thmmy.mthmmy.session.SessionManager; import okhttp3.OkHttpClient; -import static gr.thmmy.mthmmy.session.SessionManager.LOGGED_IN; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_THUMBNAIL_URL; +import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_USERNAME; public abstract class BaseActivity extends AppCompatActivity { @@ -129,6 +133,7 @@ public abstract class BaseActivity extends AppCompatActivity drawer.closeDrawer(); } + public static OkHttpClient getClient() { return client; @@ -193,8 +198,21 @@ public abstract class BaseActivity extends AppCompatActivity .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { @Override public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) { - //TODO: display profile stuff - return true; //don't close drawer (for now) + if(sessionManager.isLoggedIn()) + { + Intent intent = new Intent(BaseActivity.this, ProfileActivity.class); + Bundle extras = new Bundle(); + extras.putString(BUNDLE_PROFILE_URL, "https://www.thmmy.gr/smf/index.php?action=profile"); + if(!sessionManager.hasAvatar()) + extras.putString(BUNDLE_THUMBNAIL_URL, ""); + else + extras.putString(BUNDLE_THUMBNAIL_URL, sessionManager.getAvatarLink()); + extras.putString(BUNDLE_USERNAME, sessionManager.getUsername()); + intent.putExtras(extras); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + return false; } }) .build(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java index 416c75a9..9ad75ed4 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java @@ -28,7 +28,6 @@ import gr.thmmy.mthmmy.activities.base.BaseActivity; import gr.thmmy.mthmmy.activities.base.BaseFragment; import gr.thmmy.mthmmy.data.Board; import gr.thmmy.mthmmy.data.Category; -import gr.thmmy.mthmmy.data.TopicSummary; import gr.thmmy.mthmmy.session.SessionManager; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import mthmmy.utils.Report; @@ -36,8 +35,6 @@ import okhttp3.HttpUrl; import okhttp3.Request; import okhttp3.Response; -import static gr.thmmy.mthmmy.session.SessionManager.LOGGED_IN; - /** * A {@link BaseFragment} subclass. * Activities that contain this fragment must implement the diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java index 273ed1b4..737e4024 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java @@ -2,7 +2,6 @@ package gr.thmmy.mthmmy.activities.profile.latestPosts; import android.annotation.SuppressLint; import android.support.v7.widget.RecyclerView; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;