forked from upstream-mirrors/OpenTracks
For FragmentDialog, always use the activity obtain during onCreate.
To prevent null pointer when user clicks a button.
This commit is contained in:
@@ -24,6 +24,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -36,17 +37,20 @@ public class AboutDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String ABOUT_DIALOG_TAG = "aboutDialog";
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.about, null);
|
||||
activity = getActivity();
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.about, null);
|
||||
TextView aboutVersion = (TextView) view.findViewById(R.id.about_version);
|
||||
aboutVersion.setText(SystemUtils.getMyTracksVersion(getActivity()));
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
aboutVersion.setText(SystemUtils.getMyTracksVersion(activity));
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EulaDialogFragment.newInstance(true).show(
|
||||
getActivity().getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
activity.getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.generic_ok, null)
|
||||
|
||||
+20
-16
@@ -26,52 +26,56 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A DialogFragment to check preferred units.
|
||||
*
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class CheckUnitsDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String CHECK_UNITS_DIALOG_TAG = "checkUnitsDialog";
|
||||
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
onDone();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
boolean defaultMetric = !defaultLocale.equals(Locale.US) && !defaultLocale.equals(Locale.UK);
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.metric_units_key, defaultMetric);
|
||||
PreferencesUtils.setBoolean(activity, R.string.metric_units_key, defaultMetric);
|
||||
final String metric = getString(R.string.settings_stats_units_metric);
|
||||
final String imperial = getString(R.string.settings_stats_units_imperial);
|
||||
final CharSequence[] items = defaultMetric ? new CharSequence[] { metric, imperial }
|
||||
: new CharSequence[] { imperial, metric };
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
return new AlertDialog.Builder(activity).setPositiveButton(
|
||||
R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.metric_units_key, items[position].equals(metric));
|
||||
activity, R.string.metric_units_key, items[position].equals(metric));
|
||||
onDone();
|
||||
}
|
||||
})
|
||||
.setSingleChoiceItems(items, 0, null)
|
||||
.setTitle(R.string.settings_stats_units_title).create();
|
||||
}).setSingleChoiceItems(items, 0, null).setTitle(R.string.settings_stats_units_title)
|
||||
.create();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tasks to perform when done.
|
||||
*/
|
||||
private void onDone() {
|
||||
EulaUtils.setShowCheckUnits(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
EulaUtils.setShowCheckUnits(activity);
|
||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
}
|
||||
+20
-16
@@ -28,6 +28,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
@@ -57,6 +58,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
return chooseUploadServiceDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
private SendRequest sendRequest;
|
||||
|
||||
private CheckBox mapsCheckBox;
|
||||
@@ -68,20 +70,22 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
sendRequest = getArguments().getParcelable(KEY_SEND_REQUEST);
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.choose_upload_service, null);
|
||||
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.choose_upload_service, null);
|
||||
|
||||
mapsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_maps);
|
||||
fusionTablesCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_fusion_tables);
|
||||
docsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_docs);
|
||||
|
||||
mapsCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
|
||||
activity, R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
|
||||
fusionTablesCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.send_to_fusion_tables_key,
|
||||
activity, R.string.send_to_fusion_tables_key,
|
||||
PreferencesUtils.SEND_TO_FUSION_TABLES_DEFAULT));
|
||||
docsCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
|
||||
activity, R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
|
||||
|
||||
mapsCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton button, boolean checked) {
|
||||
@@ -93,7 +97,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
|
||||
RadioButton newMapRadioButton = (RadioButton) view.findViewById(
|
||||
R.id.choose_upload_service_new_map);
|
||||
boolean defaultMapPublic = PreferencesUtils.getBoolean(getActivity(),
|
||||
boolean defaultMapPublic = PreferencesUtils.getBoolean(activity,
|
||||
R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
|
||||
newMapRadioButton.setText(defaultMapPublic ? R.string.send_google_new_public_map
|
||||
: R.string.send_google_new_unlisted_map);
|
||||
@@ -102,31 +106,31 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
R.id.choose_upload_service_existing_map);
|
||||
|
||||
updateMapsOption();
|
||||
if (PreferencesUtils.getBoolean(getActivity(), R.string.pick_existing_map_key,
|
||||
if (PreferencesUtils.getBoolean(activity, R.string.pick_existing_map_key,
|
||||
PreferencesUtils.PICK_EXISTING_MAP_DEFAULT)) {
|
||||
existingMapRadioButton.setChecked(true);
|
||||
} else {
|
||||
newMapRadioButton.setChecked(true);
|
||||
}
|
||||
|
||||
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
|
||||
return new AlertDialog.Builder(activity).setNegativeButton(R.string.generic_cancel, null)
|
||||
.setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.pick_existing_map_key, existingMapRadioButton.isChecked());
|
||||
activity, R.string.pick_existing_map_key, existingMapRadioButton.isChecked());
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.send_to_maps_key, mapsCheckBox.isChecked());
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.send_to_fusion_tables_key,
|
||||
activity, R.string.send_to_maps_key, mapsCheckBox.isChecked());
|
||||
PreferencesUtils.setBoolean(activity, R.string.send_to_fusion_tables_key,
|
||||
fusionTablesCheckBox.isChecked());
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.send_to_docs_key, docsCheckBox.isChecked());
|
||||
activity, R.string.send_to_docs_key, docsCheckBox.isChecked());
|
||||
if (mapsCheckBox.isChecked() || fusionTablesCheckBox.isChecked()
|
||||
|| docsCheckBox.isChecked()) {
|
||||
startNextActivity();
|
||||
} else {
|
||||
Toast.makeText(
|
||||
getActivity(), R.string.send_google_no_service_selected, Toast.LENGTH_LONG)
|
||||
activity, R.string.send_google_no_service_selected, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
@@ -152,7 +156,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
sendRequest.setSendDocs(docsCheckBox.isChecked());
|
||||
sendRequest.setNewMap(!existingMapRadioButton.isChecked());
|
||||
sendStats();
|
||||
Intent intent = IntentUtils.newIntent(getActivity(), AccountChooserActivity.class)
|
||||
Intent intent = IntentUtils.newIntent(activity, AccountChooserActivity.class)
|
||||
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
|
||||
startActivity(intent);
|
||||
}
|
||||
@@ -162,13 +166,13 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
*/
|
||||
private void sendStats() {
|
||||
if (sendRequest.isSendMaps()) {
|
||||
AnalyticsUtils.sendPageViews(getActivity(), "/send/maps");
|
||||
AnalyticsUtils.sendPageViews(activity, "/send/maps");
|
||||
}
|
||||
if (sendRequest.isSendFusionTables()) {
|
||||
AnalyticsUtils.sendPageViews(getActivity(), "/send/fusion_tables");
|
||||
AnalyticsUtils.sendPageViews(activity, "/send/fusion_tables");
|
||||
}
|
||||
if (sendRequest.isSendDocs()) {
|
||||
AnalyticsUtils.sendPageViews(getActivity(), "/send/docs");
|
||||
AnalyticsUtils.sendPageViews(activity, "/send/docs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -24,6 +24,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to delete all tracks.
|
||||
@@ -34,16 +35,19 @@ public class DeleteAllTrackDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String DELETE_ALL_TRACK_DIALOG_TAG = "deleteAllTrackDialog";
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return DialogUtils.createConfirmationDialog(getActivity(),
|
||||
activity = getActivity();
|
||||
return DialogUtils.createConfirmationDialog(activity,
|
||||
R.string.track_list_delete_all_confirm_message, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MyTracksProviderUtils.Factory.get(getActivity()).deleteAllTracks();
|
||||
MyTracksProviderUtils.Factory.get(activity).deleteAllTracks();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
+9
-5
@@ -28,6 +28,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to delete one marker.
|
||||
@@ -50,25 +51,28 @@ public class DeleteOneMarkerDialogFragment extends DialogFragment {
|
||||
return deleteOneMarkerDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return DialogUtils.createConfirmationDialog(getActivity(),
|
||||
activity = getActivity();
|
||||
return DialogUtils.createConfirmationDialog(activity,
|
||||
R.string.marker_delete_one_marker_confirm_message, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MyTracksProviderUtils.Factory.get(getActivity()).deleteWaypoint(
|
||||
MyTracksProviderUtils.Factory.get(activity).deleteWaypoint(
|
||||
getArguments().getLong(KEY_MARKER_ID),
|
||||
new DescriptionGeneratorImpl(getActivity()));
|
||||
new DescriptionGeneratorImpl(activity));
|
||||
}
|
||||
}).start();
|
||||
Intent intent = IntentUtils.newIntent(getActivity(), MarkerListActivity.class)
|
||||
Intent intent = IntentUtils.newIntent(activity, MarkerListActivity.class)
|
||||
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, getArguments().getLong(KEY_TRACK_ID));
|
||||
startActivity(intent);
|
||||
// Close the activity since its content can change after delete.
|
||||
getActivity().finish();
|
||||
activity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+8
-5
@@ -32,6 +32,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to delete one track.
|
||||
@@ -52,8 +53,6 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||
public TrackRecordingServiceConnection getTrackRecordingServiceConnection();
|
||||
}
|
||||
|
||||
private DeleteOneTrackCaller caller;
|
||||
|
||||
public static DeleteOneTrackDialogFragment newInstance(long trackId) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(KEY_TRACK_ID, trackId);
|
||||
@@ -63,6 +62,9 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||
return deleteOneTrackDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
private DeleteOneTrackCaller caller;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
@@ -75,12 +77,13 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return DialogUtils.createConfirmationDialog(getActivity(),
|
||||
activity = getActivity();
|
||||
return DialogUtils.createConfirmationDialog(activity,
|
||||
R.string.track_detail_delete_confirm_message, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final long trackId = getArguments().getLong(KEY_TRACK_ID);
|
||||
final Context context = getActivity();
|
||||
final Context context = activity;
|
||||
if (trackId == PreferencesUtils.getLong(context, R.string.recording_track_id_key)) {
|
||||
TrackRecordingServiceConnectionUtils.stopRecording(
|
||||
context, caller.getTrackRecordingServiceConnection(), false);
|
||||
@@ -94,7 +97,7 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||
Intent intent = IntentUtils.newIntent(context, TrackListActivity.class);
|
||||
startActivity(intent);
|
||||
// Close the activity since its content can change after delete
|
||||
getActivity().finish();
|
||||
activity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to show EULA.
|
||||
@@ -52,6 +53,8 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
return eulaDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
if (!getArguments().getBoolean(KEY_HAS_ACCEPTED)) {
|
||||
@@ -61,8 +64,10 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
|
||||
boolean hasAccepted = getArguments().getBoolean(KEY_HAS_ACCEPTED);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity)
|
||||
.setMessage(getEulaText())
|
||||
.setTitle(R.string.eula_title);
|
||||
|
||||
@@ -78,8 +83,8 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EulaUtils.setAcceptEula(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
EulaUtils.setAcceptEula(activity);
|
||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
});
|
||||
@@ -91,7 +96,7 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
* Exits the application.
|
||||
*/
|
||||
private void exitApp() {
|
||||
getActivity().finish();
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+9
-4
@@ -24,6 +24,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to configure frequency.
|
||||
@@ -50,19 +51,23 @@ public class FrequencyDialogFragment extends DialogFragment {
|
||||
return frequencyDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
|
||||
final int preferenceId = getArguments().getInt(KEY_PREFERENCE_ID);
|
||||
int defaultValue = getArguments().getInt(KEY_DEFAULT_VALUE);
|
||||
int titleId = getArguments().getInt(KEY_TITLE_ID);
|
||||
int frequencyValue = PreferencesUtils.getInt(getActivity(), preferenceId, defaultValue);
|
||||
int frequencyValue = PreferencesUtils.getInt(activity, preferenceId, defaultValue);
|
||||
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int listIndex = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||
PreferencesUtils.setInt(getActivity(), preferenceId, getFrequencyValue(listIndex));
|
||||
PreferencesUtils.setInt(activity, preferenceId, getFrequencyValue(listIndex));
|
||||
}
|
||||
})
|
||||
.setSingleChoiceItems(getFrequencyDisplayOptions(), getListIndex(frequencyValue), null)
|
||||
@@ -75,7 +80,7 @@ public class FrequencyDialogFragment extends DialogFragment {
|
||||
*/
|
||||
private String[] getFrequencyDisplayOptions() {
|
||||
boolean metricUnits = PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
|
||||
activity, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
|
||||
String[] values = getResources().getStringArray(R.array.frequency_values);
|
||||
String[] options = new String[values.length];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
|
||||
+6
-2
@@ -27,6 +27,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
@@ -38,9 +39,12 @@ public class InstallEarthDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String INSTALL_EARTH_DIALOG_TAG = "installEarthDialog";
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
activity = getActivity();
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setMessage(R.string.track_detail_install_earth_message)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@@ -51,7 +55,7 @@ public class InstallEarthDialogFragment extends DialogFragment {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(
|
||||
getActivity(), R.string.track_detail_install_earth_error, Toast.LENGTH_LONG)
|
||||
activity, R.string.track_detail_install_earth_error, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFrament to show the welcome info.
|
||||
@@ -35,6 +36,8 @@ public class WelcomeDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String WELCOME_DIALOG_TAG = "welcomeDialog";
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
onDone();
|
||||
@@ -42,7 +45,8 @@ public class WelcomeDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
activity = getActivity();
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@@ -55,8 +59,8 @@ public class WelcomeDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
private void onDone() {
|
||||
EulaUtils.setShowWelcome(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
EulaUtils.setShowWelcome(activity);
|
||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user