Android Open Source - chat.android Health Overview Record Activity






From Project

Back to project page chat.android.

License

The source code is released under:

GNU General Public License

If you think the Android project chat.android 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.chat.android;
//  w  w w  . ja  va2  s  . c  o m
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.chat.android.models.HealthSelect;
import org.chat.android.models.HealthSelectRecorded;
import org.chat.android.models.HealthTheme;

import com.j256.ormlite.dao.Dao;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

public class HealthOverviewRecordActivity extends BaseActivity {
  Context context;
  int hhId = 0;
  int visitId = 0;
  String healthThemeName = null;
  HealthTheme theme = null;
  TextView obsTitle = null;
  TextView obsTv = null;
  TextView recTitle = null;
  TextView recTv = null;
  RadioGroup rbg = null;
  RadioButton r1 = null;
  RadioButton r2 = null;
  RadioButton r3 = null;
  RadioButton r4 = null;
  ImageButton continueBtn = null;
  
  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = getApplicationContext();
    setContentView(R.layout.activity_health_overview_record);
    
    obsTitle = (TextView)findViewById(R.id.overviewRecordTitle1);
    obsTv = (TextView)findViewById(R.id.overviewRecordContent1);
    recTitle = (TextView)findViewById(R.id.overviewRecordTitle2);
    recTv = (TextView)findViewById(R.id.overviewRecordContent2);
    rbg = (RadioGroup)findViewById(R.id.overviewRecordRadio);
    r1 = (RadioButton)findViewById(R.id.overviewRecordRadioButton1);
    r2 = (RadioButton)findViewById(R.id.overviewRecordRadioButton2);
    r3 = (RadioButton)findViewById(R.id.overviewRecordRadioButton3);
    r4 = (RadioButton)findViewById(R.id.overviewRecordRadioButton4);
    continueBtn = (ImageButton)findViewById(R.id.continueButton);
    
    Bundle b = getIntent().getExtras();
    hhId = b.getInt("hhId");
    visitId = b.getInt("visitId");
    healthThemeName = b.getString("healthTheme");
    theme = ModelHelper.getThemeForName(getHelper(), healthThemeName);
    
    populateThemeContent();
    updateUIColors();
    }
  
  public void populateThemeContent() {
    List<HealthSelect> selects = new ArrayList<HealthSelect>();
    selects = ModelHelper.getSelectsForSubjectId(getHelper(), theme.getId());
    
    // TODO set these up to work with Zulu (in the model)
    if (theme != null) {
      obsTv.setText(theme.getEnObserveContent());
      recTv.setText(theme.getEnRecordContent());
    }
    
    if (selects.size() == 4) {
      // set up the radio buttons, tagged with ID (to be used when saving)
      r1.setText(selects.get(0).getEnContent());
      r1.setTag(selects.get(0).getId());
      r2.setText(selects.get(1).getEnContent());
      r2.setTag(selects.get(1).getId());
      r3.setText(selects.get(2).getEnContent());
      r3.setTag(selects.get(2).getId());
      r4.setText(selects.get(3).getEnContent());
      r4.setTag(selects.get(3).getId());
    }

  }
  
  public void updateUIColors() {
    int colorRef = Color.parseColor(theme.getColor());
    
    obsTitle.setTextColor(colorRef);
    recTitle.setTextColor(colorRef);
    
    // button color
    if (theme.getId() == 1) {
      continueBtn.setImageResource(R.drawable.hivcontinuebutton);
    } else if (theme.getId() == 2) {
      continueBtn.setImageResource(R.drawable.childhooddiseasescontinuebutton);
    } else if (theme.getId() == 3) {
      continueBtn.setImageResource(R.drawable.nutritioncontinuebutton);
    } else if (theme.getId() == 4) {
      continueBtn.setImageResource(R.drawable.developmentcontinuebutton);
    } else {
      Log.e("Specified themeId is no in DB for: ", theme.getName());
    }
  }
   
  public void openHealthDetails(View v) {
    // save radio value
    int selectResp = 0;
    int radioButtonID = rbg.getCheckedRadioButtonId();
    View rb = rbg.findViewById(radioButtonID);    
    
    // TODO: temporary until the DB has been filled with all of the theme content - after that is done, use this to force user to select before proceeding
    if (rb != null) {
      selectResp = Integer.parseInt(rb.getTag().toString());
    }
      
    // using 0 for clientId - no specific client here
    HealthSelectRecorded hsr = new HealthSelectRecorded(visitId, selectResp, 0, healthThemeName, null, new Date(), getHelper());
      try {
        Dao<HealthSelectRecorded, Integer> hsrDao = getHelper().getHealthSelectRecordedDao();
        hsrDao.create(hsr);
      } catch (SQLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
    
    // open new intent
    Intent i = new Intent(HealthOverviewRecordActivity.this, HealthDetailsActivity.class);
    Bundle b = new Bundle();
    b.putInt("visitId",visitId);
      b.putInt("hhId",hhId);
      b.putString("healthTheme",healthThemeName);
    i.putExtras(b);
    startActivity(i);
    finish();
  }     
}




