Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97151177
Search.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
Thu, Jan 2, 23:23
Size
2 KB
Mime Type
text/x-java
Expires
Sat, Jan 4, 23:23 (2 d)
Engine
blob
Format
Raw Data
Handle
23338576
Attached To
R3229 Genome Privacy - SHCS App
Search.java
View Options
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
Log In to Comment