Android Open Source - clinicalguide Summary Screen Fragment






From Project

Back to project page clinicalguide.

License

The source code is released under:

Apache License

If you think the Android project clinicalguide listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.get.oxicam.clinicalguide.ui;
/*w w  w .j ava2  s . co m*/
import java.io.File;

import org.get.oxicam.clinicalguide.ClinicalGuideActivity;
import org.get.oxicam.clinicalguide.FileUtils;
import org.get.oxicam.clinicalguide.R;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.util.TypedValue;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class SummaryScreenFragment extends Fragment {

    private ClinicalGuideActivity mActivity;

    // private SimpleAdapter mAdapter;

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {

  mActivity = (ClinicalGuideActivity) getActivity();
  mActivity.setTitle("Summary");
  View v = inflater.inflate(R.layout.summaryscreen_list_item, container,
    false);
  RelativeLayout rl = (RelativeLayout) v.findViewById(R.id.layout);
  rl.setPadding(10, 10, 10, 10); // setPadding for entire screen
  Object arg = getArguments().get("summary"); // get the contents

  Display display = mActivity.getWindowManager().getDefaultDisplay();
  Point size = new Point();
  display.getSize(size);

  // text view
  TextView summaryTv = new TextView(mActivity);
  summaryTv.setId(1);
  summaryTv.setHint("This is Summary of a form");
  summaryTv.setText((String) arg); // get the summary data to the summary
           // textview area
  summaryTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); // setTextSize
  rl.addView(summaryTv);
  RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) summaryTv
    .getLayoutParams();

  // Comment - EditText
  EditText commentET = new EditText(mActivity);
  commentET.setId(4);
  commentET.setHint("Comments");
  commentET.setMaxHeight(size.y / 2 - 100); // !!!!!!!!!!!!!!
  // commentET.setLayoutParams(new ViewGroup.LayoutParams(size.x,
  // size.y/2));
  rl.addView(commentET);

  params = (RelativeLayout.LayoutParams) commentET.getLayoutParams();
  params.addRule(RelativeLayout.BELOW, summaryTv.getId());
  params.topMargin = 10;
  params.width = RelativeLayout.LayoutParams.MATCH_PARENT;
  // params.height = RelativeLayout.LayoutParams.MATCH_PARENT;

  // Button = "View Detail"
  Button viewDetailBtn = new Button(mActivity);
  viewDetailBtn.setId(3);
  viewDetailBtn.setText("View Detail");
  viewDetailBtn.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
    // TODO Auto-generated method stub
    Bundle b = new Bundle();

    String details = getArguments().getString("details");
    details += "\n\nComments";
    details += "\n============";
    EditText comment = (EditText) mActivity.findViewById(4);
    details += "\n" + comment.getText().toString();
    b.putString("detail", details);
    Fragment frag = Fragment.instantiate(mActivity,
      ViewDetailScreenFragment.class.getName());
    frag.setArguments(b);
    mActivity.setContent(frag);
      }
  });
  rl.addView(viewDetailBtn);
  params = (RelativeLayout.LayoutParams) viewDetailBtn.getLayoutParams();
  params.addRule(RelativeLayout.BELOW, commentET.getId());
  params.topMargin = 10;
  params.bottomMargin = 10;
  params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

  // Cancel Button
  Button cancelBtn = new Button(mActivity);
  cancelBtn.setId(5);
  cancelBtn.setText("Cancel");
  cancelBtn.setCompoundDrawablesWithIntrinsicBounds(
    R.drawable.navigation_cancel, 0, 0, 0);
  cancelBtn.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
    // TODO Auto-generated method stub
    AlertDialog.Builder alert = new AlertDialog.Builder(mActivity);
    alert.setTitle("Confirmation");
    alert.setMessage("Do you really want to cancel?");

    alert.setPositiveButton("Ok",
      new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog,
            int which) {
        // TODO Auto-generated method stub
        mActivity.onBackPressed();
          }
      });

    alert.setNegativeButton("Cancel",
      new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog,
            int which) {
        // TODO Auto-generated method stub
        dialog.cancel();
          }
      });
    AlertDialog alertDialog = alert.create();
    alertDialog.show();

      }
  });

  rl.addView(cancelBtn);
  params = (RelativeLayout.LayoutParams) cancelBtn.getLayoutParams();
  params.addRule(RelativeLayout.BELOW, viewDetailBtn.getId());
  params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

  // OK Button
  Button okBtn = new Button(mActivity);
  okBtn.setId(6);
  okBtn.setText("Save");
  okBtn.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
    // TODO Auto-generated method stub
    Bundle b = getArguments();
    String data = b.getString("details");
    String html = b.getString("html");

    data += "\n\nComments";
    html += "<div title=\"comments\">\n";
    data += "\n============";
    EditText comment = (EditText) mActivity.findViewById(4);
    data += "\n" + comment.getText().toString();
    String reportName = b.getString("filename");
    html += comment.getText().toString();
    html += "\n</div>\n";

    Log.w("hi", Environment.getExternalStorageDirectory()
      + "/oxicam/" + reportName);
    FileUtils.writeFile(html, reportName);
    Toast.makeText(mActivity, "Success saving files",
      Toast.LENGTH_SHORT).show();
      }
  });
  okBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.content_save,
    0, 0, 0);
  rl.addView(okBtn);
  params = (RelativeLayout.LayoutParams) okBtn.getLayoutParams();
  params.addRule(RelativeLayout.BELOW, viewDetailBtn.getId());
  params.addRule(RelativeLayout.LEFT_OF, cancelBtn.getId());

  // email button
  Button emailButton = new Button(mActivity);
  emailButton.setId(7);
  emailButton.setText("Save and Email");
  emailButton.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("application/octet-stream");
    Bundle b = getArguments();
    String data = b.getString("details");
    String html = b.getString("html");

    data += "\n\nComments";
    html += "<div title=\"comments\">\n";
    data += "\n============";
    EditText comment = (EditText) mActivity.findViewById(4);
    data += "\n" + comment.getText().toString();
    String reportName = b.getString("filename");
    html += comment.getText().toString();
    html += "\n</div>\n";

    Log.w("hi", Environment.getExternalStorageDirectory()
      + "/oxicam/" + reportName);
    FileUtils.writeFile(html, reportName);
    Toast.makeText(mActivity, "Success saving files",
      Toast.LENGTH_SHORT).show();
    File file = new File(Environment.getExternalStorageDirectory()
      + "/oxicam/" + reportName);
    Log.w("hi", file.exists() + "");
    emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, reportName);
    mActivity.startActivity(Intent.createChooser(emailIntent,
      "Send With..."));
      }
  });
  emailButton.setCompoundDrawablesWithIntrinsicBounds(
    R.drawable.content_new_attachment, 0, 0, 0);
  rl.addView(emailButton);
  params = (RelativeLayout.LayoutParams) emailButton.getLayoutParams();
  params.addRule(RelativeLayout.BELOW, viewDetailBtn.getId());
  params.addRule(RelativeLayout.LEFT_OF, okBtn.getId());

  return v;

    }
}




