mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Issue-944: Fix for same activity getting instantiated multiple times
This is happening because the finish() method on current activity is not called before switching to the new activity
This commit is contained in:
parent
c568f8180c
commit
2c1f20f1fd
1 changed files with 12 additions and 8 deletions
|
|
@ -91,35 +91,36 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
|
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
final int itemId = item.getItemId();
|
||||||
|
switch (itemId) {
|
||||||
case R.id.action_home:
|
case R.id.action_home:
|
||||||
drawerLayout.closeDrawer(navigationView);
|
drawerLayout.closeDrawer(navigationView);
|
||||||
if (!(this instanceof ContributionsActivity)) {
|
if (!(this instanceof ContributionsActivity)) {
|
||||||
ContributionsActivity.startYourself(this);
|
ContributionsActivity.startYourself(this);
|
||||||
}
|
}
|
||||||
return true;
|
break;
|
||||||
case R.id.action_nearby:
|
case R.id.action_nearby:
|
||||||
drawerLayout.closeDrawer(navigationView);
|
drawerLayout.closeDrawer(navigationView);
|
||||||
if (!(this instanceof NearbyActivity)) {
|
if (!(this instanceof NearbyActivity)) {
|
||||||
NearbyActivity.startYourself(this);
|
NearbyActivity.startYourself(this);
|
||||||
}
|
}
|
||||||
return true;
|
break;
|
||||||
case R.id.action_about:
|
case R.id.action_about:
|
||||||
drawerLayout.closeDrawer(navigationView);
|
drawerLayout.closeDrawer(navigationView);
|
||||||
if (!(this instanceof AboutActivity)) {
|
if (!(this instanceof AboutActivity)) {
|
||||||
AboutActivity.startYourself(this);
|
AboutActivity.startYourself(this);
|
||||||
}
|
}
|
||||||
return true;
|
break;
|
||||||
case R.id.action_settings:
|
case R.id.action_settings:
|
||||||
drawerLayout.closeDrawer(navigationView);
|
drawerLayout.closeDrawer(navigationView);
|
||||||
if (!(this instanceof SettingsActivity)) {
|
if (!(this instanceof SettingsActivity)) {
|
||||||
SettingsActivity.startYourself(this);
|
SettingsActivity.startYourself(this);
|
||||||
}
|
}
|
||||||
return true;
|
break;
|
||||||
case R.id.action_introduction:
|
case R.id.action_introduction:
|
||||||
drawerLayout.closeDrawer(navigationView);
|
drawerLayout.closeDrawer(navigationView);
|
||||||
WelcomeActivity.startYourself(this);
|
WelcomeActivity.startYourself(this);
|
||||||
return true;
|
break;
|
||||||
case R.id.action_feedback:
|
case R.id.action_feedback:
|
||||||
drawerLayout.closeDrawer(navigationView);
|
drawerLayout.closeDrawer(navigationView);
|
||||||
Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
|
Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
|
||||||
|
|
@ -134,7 +135,7 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
Toast.makeText(this, R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
return true;
|
break;
|
||||||
case R.id.action_logout:
|
case R.id.action_logout:
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setMessage(R.string.logout_verification)
|
.setMessage(R.string.logout_verification)
|
||||||
|
|
@ -146,10 +147,13 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.no, (dialog, which) -> dialog.cancel())
|
.setNegativeButton(R.string.no, (dialog, which) -> dialog.cancel())
|
||||||
.show();
|
.show();
|
||||||
return true;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Timber.e("Unknown option [%s] selected from the navigation menu", itemId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
this.finish();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BaseLogoutListener implements CommonsApplication.LogoutListener {
|
private class BaseLogoutListener implements CommonsApplication.LogoutListener {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue