Page MenuHomec4science

Search.java
No OneTemporary

File Metadata

Created
Thu, Jan 2, 23:23

Search.java

package com.example.genomicprivacy;
import java.io.FileOutputStream;
import java.util.ArrayList;
import FrameWork.DBconnector_mu;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
/**
* @author Serrano Kevin
* @author Weber Jeremy
*
*/
public class Search extends Fragment {
/**
* View for display all the matches of the patient's search
*/
AutoCompleteTextView textView;
/**
* Adapter for displaying the result
*/
ArrayAdapter<String> adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater
.inflate(R.layout.fragment_search, container, false);
textView = (AutoCompleteTextView) view
.findViewById(R.id.autoCompleteTextView);
new getPatientName().execute(textView.getText().toString());
textView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
long arg3) {
String[] patientSelected;
String name;
String lastName;
int id;
patientSelected = arg0.getItemAtPosition(pos).toString()
.split(" ; ");
lastName = patientSelected[0];
name = patientSelected[1];
id = Integer.parseInt(patientSelected[2]);
Intent i = new Intent(ContextApp.getContext(),
InfoPatient.class);
i.putExtra("name", name);
i.putExtra("lastName", lastName);
i.putExtra("id", id);
startActivity(i);
}
});
return view;
}
/**
* Asynchronous task to retrieve the patients from what the user entered in the search box
* @author Serrano Kevin
* @author Weber Jeremy
*
*/
public class getPatientName extends
AsyncTask<String, Void, ArrayList<String>> {
protected ArrayList<String> doInBackground(String... letter) {
// TODO Auto-generated method stub
ArrayList<String> patientArray = DBconnector_mu
.getPatientsName(letter[0]);
return patientArray;
}
@Override
protected void onPostExecute(ArrayList<String> result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
adapter = new ArrayAdapter<String>(ContextApp.getContext(),
R.layout.listitem, result);
textView.setThreshold(1);
textView.setAdapter(adapter);
}
}
}

Event Timeline