aboutsummaryrefslogtreecommitdiff
path: root/src/com/example/surgerylog/ViewDataFragment.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/example/surgerylog/ViewDataFragment.java')
-rwxr-xr-xsrc/com/example/surgerylog/ViewDataFragment.java173
1 files changed, 0 insertions, 173 deletions
diff --git a/src/com/example/surgerylog/ViewDataFragment.java b/src/com/example/surgerylog/ViewDataFragment.java
deleted file mode 100755
index 6adbbaa..0000000
--- a/src/com/example/surgerylog/ViewDataFragment.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package com.example.surgerylog;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-import net.redroid.medlog.R;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.ListView;
-import android.widget.AdapterView.OnItemClickListener;
-
-public class ViewDataFragment extends Fragment {
- /**
- * The fragment argument representing the section number for this fragment.
- */
- public static final String ARG_SECTION_NUMBER = "section_number";
-
- private MainActivity _activity;
-
- List<String> _viewDataList = new ArrayList<String>();
-
- int _lastSelected;
-
- public ViewDataFragment() {
- }
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
-
- // This makes sure that the container activity has implemented
- // the callback interface. If not, it throws an exception
- try {
- _activity = (MainActivity) activity;
- } catch (ClassCastException e) {
- throw new ClassCastException(activity.toString()
- + " must implement OnHeadlineSelectedListener");
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // get root view
- View rootView = inflater.inflate(R.layout.fragment_view_data,
- container, false);
-
- return rootView;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onActivityCreated(savedInstanceState);
-
- // get list view
- ListView listView = ((ListView) getView().findViewById(
- R.id.dataBaseListView));
-
- // set list view on click event
- listView.setOnItemClickListener(new OnItemClickListener() {
-
- @Override
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
-
- // hold last selected
- _lastSelected = position;
-
- // prepare the alert box
- AlertDialog.Builder _alertbox = new AlertDialog.Builder(
- _activity);
- MedLogInfo info = _activity.DataBase.get(position);
- String infoStr = "#Pro: " + info.ProcessNumber.toString()
- + "\n" + "#Cir: " + info.SurgeryNumber.toString()
- + "\n" + "Data: " + info.GetFormatedDate()
- + "\n" + "Ajud: " + info.FirstAider
- + "\n" + "Anst: " + info.Anesthesia
- + "\n" + "Locl: " + info.Place
- + "\n" + "Tipo: " + info.Type
- + "\n" + "Subt: " + info.SubType
- + "\n" + "Pato: " + info.Pathology
- + "\n" + "Intr: " + info.Intervention
- + "\n" + "Urgn: " + _activity.getString(info.Urgency == true ? R.string.yes_str : R.string.no_str)
- + "\n" + "Nota: " + info.Notes
- ;
- _alertbox.setMessage(infoStr);
- _alertbox.setNeutralButton(R.string.ok_str,
- new DialogInterface.OnClickListener() {
- // click listener on the alert box
- public void onClick(DialogInterface arg0, int arg1) {
- // nothing to do here
- }
- });
- _alertbox.setNegativeButton(R.string.delete_str,
- new DialogInterface.OnClickListener() {
- // click listener on the alert box
- public void onClick(DialogInterface arg0, int arg1) {
- // TODO delete the database entry
- _activity.DataBase.remove(_lastSelected);
- _activity.SaveMedLogDB();
- UpdateListView();
- }
- });
- _alertbox.show();
- }
- });
-
- // REFRESH BUTTON
- Button refreshBtn = (Button) getView().findViewById(R.id.refreshBtn);
- refreshBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- UpdateListView();
- }
- });
-
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- UpdateListView();
- }
-
- public void UpdateListView() {
- // get list data
- if (_activity.DataBase != null) {
-
- // remove old entries
- _viewDataList.clear();
-
- // add new entries
- for (MedLogInfo log : _activity.DataBase) {
- _viewDataList.add(log.ProcessNumber.toString());
- }
- }
-
- // create array adapter
- ArrayAdapter<String> adapter = new ArrayAdapter<String>(getView()
- .getContext(), android.R.layout.simple_list_item_1,
- _viewDataList);
-
- // // sort list values
- // adapter.sort(new Comparator<String>() {
- // public int compare(String object1, String object2) {
- // return object1.compareTo(object2);
- // }
- // });
-
- // get list view
- ListView listView = ((ListView) getView().findViewById(
- R.id.dataBaseListView));
-
- // set adapter
- listView.setAdapter(adapter);
- }
-
-}