Skip to content

Instantly share code, notes, and snippets.

// Implement the addName IBAction
@IBAction func addName(_ sender: UIBarButtonItem) {
let alert = UIAlertController(title: "New Name",
message: "Add a new name",
preferredStyle: .alert)
let saveAction = UIAlertAction(title: "Save",
style: .default) {
[unowned self] action in
@crgg
crgg / intent_map_android.java
Created January 20, 2020 19:01 — forked from javymarmol/intent_map_android.java
Intent para abrir mapa en android
//Con latitude y longitude
Uri gmmIntentUri = Uri.parse("geo:0,0" + "?q=" + trayecto.getLatitude() + "," + trayecto.getLongitude());
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
// Con dirección
Uri gmmIntentUri = Uri.parse("geo:0,0" + "?q=" + trayecto.getAddress());
@crgg
crgg / restoringFragment.java
Created May 10, 2018 16:04 — forked from javymarmol/restoringFragment.java
restore existing fragment
private void changeFragment(Fragment f, String tag) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (fragmentManager.findFragmentByTag(tag) == null) {
fragmentTransaction.add(R.id.frameContainer, f, tag);
} else {
f = fragmentManager.findFragmentByTag(tag);
fragmentTransaction.replace(R.id.frameContainer, f, tag);
}
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
@crgg
crgg / restoringFragment.java
Created May 10, 2018 16:04 — forked from javymarmol/restoringFragment.java
restore existing fragment
private void changeFragment(Fragment f, String tag) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (fragmentManager.findFragmentByTag(tag) == null) {
fragmentTransaction.add(R.id.frameContainer, f, tag);
} else {
f = fragmentManager.findFragmentByTag(tag);
fragmentTransaction.replace(R.id.frameContainer, f, tag);
}
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();