package io.jamesclonk.turbojira;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
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.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;

public class ItemList extends AppCompatActivity {

    ArrayList<String> itemList = new ArrayList<>();
    ArrayAdapter<String> itemListAdapter;
    int clickCounter=0;

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

        FloatingActionButton addTaskButton = (FloatingActionButton) findViewById(R.id.add_task);
        addTaskButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //Snackbar.make(view, "Create new Jira Task", Snackbar.LENGTH_LONG)
                //        .setAction("Action", null).show();
                addItems(view);
            }
        });

        ListView listView = (ListView) findViewById(R.id.item_list);
        itemListAdapter = new ArrayAdapter<>(this,
                android.R.layout.simple_list_item_1,
                itemList);
        listView.setAdapter(itemListAdapter);
    }

    public void addItems(View v) {
        itemList.add("Clicked: "+clickCounter++);
        itemListAdapter.notifyDataSetChanged();
    }

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

@@ -481,24 +481,32 @@
 vity %7B%0A%0A    
+private 
 ArrayList%3CSt
@@ -545,16 +545,24 @@
 ();%0A    
+private 
 ArrayAda
@@ -594,32 +594,8 @@
 ter;
-%0A    int clickCounter=0;
 %0A%0A  
@@ -1297,24 +1297,112 @@
        %7D);%0A%0A
+        for( int i = 1; i %3C= 15; i++) %7B%0A            itemList.add(%22Item: %22+i);%0A        %7D%0A
         List
@@ -1669,16 +1669,20 @@
 Item
-s(View v
+(String item
 ) %7B%0A
@@ -1706,34 +1706,138 @@
 add(
-%22Clicked: %22+clickCounter++
+item);%0A        itemListAdapter.notifyDataSetChanged();%0A    %7D%0A%0A    public void addItems(View v) %7B%0A        //itemList.add(%22New Item%22
 );%0A 
@@ -1835,32 +1835,34 @@
 Item%22);%0A        
+//
 itemListAdapter.

prepare for settings