File tree Expand file tree Collapse file tree 5 files changed +30
-5
lines changed
app/src/main/java/com/nathansdev/stack Expand file tree Collapse file tree 5 files changed +30
-5
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import android.content.Intent
44import android.net.Uri
55import android.os.Bundle
66import android.view.View
7+ import android.webkit.CookieManager
8+ import android.webkit.CookieSyncManager
79import android.widget.Button
810import android.widget.ProgressBar
911import 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
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 1212import android .view .LayoutInflater ;
1313import android .view .View ;
1414import android .view .ViewGroup ;
15- import android .webkit .CookieManager ;
1615
1716import com .nathansdev .stack .AppConstants ;
1817import 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 ());
Original file line number Diff line number Diff 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 ();
You can’t perform that action at this time.
0 commit comments