package com.example.denis_niko.projektjanez;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    public final static String EXTRA_INTEGER = "com.example.denis_niko.projektjanez.INTEGER";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    public void StartTimer(View view) {
        Intent intent = new Intent(this, TimerActivity.class);
        EditText editText = (EditText) findViewById(R.id.message_timer);
        String message = editText.getText().toString();

        int num = Integer.parseInt(message);   // just used for verification

        if(num <= 60 && num > 0) {
            intent.putExtra(EXTRA_INTEGER, message);
            startActivity(intent);
        } else {
            Context context = getApplicationContext();
            CharSequence text = "Invalid input!\nTry again.";
            int duration = Toast.LENGTH_LONG;

            Toast toast = Toast.makeText(context, text, duration);
            toast.show();
        }
    }

}

@@ -128,16 +128,60 @@
 Bundle;%0A
+import android.support.annotation.Nullable;%0A
 import a
@@ -1613,16 +1613,22 @@
  Intent 
+timer_
 intent =
@@ -1793,24 +1793,217 @@
 oString();%0A%0A
+        if(message.matches(%22%22)) %7B%0A            // make sure input is not empty%0A            Toast.makeText(this, %22You entered nothing!%22, Toast.LENGTH_LONG).show();%0A            return;%0A        %7D%0A%0A
         int 
@@ -2115,16 +2115,22 @@
         
+timer_
 intent.p
@@ -2188,16 +2188,22 @@
 ctivity(
+timer_
 intent);
@@ -2236,82 +2236,28 @@
     
-Context context = getApplicationContext();%0A            CharSequence text =
+Toast.makeText(this,
  %22In
@@ -2262,17 +2262,17 @@
 Invalid 
-i
+I
 nput!%5CnT
@@ -2285,141 +2285,28 @@
 in.%22
-;%0A            int duration = Toast.LENGTH_LONG;%0A%0A            Toast toast = Toast.makeText(context, text, duration);%0A            toast
+, Toast.LENGTH_LONG)
 .sho

fix #1 and simplify toasts