Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98979592
Results.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 18, 05:09
Size
3 KB
Mime Type
text/x-java
Expires
Mon, Jan 20, 05:09 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
23682045
Attached To
R3229 Genome Privacy - SHCS App
Results.java
View Options
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
Log In to Comment