Page MenuHomec4science

Results.java
No OneTemporary

File Metadata

Created
Sat, Jan 18, 05:09

Results.java

package com.example.genomicprivacy;
import java.io.File;
import java.util.ArrayList;
import FrameWork.DBconnector_mu;
import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
/**
* @author Serrano Kevin
* @author Weber Jeremy
*
*/
public class Results extends Fragment {
/**
* Button for show the pdf file
*/
private Button pdfButton;
/**
* View for display all the matches of the patient's search
*/
private AutoCompleteTextView textView;
/**
* Adapter for displaying the result
*/
private ArrayAdapter<String> adapter;
/**
* ID of the patient selected
*/
private int id = 0;
/**
* Button Histogram
*/
private Button histo;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater
.inflate(R.layout.fragment_result, container, false);
pdfButton = (Button) view.findViewById(R.id.pdfButton);
histo = (Button) view.findViewById(R.id.showHistogram);
textView = (AutoCompleteTextView) view
.findViewById(R.id.autoSearchResult);
new getPatientName().execute(textView.getText().toString());
textView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
long arg3) {
String[] patientSelected;
patientSelected = arg0.getItemAtPosition(pos).toString()
.split(" ; ");
id = Integer.parseInt(patientSelected[2]);
}
});
pdfButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Uri path = Uri
.fromFile(new File(Environment
.getExternalStorageDirectory().getPath()
+ "/GenomicPrivacy/PDFReports/", "SHCS_" + id
+ ".pdf"));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
histo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ContextApp.getContext(),
Histogram.class);
intent.putExtra("id_p", id);
startActivity(intent);
}
});
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