|
@ -99,6 +99,7 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
|
private MainActivity mainActivity; |
|
|
private MainActivity mainActivity; |
|
|
private boolean isMainActivity; |
|
|
private boolean isMainActivity; |
|
|
|
|
|
private boolean isUserConsentDialogShown; //Needed because sometimes onResume is being called twice
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
@ -128,9 +129,11 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
protected void onResume() { |
|
|
protected void onResume() { |
|
|
super.onResume(); |
|
|
super.onResume(); |
|
|
updateDrawer(); |
|
|
updateDrawer(); |
|
|
if (!sharedPreferences.getBoolean(getString(R.string.user_consent_shared_preference_key), false)) |
|
|
if (!sharedPreferences.getBoolean(getString(R.string.user_consent_shared_preference_key), false) && !isUserConsentDialogShown){ |
|
|
|
|
|
isUserConsentDialogShown=true; |
|
|
showUserConsentDialog(); |
|
|
showUserConsentDialog(); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onPause() { |
|
|
protected void onPause() { |
|
@ -389,7 +392,7 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
|
|
|
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
|
|
|
startLoginActivity(); |
|
|
startLoginActivity(); |
|
|
else |
|
|
else |
|
|
new LogoutTask().execute(); |
|
|
new LogoutTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); //Avoid delays between onPreExecute() and doInBackground()
|
|
|
} else if (drawerItem.equals(ABOUT_ID)) { |
|
|
} else if (drawerItem.equals(ABOUT_ID)) { |
|
|
if (!(BaseActivity.this instanceof AboutActivity)) { |
|
|
if (!(BaseActivity.this instanceof AboutActivity)) { |
|
|
Intent intent = new Intent(BaseActivity.this, AboutActivity.class); |
|
|
Intent intent = new Intent(BaseActivity.this, AboutActivity.class); |
|
@ -496,6 +499,7 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
if (mainActivity != null) |
|
|
if (mainActivity != null) |
|
|
mainActivity.updateTabs(); |
|
|
mainActivity.updateTabs(); |
|
|
progressDialog.dismiss(); |
|
|
progressDialog.dismiss(); |
|
|
|
|
|
//TODO: Redirect to Main only for some Activities (e.g. Topic, Board, Downloads)
|
|
|
//if (BaseActivity.this instanceof TopicActivity){
|
|
|
//if (BaseActivity.this instanceof TopicActivity){
|
|
|
Intent intent = new Intent(BaseActivity.this, MainActivity.class); |
|
|
Intent intent = new Intent(BaseActivity.this, MainActivity.class); |
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
|
|