package victory.sandbox.mytestapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import java.util.ArrayList;


public class MyActivity extends Activity {

    Button clickToList;
    ListView myListView;
    private ArrayAdapter<String> adapter;
    private ArrayList<String> arrayList;

    private int swipeNumber;

    private class SwipeItemClickListener implements AdapterView.OnItemClickListener {
        private SwipeDetector swipeDetector = null;

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (swipeDetector == null) {
                return;
            }
            swipeDetector.getSwipeHorizontal();

            if (swipeDetector.isLeftToRight()) {
                view.getResources().getColor(android.R.color.holo_blue_bright);
            }
        }

        public void setSwipeDetector(SwipeDetector swipeDetector) {
            this.swipeDetector = swipeDetector;
        }

        public SwipeDetector getSwipeDetector () {
            return swipeDetector;
        }
    }

    private class SwipeItemTouchListener extends SwipeDetector {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            boolean result = super.onTouch(view, event);

            if (isLeftToRight()) {
                swipeNumber += 1;
            }

            return result;
        }
    }

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

        clickToList = (Button) findViewById(R.id.clickToList);
        myListView = (ListView) findViewById(R.id.listView);

        SwipeItemClickListener swipeListener = new SwipeItemClickListener();
        swipeListener.setSwipeDetector(new SwipeItemTouchListener());

        myListView.setOnItemClickListener(swipeListener);
        myListView.setOnTouchListener(swipeListener.getSwipeDetector());

        arrayList = new ArrayList<String>();

        adapter = new ArrayAdapter<String>(
                getApplicationContext(),
                R.layout.list_layout,
                R.id.listTextView,
                arrayList);

        myListView.setAdapter(adapter);

        clickToList.setOnClickListener(new View.OnClickListener() {
            private Integer counter = 0;
            private int maxClicks = 50;

            @Override
            public void onClick(View v) {
                if (counter >= maxClicks) {
                    return;
                }
                arrayList.add("Row: " + counter.toString() + " Swipe Number: " + swipeNumber);
                counter += 1;
                adapter.notifyDataSetChanged();
                myListView.setBackgroundColor(
                        getResources().getColor(android.R.color.background_dark));

            }
        });


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, 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();

        return (id == R.id.action_settings) || (super.onOptionsItemSelected(item));
    }
}

@@ -573,767 +573,8 @@
 r;%0A%0A
-    private class SwipeItemClickListener implements AdapterView.OnItemClickListener %7B%0A        private SwipeDetector swipeDetector = null;%0A%0A        @Override%0A        public void onItemClick(AdapterView%3C?%3E parent, View view, int position, long id) %7B%0A            if (swipeDetector == null) %7B%0A                return;%0A            %7D%0A            swipeDetector.getSwipeHorizontal();%0A%0A            if (swipeDetector.isLeftToRight()) %7B%0A                view.getResources().getColor(android.R.color.holo_blue_bright);%0A            %7D%0A        %7D%0A%0A        public void setSwipeDetector(SwipeDetector swipeDetector) %7B%0A            this.swipeDetector = swipeDetector;%0A        %7D%0A%0A        public SwipeDetector getSwipeDetector () %7B%0A            return swipeDetector;%0A        %7D%0A    %7D%0A%0A
     
@@ -634,16 +634,16 @@
 ector %7B%0A
+
         
@@ -1200,273 +1200,63 @@
     
-SwipeItemClickListener swipeListener = new SwipeItemClickListener();%0A        swipeListener.setSwipeDetector(new SwipeItemTouchListener());%0A%0A        myListView.setOnItemClickListener(swipeListener);%0A        myListView.setOnTouchListener(swipeListener.getSwipeDetecto
+myListView.setOnTouchListener(new SwipeItemTouchListene
 r())

remove unused click swipe class