1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Improve readability of up navigation code in EventDetailsActivity and add missing flags in the Manifest file for it.

This commit is contained in:
Christophe Beyls 2015-02-04 23:30:13 +01:00
parent 45b162246c
commit 7f8a8aa5cb
2 changed files with 28 additions and 17 deletions

View file

@ -46,13 +46,16 @@
</activity>
<activity
android:name=".activities.TrackScheduleActivity"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.MainActivity"/>
</activity>
<activity android:name=".activities.TrackScheduleEventActivity"/>
<activity android:name=".activities.EventDetailsActivity">
<activity
android:name=".activities.EventDetailsActivity"
android:parentActivityName=".activities.TrackScheduleActivity">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
@ -60,6 +63,9 @@
<data android:mimeType="application/be.digitalia.fosdem"/>
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.TrackScheduleActivity"/>
</activity>
<activity
android:name=".activities.PersonInfoActivity"

View file

@ -26,7 +26,6 @@ import be.digitalia.fosdem.utils.NfcUtils.CreateNfcAppDataCallback;
* Displays a single event passed either as a complete Parcelable object in extras or as an id in data.
*
* @author Christophe Beyls
*
*/
public class EventDetailsActivity extends ActionBarActivity implements LoaderCallbacks<Event>, CreateNfcAppDataCallback {
@ -75,18 +74,24 @@ public class EventDetailsActivity extends ActionBarActivity implements LoaderCal
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// Navigate up to the track associated to this event
// Navigate up to the track associated with this event
Intent upIntent = new Intent(this, TrackScheduleActivity.class);
upIntent.putExtra(TrackScheduleActivity.EXTRA_DAY, event.getDay());
upIntent.putExtra(TrackScheduleActivity.EXTRA_TRACK, event.getTrack());
upIntent.putExtra(TrackScheduleActivity.EXTRA_FROM_EVENT_ID, event.getId());
upIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
finish();
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
TaskStackBuilder.create(this).addNextIntent(new Intent(this, MainActivity.class)).addNextIntent(upIntent).startActivities();
TaskStackBuilder.create(this)
.addNextIntentWithParentStack(upIntent)
.startActivities();
finish();
} else {
// Replicate the compatibility implementation of NavUtils.navigateUpTo()
// to ensure the parent Activity is always launched
// even if not present on the back stack.
upIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(upIntent);
finish();
}
return true;
}