// Path: RetroShareAndroidIntegration/src/org/retroshare/android/RsSearchService.java
// public interface SearchResponseHandler { public void onSearchResponseReceived(int id); }


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.retroshare.android.RsSearchService.SearchResponseHandler;
import android.content.Context;
import android.content.Intent;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnKeyListener;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
        setContentView(R.layout.activity_listsearches);
        
        editText=(EditText) findViewById(R.id.searchEditText_ListSearchesActivity);
        listView=(ListView) findViewById(R.id.searchListView_ListSearchesActivity);
        
        editText.setOnKeyListener(new KeyListener());
        
        adapter=new SearchListAdapterListener(this);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(adapter);
        listView.setOnItemLongClickListener(adapter);
    }
    
	private class KeyListener implements OnKeyListener
	{
		@Override
		public boolean onKey(View v, int keyCode, KeyEvent event) {
			
			if((event.getAction()==KeyEvent.ACTION_DOWN)&(event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
			{
				Log.v(TAG,"KeyListener.onKey() event.getKeyCode() == KeyEvent.KEYCODE_ENTER");
				getConnectedServer().mRsSearchService.sendRequestBasicSearch(editText.getText().toString(), new ResponseHandler());
				return true;
			}
			else return false;
		}
		
	}
	
	// needed, because we know dont know the serach id before we received the result
// Path: RetroShareAndroidIntegration/src/org/retroshare/android/RsSearchService.java
// public interface SearchResponseHandler { public void onSearchResponseReceived(int id); }


// Path: RetroShareAndroidIntegration/src/org/retroshare/android/ListSearchesActivity.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.retroshare.android.RsSearchService.SearchResponseHandler;
import android.content.Context;
import android.content.Intent;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnKeyListener;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;

        setContentView(R.layout.activity_listsearches);
        
        editText=(EditText) findViewById(R.id.searchEditText_ListSearchesActivity);
        listView=(ListView) findViewById(R.id.searchListView_ListSearchesActivity);
        
        editText.setOnKeyListener(new KeyListener());
        
        adapter=new SearchListAdapterListener(this);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(adapter);
        listView.setOnItemLongClickListener(adapter);
    }
    
	private class KeyListener implements OnKeyListener
	{
		@Override
		public boolean onKey(View v, int keyCode, KeyEvent event) {
			
			if((event.getAction()==KeyEvent.ACTION_DOWN)&(event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
			{
				Log.v(TAG,"KeyListener.onKey() event.getKeyCode() == KeyEvent.KEYCODE_ENTER");
				getConnectedServer().mRsSearchService.sendRequestBasicSearch(editText.getText().toString(), new ResponseHandler());
				return true;
			}
			else return false;
		}
		
	}
	
	// needed, because we know dont know the serach id before we received the result
	private class ResponseHandler implements SearchResponseHandler