Create an IntentUtils.newIntent utility method to create an intent

with FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_NEW_TASK.
This commit is contained in:
Jimmy Shih
2012-04-19 11:24:40 -07:00
parent c8deb63de9
commit 1676f19830
31 changed files with 262 additions and 195 deletions
@@ -20,6 +20,7 @@ import com.google.android.apps.mytracks.MarkerListActivity;
import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.maps.mytracks.R;
import android.app.Dialog;
@@ -37,10 +38,12 @@ public class DeleteOneMarkerDialogFragment extends DialogFragment {
public static final String DELETE_ONE_MARKER_DIALOG_TAG = "deleteOneMarkerDialog";
private static final String KEY_MARKER_ID = "markerId";
private static final String KEY_TRACK_ID = "trackId";
public static DeleteOneMarkerDialogFragment newInstance(long markerId) {
public static DeleteOneMarkerDialogFragment newInstance(long markerId, long trackId) {
Bundle bundle = new Bundle();
bundle.putLong(KEY_MARKER_ID, markerId);
bundle.putLong(KEY_TRACK_ID, trackId);
DeleteOneMarkerDialogFragment deleteOneMarkerDialogFragment = new DeleteOneMarkerDialogFragment();
deleteOneMarkerDialogFragment.setArguments(bundle);
@@ -55,8 +58,9 @@ public class DeleteOneMarkerDialogFragment extends DialogFragment {
public void onClick(DialogInterface dialog, int which) {
MyTracksProviderUtils.Factory.get(getActivity()).deleteWaypoint(
getArguments().getLong(KEY_MARKER_ID), new DescriptionGeneratorImpl(getActivity()));
startActivity(new Intent(getActivity(), MarkerListActivity.class).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
Intent intent = IntentUtils.newIntent(getActivity(), MarkerListActivity.class)
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, getArguments().getLong(KEY_TRACK_ID));
startActivity(intent);
}
});
}
@@ -19,6 +19,7 @@ package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.TrackListActivity;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.maps.mytracks.R;
import android.app.Dialog;
@@ -54,8 +55,8 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
public void onClick(DialogInterface dialog, int which) {
MyTracksProviderUtils.Factory.get(getActivity())
.deleteTrack(getArguments().getLong(KEY_TRACK_ID));
startActivity(new Intent(getActivity(), TrackListActivity.class).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
Intent intent = IntentUtils.newIntent(getActivity(), TrackListActivity.class);
startActivity(intent);
}
});
}
@@ -45,7 +45,8 @@ public class InstallEarthDialogFragment extends DialogFragment {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent().setData(Uri.parse(SaveActivity.GOOGLE_EARTH_MARKET_URL)));
Intent intent = new Intent().setData(Uri.parse(SaveActivity.GOOGLE_EARTH_MARKET_URL));
startActivity(intent);
}
})
.create();
@@ -239,7 +239,8 @@ public class MapFragment extends Fragment
@Override
public void onClick(View v) {
if (v == messagePane) {
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
}