Timelife-Project/timelife/app/src/main/java/com/henriktk/timer_v2/MainActivity.java
/**
     * Displays a dialog to user prompting for the name of the new timer.
     * Creates and stores the new timer, then calls on the adapter to update.
     * @param view View of the calling button
     */
Displays a dialog to user prompting for the name of the new timer.
Creates and stores the new timer, then calls on the adapter to update.
@param view View of the calling button
Displays a dialog to user prompting for the name of the new timer . Creates and stores the new timer then calls on the adapter to update . @param view View of the calling button
public void newTimer(View view) {
        Log.i("NewTimer", "Creating new timer.");
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Insert name of new timer");
        final EditText input = new EditText(this);
        input.setInputType(InputType.TYPE_CLASS_TEXT);
        builder.setView(input);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                newTimer(input.getText().toString());
            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }
        });
        builder.show();
    }
public void newTimer ( View view ) { Log . i ( "NewTimer" , "Creating new timer." ) ; AlertDialog . Builder builder = new AlertDialog . Builder ( this ) ; builder . setTitle ( "Insert name of new timer" ) ; final EditText input = new EditText ( this ) ; input . setInputType ( InputType . TYPE_CLASS_TEXT ) ; builder . setView ( input ) ; builder . setPositiveButton ( "OK" , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialogInterface , int i ) { newTimer ( input . getText ( ) . toString ( ) ) ; } } ) ; builder . setNegativeButton ( "Cancel" , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialogInterface , int i ) { dialogInterface . cancel ( ) ; } } ) ; builder . show ( ) ; }
Displays a dialog to user prompting for the name of the new timer.
Displays a dialog to user prompting for the name of the new timer .
// Display dialog to user asking for name of new timer