コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_formulario);
    helper = new FormularioHelper(this);
    Aluno alunoSelecionado =
        (Aluno) getIntent().getSerializableExtra(ListaAlunosActivity.ALUNO_SELECIONADO);

    if (alunoSelecionado != null) {
      helper.colocaNoFormulario(alunoSelecionado);
    }

    ImageView fotoButton = helper.getFotoButton();
    fotoButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            localArquivoFoto =
                getExternalFilesDir(null) + "/" + System.currentTimeMillis() + ".jpg";
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(localArquivoFoto)));
            startActivityForResult(intent, CAMERA_REQUEST_CODE);
          }
        });
  }
コード例 #2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_formulario_ok:
        if (helper.estaValido()) {
          AlunoDAO alunoDAO = new AlunoDAO(this);
          Aluno aluno = helper.pegaAlunoDoFormulario();
          alunoDAO.adicionaOuAltera(aluno);
          alunoDAO.close();

          finish();
        } else {
          helper.mostrarErros();
        }
        return false;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
コード例 #3
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == CAMERA_REQUEST_CODE) {
     if (resultCode == Activity.RESULT_OK) {
       helper.carregarImagem(this.localArquivoFoto);
     } else {
       this.localArquivoFoto = null;
     }
   }
 }