package ro.pub.cs.systems.eim.practicaltest01;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;

public class PracticalTest01MainActivity extends AppCompatActivity {

    private Button navigateToSecondayActivity = null;
    private EditText leftEditText = null;
    private EditText rightEditText = null;
    private Button leftButton = null;
    private Button rightButton = null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_practical_test01_main);

        //navigateToSecondayActivity = (Button)findViewById(R.id.navigate_to_secondary_activity_button);
        leftEditText = (EditText)findViewById(R.id.left_edit_text);
        rightEditText = (EditText)findViewById(R.id.right_edit_text);
        leftEditText.setText(String.valueOf(0));
        rightEditText.setTag(String.valueOf(0));

        leftButton = (Button)findViewById(R.id.left_button);
        rightButton = (Button)findViewById(R.id.right_button);

       /* Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });*/
    }

    @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_practical_test01_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);
    }
}

@@ -172,16 +172,42 @@
 nuItem;%0A
+import android.view.View;%0A
 import a
@@ -547,16 +547,786 @@
 = null;%0A
+    private ButtonClickListener buttonClickListener = new ButtonClickListener();%0A%0A    private class ButtonClickListener implements View.OnClickListener %7B%0A        @Override%0A        public void onClick(View v) %7B%0A            switch (v.getId()) %7B%0A                case R.id.left_button:%0A                    leftEditText.setText(%0A                            String.valueOf(Integer.%0A                                    parseInt(leftEditText.getText().toString()) + 1));%0A                    break;%0A                case R.id.right_button:%0A                    rightEditText.setText(%0A                            String.valueOf(Integer.%0A                                    parseInt(rightEditText.getText().toString()) + 1));%0A                    break;%0A%0A            %7D%0A        %7D%0A    %7D
 %0A%0A    @O
@@ -1818,18 +1818,19 @@
 ext.setT
-ag
+ext
 (String.
@@ -1964,24 +1964,146 @@
 t_button);%0A%0A
+        leftButton.setOnClickListener(buttonClickListener);%0A        rightButton.setOnClickListener(buttonClickListener);%0A%0A
        /* To

add on click listener on left/right buttons