blob: f1ffc1dcea6a96b3eb045576334607a86ec91ec9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package cgeo.geocaching;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.Window;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.activity.ActivityMixin;
public class WaypointPopup extends AbstractActivity {
private int waypointId = 0;
private String geocode;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
this.setTheme(ActivityMixin.getDialogTheme());
final Bundle extras = getIntent().getExtras();
if (extras != null) {
waypointId = extras.getInt(Intents.EXTRA_WAYPOINT_ID);
geocode = extras.getString(Intents.EXTRA_GEOCODE);
}
showDialog();
}
public static void startActivity(final Context context, final int waypointId, final String geocode) {
final Intent popupIntent = new Intent(context, WaypointPopup.class);
popupIntent.putExtra(Intents.EXTRA_WAYPOINT_ID, waypointId);
popupIntent.putExtra(Intents.EXTRA_GEOCODE, geocode);
context.startActivity(popupIntent);
}
void showDialog() {
// DialogFragment.show() will take care of adding the fragment
// in a transaction. We also want to remove any currently showing
// dialog, so make our own transaction and take care of that here.
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
// Create and show the dialog.
DialogFragment newFragment = WaypointPopupFragment.newInstance(geocode, waypointId);
newFragment.show(ft, "dialog");
}
}
|