Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 00383e0

Browse files
author
Sabari
committed
cookie clear issue fixed.
1 parent 572e8fb commit 00383e0

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

‎app/src/main/java/com/nathansdev/stack/AppConstants.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public final class AppConstants {
2121
public static final String EXPIRES = "expires";
2222
public static final String ERROR = "error";
2323
public static final String KEY = "key";
24+
public static final String IS_JUST_LOGGED_OUT = "isJustLoggedOut";
2425

2526
public static final Integer SOCKET_TIME_OUT = 5001;
2627
public static final Integer IO_EXCEPTION = 5002;

‎app/src/main/java/com/nathansdev/stack/auth/LoginActivity.kt‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import android.content.Intent
44
import android.net.Uri
55
import android.os.Bundle
66
import android.view.View
7+
import android.webkit.CookieManager
8+
import android.webkit.CookieSyncManager
79
import android.widget.Button
810
import android.widget.ProgressBar
911
import com.nathansdev.stack.AppConstants
@@ -42,12 +44,25 @@ class LoginActivity : BaseActivity() {
4244
showProgress()
4345
}
4446
buttonSkip?.setOnClickListener { routeToHome() }
45-
Timber.d("onCreate")
47+
checkLoggedOutIntent()
48+
}
49+
50+
private fun checkLoggedOutIntent() {
51+
val isJusLoggedOut = intent?.extras?.getBoolean(AppConstants.IS_JUST_LOGGED_OUT)
52+
when (isJusLoggedOut) {
53+
true -> clearCookies()
54+
}
55+
}
56+
57+
private fun clearCookies() {
58+
Timber.d("clearCookies")
59+
CookieSyncManager.createInstance(this)
60+
val cookieManager = CookieManager.getInstance()
61+
cookieManager.removeAllCookie()
4662
}
4763

4864
override fun onResume() {
4965
super.onResume()
50-
Timber.d("onResume %s", intent)
5166
handleIntent()
5267
}
5368

‎app/src/main/java/com/nathansdev/stack/home/HomeActivity.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ private void handleProfileMenuClicked() {
193193

194194
private void handleLogOutCompleted() {
195195
Intent intent = new Intent(this, LoginActivity.class);
196+
intent.putExtra(AppConstants.IS_JUST_LOGGED_OUT, true);
196197
startActivity(intent);
197198
finish();
198199
}
@@ -205,6 +206,7 @@ private void handleBackPressed() {
205206
if (profileViewContainer.getVisibility() == View.VISIBLE) {
206207
Utils.captureTransitionSlide(rootView);
207208
profileViewContainer.setVisibility(View.INVISIBLE);
209+
getProfileFrag().cleanUp();
208210
} else {
209211
super.onBackPressed();
210212
}

‎app/src/main/java/com/nathansdev/stack/home/feed/ProfileFragment.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import android.view.LayoutInflater;
1313
import android.view.View;
1414
import android.view.ViewGroup;
15-
import android.webkit.CookieManager;
1615

1716
import com.nathansdev.stack.AppConstants;
1817
import com.nathansdev.stack.AppPreferences;
@@ -184,11 +183,13 @@ public void showUser(Owner owner) {
184183
public void onLoggedOut() {
185184
preferences.setIsLoggedIn(false);
186185
preferences.delete();
187-
CookieManager cookieManager = CookieManager.getInstance();
188-
cookieManager.removeAllCookie();
189186
eventBus.send(new Pair<>(AppEvents.LOGOUT_COMPLETED, null));
190187
}
191188

189+
public void cleanUp(){
190+
myFeedFragment.cleanUp();
191+
}
192+
192193
public void logOutUser() {
193194
mask.setVisibility(View.VISIBLE);
194195
presenter.invalidateAccessToken(preferences.getAccessToken());

‎app/src/main/java/com/nathansdev/stack/home/profile/MyFeedFragment.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ public void onQuestionsLoaded(List<QuestionsAdapterRow> rows) {
8888
adapter.notifyDataSetChanged();
8989
}
9090

91+
public void cleanUp() {
92+
if (dataset != null) {
93+
dataset.clearDataSet();
94+
}
95+
}
96+
9197
@Override
9298
public void onDestroyView() {
9399
super.onDestroyView();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /