// Path: src/us/shandian/blacklight/support/AsyncTask.java
// public abstract class AsyncTask<Params, Progress, Result>
// {
// 	private static final String TAG = AsyncTask.class.getSimpleName();
// 	
// 	private static class AsyncResult<Data> {
// 		public AsyncTask task;
// 		public Data[] data;
// 		
// 		public AsyncResult(AsyncTask task, Data... data) {
// 			this.task = task;
// 			this.data = data;
// 		}
// 	}
// 	
// 	private static final int MSG_FINISH = 1000;
// 	private static final int MSG_PROGRESS = 1001;
// 	
// 	private static Handler sInternalHandler = new Handler() {
// 		@SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
// 		@Override
// 		public void handleMessage(Message msg) {
// 			AsyncResult result = (AsyncResult) msg.obj;
// 			switch (msg.what) {
// 				case MSG_FINISH:
// 					result.task.onPostExecute(result.data[0]);
// 					break;
// 				case MSG_PROGRESS:
// 					result.task.onProgressUpdate(result.data);
// 					break;
// 			}
// 		}
// 	};
// 	
// 	private Params[] mParams;
// 	
// 	private Thread mThread = new Thread(new Runnable() {
// 		@Override
// 		public void run() {
// 			CrashHandler.register();
// 			
// 			try {
// 				Result result = doInBackground(mParams);
// 				sInternalHandler.sendMessage(sInternalHandler.obtainMessage(MSG_FINISH, new AsyncResult<Result>(AsyncTask.this, result)));
// 			} catch (Exception e) {
// 				// Don't crash the whole app
// 				if (DEBUG) {
// 					Log.d(TAG, e.getClass().getSimpleName() + " caught when running background task. Printing stack trace.");
// 					Log.d(TAG, Log.getStackTraceString(e));
// 				}
// 			}
// 			
// 			Thread.currentThread().interrupt();
// 		}
// 	});
// 	
// 	protected void onPostExecute(Result result) {}
// 	
// 	protected abstract Result doInBackground(Params... params);
// 	
// 	protected void onPreExecute() {}
// 	
// 	protected void onProgressUpdate(Progress... progress) {}
// 	
// 	protected void publishProgress(Progress... progress) {
// 		sInternalHandler.sendMessage(sInternalHandler.obtainMessage(MSG_PROGRESS, new AsyncResult<Progress>(this, progress)));
// 	}
// 	
// 	public void execute(Params... params) {
// 		onPreExecute();
// 		mParams = params;
// 		mThread.start();
// 	}
// }


import us.shandian.blacklight.R;
import us.shandian.blacklight.api.search.SearchApi;
import us.shandian.blacklight.support.AsyncTask;
import android.widget.*;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import java.util.ArrayList;
		// Views
		setContentView(R.layout.at_user_dialog);
		
		mText = (EditText) findViewById(R.id.at_user_text);
		mSearch = findViewById(R.id.at_user_search);
		mList = (ListView) findViewById(R.id.at_user_list);
		
		mSearch.setOnClickListener(this);
		mList.setOnItemClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if (mLoading) return;
		
		new SearchTask().execute(mText.getText().toString());
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		if (mListener != null && mStrs != null && position < mStrs.length) {
			mListener.onChooseUser(mStrs[position]);
			dismiss();
		}
	}
	
	public void setListener(AtUserListener listener) {
		mListener = listener;
	}
	
// Path: src/us/shandian/blacklight/support/AsyncTask.java
// public abstract class AsyncTask<Params, Progress, Result>
// {
// 	private static final String TAG = AsyncTask.class.getSimpleName();
// 	
// 	private static class AsyncResult<Data> {
// 		public AsyncTask task;
// 		public Data[] data;
// 		
// 		public AsyncResult(AsyncTask task, Data... data) {
// 			this.task = task;
// 			this.data = data;
// 		}
// 	}
// 	
// 	private static final int MSG_FINISH = 1000;
// 	private static final int MSG_PROGRESS = 1001;
// 	
// 	private static Handler sInternalHandler = new Handler() {
// 		@SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
// 		@Override
// 		public void handleMessage(Message msg) {
// 			AsyncResult result = (AsyncResult) msg.obj;
// 			switch (msg.what) {
// 				case MSG_FINISH:
// 					result.task.onPostExecute(result.data[0]);
// 					break;
// 				case MSG_PROGRESS:
// 					result.task.onProgressUpdate(result.data);
// 					break;
// 			}
// 		}
// 	};
// 	
// 	private Params[] mParams;
// 	
// 	private Thread mThread = new Thread(new Runnable() {
// 		@Override
// 		public void run() {
// 			CrashHandler.register();
// 			
// 			try {
// 				Result result = doInBackground(mParams);
// 				sInternalHandler.sendMessage(sInternalHandler.obtainMessage(MSG_FINISH, new AsyncResult<Result>(AsyncTask.this, result)));
// 			} catch (Exception e) {
// 				// Don't crash the whole app
// 				if (DEBUG) {
// 					Log.d(TAG, e.getClass().getSimpleName() + " caught when running background task. Printing stack trace.");
// 					Log.d(TAG, Log.getStackTraceString(e));
// 				}
// 			}
// 			
// 			Thread.currentThread().interrupt();
// 		}
// 	});
// 	
// 	protected void onPostExecute(Result result) {}
// 	
// 	protected abstract Result doInBackground(Params... params);
// 	
// 	protected void onPreExecute() {}
// 	
// 	protected void onProgressUpdate(Progress... progress) {}
// 	
// 	protected void publishProgress(Progress... progress) {
// 		sInternalHandler.sendMessage(sInternalHandler.obtainMessage(MSG_PROGRESS, new AsyncResult<Progress>(this, progress)));
// 	}
// 	
// 	public void execute(Params... params) {
// 		onPreExecute();
// 		mParams = params;
// 		mThread.start();
// 	}
// }


// Path: src/us/shandian/blacklight/ui/search/AtUserSuggestDialog.java
import us.shandian.blacklight.R;
import us.shandian.blacklight.api.search.SearchApi;
import us.shandian.blacklight.support.AsyncTask;
import android.widget.*;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import java.util.ArrayList;

		// Views
		setContentView(R.layout.at_user_dialog);
		
		mText = (EditText) findViewById(R.id.at_user_text);
		mSearch = findViewById(R.id.at_user_search);
		mList = (ListView) findViewById(R.id.at_user_list);
		
		mSearch.setOnClickListener(this);
		mList.setOnItemClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if (mLoading) return;
		
		new SearchTask().execute(mText.getText().toString());
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		if (mListener != null && mStrs != null && position < mStrs.length) {
			mListener.onChooseUser(mStrs[position]);
			dismiss();
		}
	}
	
	public void setListener(AtUserListener listener) {
		mListener = listener;
	}
	
	private class SearchTask extends AsyncTask<String, Void, String[]> {