forked from penguin86/luna-tracker
		
	Implemented event deletion
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
				
			|||||||
package it.danieleverducci.lunatracker
 | 
					package it.danieleverducci.lunatracker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.content.DialogInterface
 | 
				
			||||||
import android.content.Intent
 | 
					import android.content.Intent
 | 
				
			||||||
import android.os.Bundle
 | 
					import android.os.Bundle
 | 
				
			||||||
import android.os.Handler
 | 
					import android.os.Handler
 | 
				
			||||||
@@ -306,9 +307,11 @@ class MainActivity : AppCompatActivity() {
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
        dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes).setText(event.notes)
 | 
					        dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes).setText(event.notes)
 | 
				
			||||||
        d.setView(dialogView)
 | 
					        d.setView(dialogView)
 | 
				
			||||||
        d.setPositiveButton(android.R.string.ok) { dialogInterface, i -> dialogInterface.dismiss() }
 | 
					        d.setPositiveButton(R.string.dialog_event_detail_save_button) { dialogInterface, i -> dialogInterface.dismiss() }
 | 
				
			||||||
 | 
					        d.setNeutralButton(R.string.dialog_event_detail_delete_button) { dialogInterface, i -> deleteEvent(event) }
 | 
				
			||||||
        val alertDialog = d.create()
 | 
					        val alertDialog = d.create()
 | 
				
			||||||
        alertDialog.show()
 | 
					        alertDialog.show()
 | 
				
			||||||
 | 
					        alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setTextColor(ContextCompat.getColor(this, R.color.danger))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fun showAddLogbookDialog(requestedByUser: Boolean) {
 | 
					    fun showAddLogbookDialog(requestedByUser: Boolean) {
 | 
				
			||||||
@@ -520,6 +523,18 @@ class MainActivity : AppCompatActivity() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fun deleteEvent(event: LunaEvent) {
 | 
				
			||||||
 | 
					        // Update view
 | 
				
			||||||
 | 
					        savingEvent(true)
 | 
				
			||||||
 | 
					        adapter.items.remove(event)
 | 
				
			||||||
 | 
					        adapter.notifyDataSetChanged()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Update data
 | 
				
			||||||
 | 
					        setLoading(true)
 | 
				
			||||||
 | 
					        logbook.logs.remove(event)
 | 
				
			||||||
 | 
					        saveLogbook()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Saves the logbook. If saving while adding an event, please specify the event so in case
 | 
					     * Saves the logbook. If saving while adding an event, please specify the event so in case
 | 
				
			||||||
     * of error can be removed from the list.
 | 
					     * of error can be removed from the list.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,6 +80,8 @@
 | 
				
			|||||||
    <string name="log_notes_dialog_note_hint">Inserisci le note</string>
 | 
					    <string name="log_notes_dialog_note_hint">Inserisci le note</string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <string name="dialog_event_detail_title">Dettaglio evento</string>
 | 
					    <string name="dialog_event_detail_title">Dettaglio evento</string>
 | 
				
			||||||
 | 
					    <string name="dialog_event_detail_save_button">Salva</string>
 | 
				
			||||||
 | 
					    <string name="dialog_event_detail_delete_button">Elimina</string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <string name="dialog_add_logbook_title">Aggiungi diario</string>
 | 
					    <string name="dialog_add_logbook_title">Aggiungi diario</string>
 | 
				
			||||||
    <string name="dialog_add_logbook_logbookname">👶 Nome del diario</string>
 | 
					    <string name="dialog_add_logbook_logbookname">👶 Nome del diario</string>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -103,6 +103,8 @@
 | 
				
			|||||||
    <string name="measurement_unit_temperature_base_metric" translatable="false">°C</string>
 | 
					    <string name="measurement_unit_temperature_base_metric" translatable="false">°C</string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <string name="dialog_event_detail_title">Event detail</string>
 | 
					    <string name="dialog_event_detail_title">Event detail</string>
 | 
				
			||||||
 | 
					    <string name="dialog_event_detail_save_button">Save</string>
 | 
				
			||||||
 | 
					    <string name="dialog_event_detail_delete_button">Delete</string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <string name="dialog_add_logbook_title">Add logbook</string>
 | 
					    <string name="dialog_add_logbook_title">Add logbook</string>
 | 
				
			||||||
    <string name="dialog_add_logbook_logbookname">👶 Logbook name</string>
 | 
					    <string name="dialog_add_logbook_logbookname">👶 Logbook name</string>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user