Java Source Code List

org.chat.android.BaseActivity.java
org.chat.android.CHADelivery.java
org.chat.android.CHAOverviewActivity.java
org.chat.android.CHASelectChildActivity.java
org.chat.android.CHASelectChildAdapter.java
org.chat.android.ChatUtil.java
org.chat.android.ClientsAdapter.java
org.chat.android.DatabaseHelper.java
org.chat.android.GPSTracker.java
org.chat.android.HealthDeliveryActivity.java
org.chat.android.HealthDetailsActivity.java
org.chat.android.HealthOverviewActivity.java
org.chat.android.HealthOverviewRecordActivity.java
org.chat.android.HomeActivity.java
org.chat.android.ImmunizationsReceivedActivity.java
org.chat.android.ImmunizationsSummaryActivity.java
org.chat.android.LoginActivity.java
org.chat.android.Mail.java
org.chat.android.ModelHelper.java
org.chat.android.MyApplication.java
org.chat.android.ResourcesActivity.java
org.chat.android.RestoreVisitActivity.java
org.chat.android.ServiceDeliveryActivity.java
org.chat.android.ServiceDeliveryAdapter.java
org.chat.android.ServiceDetailsActivity.java
org.chat.android.ServiceOtherActivity.java
org.chat.android.ServiceOverviewActivity.java
org.chat.android.ServicesAdapter.java
org.chat.android.SetupDB.java
org.chat.android.SetupVisitActivity.java
org.chat.android.SyncResourcesActivity.java
org.chat.android.Auth.AccountGeneral.java
org.chat.android.Auth.AuthenticatorService.java
org.chat.android.Auth.Authenticator.java
org.chat.android.Auth.ChatAuthServerAuthenticate.java
org.chat.android.Auth.MainActivity.java
org.chat.android.Auth.ServerAuthenticate.java
org.chat.android.Sync.StubProvider.java
org.chat.android.Sync.SyncAdapter.java
org.chat.android.Sync.SyncService.java
org.chat.android.Sync.provider.ChatContentProvider.java
org.chat.android.models.Attendance.java
org.chat.android.models.CHAAccessed.java
org.chat.android.models.Client.java
org.chat.android.models.HealthPage.java
org.chat.android.models.HealthSelectRecorded.java
org.chat.android.models.HealthSelect.java
org.chat.android.models.HealthTheme.java
org.chat.android.models.HealthTopicAccessed.java
org.chat.android.models.HealthTopic.java
org.chat.android.models.Household.java
org.chat.android.models.PageAssessment1.java
org.chat.android.models.PageSelect1.java
org.chat.android.models.PageText1.java
org.chat.android.models.PageVideo1.java
org.chat.android.models.ResourceAccessed.java
org.chat.android.models.Resource.java
org.chat.android.models.Role.java
org.chat.android.models.ServiceAccessed.java
org.chat.android.models.Service.java
org.chat.android.models.TopicVideo.java
org.chat.android.models.Util.java
org.chat.android.models.VaccineRecorded.java
org.chat.android.models.Vaccine.java
org.chat.android.models.VideoAccessed.java
org.chat.android.models.Video.java
org.chat.android.models.Visit.java
org.chat.android.models.Worker.java
org.chat.android.pages.Assessment1Fragment.java
org.chat.android.pages.BaseFragment.java
org.chat.android.pages.ReferralFragment.java
org.chat.android.pages.Select1Fragment.java
org.chat.android.pages.Text1Fragment.java
org.chat.android.pages.Video1Fragment.java