From b33ac8c5d253613941d21994a2a4eaa91ffa8a89 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sat, 4 Nov 2017 16:36:57 +0200 Subject: [PATCH] Fixes for profile online dot and logout --- .../activities/profile/ProfileActivity.java | 27 +++++++++++++------ .../gr/thmmy/mthmmy/base/BaseActivity.java | 5 ++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index 24600df5..a83fc610 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java @@ -172,7 +172,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(profileUrl)); if (!target.is(ThmmyPage.PageCategory.PROFILE)) { - Timber.e("Bundle came with a non profile url!\nUrl:\n%s" , profileUrl); + Timber.e("Bundle came with a non profile url!\nUrl:\n%s", profileUrl); Toast.makeText(this, "An error has occurred\n Aborting.", Toast.LENGTH_SHORT).show(); finish(); } @@ -217,6 +217,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment //Class variables Document profilePage; Spannable usernameSpan; + Boolean isOnline = false; protected void onPreExecute() { progressBar.setVisibility(ProgressBar.VISIBLE); @@ -261,13 +262,17 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); usernameSpan.setSpan(new RelativeSizeSpan(0.45f) , 0, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + if (contentsTable.toString().contains("Online") || contentsTable.toString().contains("Συνδεδεμένος")) { - usernameSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#4CAF50")) - , 0, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - } else - usernameSpan.setSpan(new ForegroundColorSpan(Color.GRAY) - , 0, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + isOnline = true; + } else { + isOnline = false; + /*usernameSpan.setSpan(new ForegroundColorSpan(Color.GRAY) + , 0, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);*/ + } + usernameSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#26A69A")) + , 2, usernameSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } return true; } catch (SSLHandshakeException e) { @@ -290,8 +295,14 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment if (pmFAB.getVisibility() != View.GONE) pmFAB.setEnabled(true); progressBar.setVisibility(ProgressBar.INVISIBLE); - if (usernameSpan != null) usernameView.setText(usernameSpan); - else if (usernameView.getText() != username) usernameView.setText(username); + if (usernameSpan != null) { + if (isOnline) { + usernameView.setTextColor(Color.parseColor("#4CAF50")); + } else { + usernameView.setTextColor(Color.GRAY); + } + usernameView.setText(usernameSpan); + } else if (usernameView.getText() != username) usernameView.setText(username); if (thumbnailUrl != null && !Objects.equals(thumbnailUrl, "")) //noinspection ConstantConditions Picasso.with(getApplicationContext()) 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 6c77c5ec..efc78db9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -411,6 +411,11 @@ public abstract class BaseActivity extends AppCompatActivity { if (mainActivity != null) mainActivity.updateTabs(); progressDialog.dismiss(); + //if (BaseActivity.this instanceof TopicActivity){ + Intent intent = new Intent(BaseActivity.this, MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + //} } } //-----------------------------------------LOGOUT END-----------------------------------------------