Android Open Source - field-data-app Bio Sample Activity Fragment






From Project

Back to project page field-data-app.

License

The source code is released under:

MIT License

If you think the Android project field-data-app 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 nz.cri.gns.springs.fragments;
/*from  w  w w. j  a  va  2s. co m*/
import nz.cri.gns.springs.db.BiologicalSample;
import nz.cri.gns.springs.db.Survey;
import android.os.Bundle;

/**
 * Base class for screens used to collect data related to a biological sample
 * collected from a geothermal feature.
 * @author duncanw
 */
public class BioSampleActivityFragment extends SpringsFragment {

  protected BiologicalSample currentSample;
  protected Survey currentSurvey;
  
  private static final String SAMPLE_KEY = "currentSample";

  public BiologicalSample getCurrentSample() {
    return currentSample;
  }

  public BioSampleActivityFragment setCurrentSample(BiologicalSample currentSample) {
    this.currentSample = currentSample;
    setCurrentSurvey();
    return this;
  }
  
    protected void setCurrentSurvey() {
      
      currentSurvey = currentSample.getSurvey();
      if (currentSurvey == null) {
        Survey survey = new Survey();
        survey.setSurveyDate(System.currentTimeMillis());
        getHelper().getSurveyDao().create(survey);
        currentSample.setSurvey(survey);
        getHelper().getBiologicalSampleDao().update(currentSample);
        currentSurvey = survey;
      } else {
        getHelper().getSurveyDao().refresh(currentSurvey);
        getHelper().getFeatureDao().refresh(currentSurvey.getFeature());
      }
    }
    
    @Override
    public void onSaveInstanceState(Bundle instanceState) {
      super.onSaveInstanceState(instanceState);
      instanceState.putSerializable(SAMPLE_KEY, currentSample);
    }
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      if (savedInstanceState != null) {
        currentSample = (BiologicalSample)savedInstanceState.getSerializable(SAMPLE_KEY);
        getHelper().getBiologicalSampleDao().refresh(currentSample);
        setCurrentSurvey();
      }
    }
    
}




Java Source Code List

nz.cri.gns.springs.GpsLocation.java
nz.cri.gns.springs.SpringsApplication.java
nz.cri.gns.springs.activity.BioSampleActivity.java
nz.cri.gns.springs.activity.EditBiologicalSamplesActivity.java
nz.cri.gns.springs.activity.MainMenuActivity.java
nz.cri.gns.springs.activity.ManageBioSamplesActivity.java
nz.cri.gns.springs.activity.SettingsActivity.java
nz.cri.gns.springs.db.BiologicalSampleTest.java
nz.cri.gns.springs.db.BiologicalSample.java
nz.cri.gns.springs.db.ChecklistItem.java
nz.cri.gns.springs.db.Configuration.java
nz.cri.gns.springs.db.FeatureTest.java
nz.cri.gns.springs.db.Feature.java
nz.cri.gns.springs.db.PersistentObject.java
nz.cri.gns.springs.db.SpringsDbHelper.java
nz.cri.gns.springs.db.SurveyImage.java
nz.cri.gns.springs.db.SurveyTest.java
nz.cri.gns.springs.db.Survey.java
nz.cri.gns.springs.fragments.AppearanceFragment.java
nz.cri.gns.springs.fragments.BioSampleActivityFragment.java
nz.cri.gns.springs.fragments.BioSampleFragment.java
nz.cri.gns.springs.fragments.ChooseImageFragment.java
nz.cri.gns.springs.fragments.ExportSamplesFragment.java
nz.cri.gns.springs.fragments.FeatureIdFragment.java
nz.cri.gns.springs.fragments.ImageColourPickerFragment.java
nz.cri.gns.springs.fragments.ImageFragment.java
nz.cri.gns.springs.fragments.SpringsDialogFragment.java
nz.cri.gns.springs.fragments.SpringsFragment.java
nz.cri.gns.springs.util.CustomExceptionHandler.java
nz.cri.gns.springs.util.DataStatistics.java
nz.cri.gns.springs.util.DateTimePickerDialog.java
nz.cri.gns.springs.util.UiUtil.java
nz.cri.gns.springs.util.Util.java