Android Open Source - Visu New Study Dialog






From Project

Back to project page Visu.

License

The source code is released under:

Apache License

If you think the Android project Visu 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 com.ufavaloro.android.visu.UI;
//w w w.j  a  v  a  2s  .co m
import java.util.ArrayList;

import com.ufavaloro.android.visu.R;
import com.ufavaloro.android.visu.study.Study;

import android.app.Dialog;
import android.content.Context;
import android.util.SparseArray;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckedTextView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class NewStudyDialog extends Dialog {
  
  private EditText mEditTextPatientName;
  private EditText mEditTextPatientSurname;
  private EditText mEditTextStudyName;
  private ListView mListViewChannels;
  private Button mButtonStartNewStudy;
  private Button mButtonCancelNewStudy;
  
  private Context mContext;
  private Study mStudy;
  private SparseArray<Integer> mChannelsToStore = new SparseArray<Integer>();
  
  
  public NewStudyDialog(Context context, int theme) {
    super(context, theme);
    mContext = context;
  }
  
  public void setup() {
    if(mStudy.bluetooth.getConnected() == false) {
      Toast.makeText(mContext, "No se encuentra conectado", Toast.LENGTH_SHORT).show();
      return;
    }
    setCanceledOnTouchOutside(false);
    setTitle("Seleccione una acci?n");
    inflate();
    setListeners();
    populateListView();
  }
  
  private void inflate() {
    
    setContentView(R.layout.dialog_new_study);
    
    // Bot?n de iniciar estudio
    mButtonStartNewStudy = (Button) findViewById(R.id.buttonStartStudy);
    
    // Bot?n de cancelar
    mButtonCancelNewStudy = (Button) findViewById(R.id.buttonCancel);

    // EditText con el nombre del paciente
    mEditTextPatientName = (EditText) findViewById(R.id.editTextPatientName);

    // EditText con el apellido del paciente
    mEditTextPatientSurname = (EditText) findViewById(R.id.editTextPatientSurname);
    
    // EditText con el nombre del estudio
    mEditTextStudyName = (EditText) findViewById(R.id.editTextStudyName);

    // ListView con los canales
    mListViewChannels = (ListView) findViewById(R.id.listViewChannels);
  }
  
  private void setListeners() {
    
    // Bot?n de iniciar estudio
    mButtonStartNewStudy.setOnClickListener(new android.view.View.OnClickListener() {
      @Override
      public void onClick(View v) {
        newStudyDialogResult();
      }
    });
    
    // Bot?n de cancelar
    mButtonCancelNewStudy.setOnClickListener(new android.view.View.OnClickListener() {
      @Override
      public void onClick(View v) {
        dismiss();
      }
    });
    
    // ListView con los canales
    mListViewChannels.setOnItemClickListener(new OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView<?> arg0, View view, int channel, long arg3) {
        if(mChannelsToStore.get(channel) == null) {
          view.setBackgroundColor(mContext.getResources().getColor(R.color.common_action_bar_splitter));
          mChannelsToStore.append(channel, channel);
        } else {
          view.setBackgroundColor(0);
          mChannelsToStore.remove(channel);
        }
      }
    });
    
  }
  
  private void populateListView() {
    // Populate Channel ListView
    ArrayList<String> channels = new ArrayList<String>();
    for(int i = 0; i < mStudy.getTotalAdcChannels(); i++) {
      channels.add("Canal " + String.valueOf(i+1));
    }
      ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_item, channels);      
      mListViewChannels.setAdapter(arrayAdapter);
      mListViewChannels.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
  }

  private void newStudyDialogResult() {
    
    // Extraigo nombre
    String patientName = mEditTextPatientName.getText().toString();
    
    // Extraigo apellido
    String patientSurname = mEditTextPatientSurname.getText().toString();
    
    // Extraigo nombre del estudio
    String studyName = mEditTextStudyName.getText().toString();
  
    // Chequeo si completo todo    
    boolean nameEmpty = patientName.isEmpty();
    boolean surnameEmpty = patientSurname.isEmpty();
    boolean studyEmpty = studyName.isEmpty();  
        
    // Si escribio el nombre y el apellido => PatientInfoOk = true
    if(nameEmpty == false && surnameEmpty == false && studyEmpty == false) {
      
      // Elimino espacios
      patientName = patientName.trim().replace(' ', '_');
      patientSurname = patientSurname.trim().replace(' ', '_');
      studyName = studyName.trim().replace(' ', '_');
      
      // Creo estudios y empiezo a almacenar
      mStudy.newStudy(patientName, patientSurname, studyName, mChannelsToStore);
      mStudy.startRecording();
    
    } else {
      Toast.makeText(mContext, "Por favor complete los campos requeridos", Toast.LENGTH_SHORT).show();
    }
  
      // Cierro dialog
    dismiss();
    
  }
  
  public void setStudy(Study study) {
    mStudy = study;
  }

}




