Browse Source

User can navigate to his profile from drawer

pull/24/head
Ezerous 8 years ago
parent
commit
91ddfce5e3
  1. 24
      app/src/main/java/gr/thmmy/mthmmy/activities/base/BaseActivity.java
  2. 3
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
  3. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java

24
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.AboutActivity;
import gr.thmmy.mthmmy.activities.LoginActivity; import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.activities.main.MainActivity; import gr.thmmy.mthmmy.activities.main.MainActivity;
import gr.thmmy.mthmmy.activities.profile.ProfileActivity;
import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.session.SessionManager;
import okhttp3.OkHttpClient; 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 public abstract class BaseActivity extends AppCompatActivity
{ {
@ -129,6 +133,7 @@ public abstract class BaseActivity extends AppCompatActivity
drawer.closeDrawer(); drawer.closeDrawer();
} }
public static OkHttpClient getClient() public static OkHttpClient getClient()
{ {
return client; return client;
@ -193,8 +198,21 @@ public abstract class BaseActivity extends AppCompatActivity
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override @Override
public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) { public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
//TODO: display profile stuff if(sessionManager.isLoggedIn())
return true; //don't close drawer (for now) {
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(); .build();

3
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.activities.base.BaseFragment;
import gr.thmmy.mthmmy.data.Board; import gr.thmmy.mthmmy.data.Board;
import gr.thmmy.mthmmy.data.Category; import gr.thmmy.mthmmy.data.Category;
import gr.thmmy.mthmmy.data.TopicSummary;
import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.session.SessionManager;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report; import mthmmy.utils.Report;
@ -36,8 +35,6 @@ import okhttp3.HttpUrl;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import static gr.thmmy.mthmmy.session.SessionManager.LOGGED_IN;
/** /**
* A {@link BaseFragment} subclass. * A {@link BaseFragment} subclass.
* Activities that contain this fragment must implement the * Activities that contain this fragment must implement the

1
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.annotation.SuppressLint;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;

Loading…
Cancel
Save