Java Source Code List

.PatientDetailsDataSource.java
org.get.oxicam.clinicalguide.ClinicalGuideActivity.java
org.get.oxicam.clinicalguide.FileUtils.java
org.get.oxicam.clinicalguide.LoginActivity.java
org.get.oxicam.clinicalguide.db.DatabaseHelper.java
org.get.oxicam.clinicalguide.db.Database.java
org.get.oxicam.clinicalguide.db.FollowupDataSource.java
org.get.oxicam.clinicalguide.db.FollowupDetails.java
org.get.oxicam.clinicalguide.db.FollowupSQLHelper.java
org.get.oxicam.clinicalguide.db.HistoryDetailsDataSource.java
org.get.oxicam.clinicalguide.db.HistoryDetailsSQLHelper.java
org.get.oxicam.clinicalguide.db.HistoryDetails.java
org.get.oxicam.clinicalguide.db.PatientDetailsSQLHelper.java
org.get.oxicam.clinicalguide.db.PatientDetails.java
org.get.oxicam.clinicalguide.db.RegistrationValidator.java
org.get.oxicam.clinicalguide.db.Validator.java
org.get.oxicam.clinicalguide.encryption.Encryption.java
org.get.oxicam.clinicalguide.ui.AnswersReviewFragment.java
org.get.oxicam.clinicalguide.ui.AssessmentDetailFragment.java
org.get.oxicam.clinicalguide.ui.ClassificationFragment.java
org.get.oxicam.clinicalguide.ui.ClassificationListItem.java
org.get.oxicam.clinicalguide.ui.DatePickerFragment.java
org.get.oxicam.clinicalguide.ui.ExportFragment.java
org.get.oxicam.clinicalguide.ui.ExportscreenListItem.java
org.get.oxicam.clinicalguide.ui.FollowUpFragment.java
org.get.oxicam.clinicalguide.ui.FormScreenFragment.java
org.get.oxicam.clinicalguide.ui.HomescreenFragment.java
org.get.oxicam.clinicalguide.ui.HomescreenListItem.java
org.get.oxicam.clinicalguide.ui.ListItemOnClickListener.java
org.get.oxicam.clinicalguide.ui.MainSymptomFragment.java
org.get.oxicam.clinicalguide.ui.MainSymptomListItem.java
org.get.oxicam.clinicalguide.ui.NumberTickerValueChangeListener.java
org.get.oxicam.clinicalguide.ui.NumberTicker.java
org.get.oxicam.clinicalguide.ui.PatientDetailsFragment.java
org.get.oxicam.clinicalguide.ui.PatientHistoryFragment.java
org.get.oxicam.clinicalguide.ui.PatientsFragment.java
org.get.oxicam.clinicalguide.ui.QuestionListItem.java
org.get.oxicam.clinicalguide.ui.QuestionnaireFragment.java
org.get.oxicam.clinicalguide.ui.StatScreenFragment.java
org.get.oxicam.clinicalguide.ui.SummaryScreenFragment.java
org.get.oxicam.clinicalguide.ui.TextViewCustomFont.java
org.get.oxicam.clinicalguide.ui.TreatmentConfirmationDialog.java
org.get.oxicam.clinicalguide.ui.TreatmentFragment.java
org.get.oxicam.clinicalguide.ui.TreatmentListItem.java
org.get.oxicam.clinicalguide.ui.ViewDetailScreenFragment.java
org.get.oxicam.clinicalguide.xml.CGFormParser.java
org.get.oxicam.clinicalguide.xml.CGParser.java
org.get.oxicam.clinicalguide.xml.CGStatsParser.java
org.get.oxicam.clinicalguide.xml.DateHelper.java
org.get.oxicam.clinicalguide.xml.FormGenerator.java
org.get.oxicam.clinicalguide.xml.ParserHelper.java
org.get.oxicam.clinicalguide.xml.StatsGenerator.java
org.get.oxicam.clinicalguide.xml.XMLHandler.java
org.get.oxicam.clinicalguide.xml.data.AbstractAnswer.java
org.get.oxicam.clinicalguide.xml.data.Annotation.java
org.get.oxicam.clinicalguide.xml.data.AnswerValidator.java
org.get.oxicam.clinicalguide.xml.data.Answer.java
org.get.oxicam.clinicalguide.xml.data.Assessment.java
org.get.oxicam.clinicalguide.xml.data.CombinedAnswer.java
org.get.oxicam.clinicalguide.xml.data.FollowUp.java
org.get.oxicam.clinicalguide.xml.data.FormQuery.java
org.get.oxicam.clinicalguide.xml.data.Info.java
org.get.oxicam.clinicalguide.xml.data.Option.java
org.get.oxicam.clinicalguide.xml.data.PatientAttribute.java
org.get.oxicam.clinicalguide.xml.data.Question.java
org.get.oxicam.clinicalguide.xml.data.Questionnaire.java
org.get.oxicam.clinicalguide.xml.data.SimpleAnswer.java
org.get.oxicam.clinicalguide.xml.data.Symptom.java
org.get.oxicam.clinicalguide.xml.data.TreatmentAction.java
org.get.oxicam.clinicalguide.xml.data.Treatment.java
org.get.oxicam.clinicalguide.xml.data.User.java
org.get.oxicam.clinicalguide.xml.forms.FormCell.java
org.get.oxicam.clinicalguide.xml.forms.FormColumn.java
org.get.oxicam.clinicalguide.xml.forms.FormDuration.java
org.get.oxicam.clinicalguide.xml.forms.Form.java
org.get.oxicam.clinicalguide.xml.query.QueryHelper.java
org.get.oxicam.clinicalguide.xml.query.QueryResultCell.java
org.get.oxicam.clinicalguide.xml.query.QueryResultRow.java
org.get.oxicam.clinicalguide.xml.query.QueryResultTable.java
org.get.oxicam.clinicalguide.xml.stats.AbstractStatsQuestion.java
org.get.oxicam.clinicalguide.xml.stats.StatsAnswerHolder.java
org.get.oxicam.clinicalguide.xml.stats.StatsColumnCompare.java
org.get.oxicam.clinicalguide.xml.stats.StatsComparatorOperator.java
org.get.oxicam.clinicalguide.xml.stats.StatsCompareConstraint.java
org.get.oxicam.clinicalguide.xml.stats.StatsConstraint.java
org.get.oxicam.clinicalguide.xml.stats.StatsQuestionAverage.java
org.get.oxicam.clinicalguide.xml.stats.StatsQuestionCount.java
org.get.oxicam.clinicalguide.xml.stats.StatsQuestionExtrema.java
org.get.oxicam.clinicalguide.xml.stats.StatsQuestionFactory.java
org.get.oxicam.clinicalguide.xml.stats.StatsQuestionList.java
org.get.oxicam.clinicalguide.xml.stats.StatsQuestionPercentage.java
org.get.oxicam.clinicalguide.xml.stats.StatsQuestionRatio.java
org.get.oxicam.clinicalguide.xml.stats.StatsSubject.java
org.get.oxicam.clinicalguide.xml.stats.StatsTimespan.java
org.get.oxicam.clinicalguide.xml.stats.Stats.java