Java Source Code List

com.samsung.sprc.fileselector.FileData.java
com.samsung.sprc.fileselector.FileListAdapter.java
com.samsung.sprc.fileselector.FileOperation.java
com.samsung.sprc.fileselector.FileSelector.java
com.samsung.sprc.fileselector.FileUtils.java
com.samsung.sprc.fileselector.OnHandleFileListener.java
com.samsung.sprc.fileselector.SaveLoadClickListener.java
com.samsung.sprc.fileselector.TextViewWithImage.java
com.ufavaloro.android.visu.UI.ChannelOptionsDialog.java
com.ufavaloro.android.visu.UI.LoadFileFromGoogleDriveDialog.java
com.ufavaloro.android.visu.UI.LoadFileFromLocalStorageDialog.java
com.ufavaloro.android.visu.UI.MainActivity.java
com.ufavaloro.android.visu.UI.MainMenuDialog.java
com.ufavaloro.android.visu.UI.NewStudyDialog.java
com.ufavaloro.android.visu.UI.OfflineChannelPropertiesDialog.java
com.ufavaloro.android.visu.UI.OnlineChannelPropertiesDialog.java
com.ufavaloro.android.visu.UI.StopStudyDialog.java
com.ufavaloro.android.visu.bluetooth.BluetoothProtocolMessage.java
com.ufavaloro.android.visu.bluetooth.BluetoothProtocol.java
com.ufavaloro.android.visu.bluetooth.BluetoothServiceMessage.java
com.ufavaloro.android.visu.bluetooth.BluetoothService.java
com.ufavaloro.android.visu.draw.BitmapManager.java
com.ufavaloro.android.visu.draw.DrawHelper.java
com.ufavaloro.android.visu.draw.RGB.java
com.ufavaloro.android.visu.draw.ReferenceMatrix.java
com.ufavaloro.android.visu.draw.TouchPointer.java
com.ufavaloro.android.visu.draw.channel.ChannelList.java
com.ufavaloro.android.visu.draw.channel.Channel.java
com.ufavaloro.android.visu.draw.channel.DrawBuffer.java
com.ufavaloro.android.visu.draw.channel.InfoBox.java
com.ufavaloro.android.visu.draw.channel.Label.java
com.ufavaloro.android.visu.draw.channel.ScreenElement.java
com.ufavaloro.android.visu.draw.channel.SignalBox.java
com.ufavaloro.android.visu.storage.DataConversion.java
com.ufavaloro.android.visu.storage.SamplesBuffer.java
com.ufavaloro.android.visu.storage.StorageHelperMessage.java
com.ufavaloro.android.visu.storage.StorageHelper.java
com.ufavaloro.android.visu.storage.StudyDataParser.java
com.ufavaloro.android.visu.storage.datatypes.AcquisitionData.java
com.ufavaloro.android.visu.storage.datatypes.AdcData.java
com.ufavaloro.android.visu.storage.datatypes.PatientData.java
com.ufavaloro.android.visu.storage.datatypes.StorageData.java
com.ufavaloro.android.visu.storage.datatypes.StudyData.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveClientMessage.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveClient.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveManagerMessage.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveManager.java
com.ufavaloro.android.visu.storage.local.LocalStorageManager.java
com.ufavaloro.android.visu.study.StudyMessage.java
com.ufavaloro.android.visu.study.StudyType.java
com.ufavaloro.android.visu.study.Study.java