Ejemplo n.º 1
0
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_picture_note, parent, false);
    date = getArguments().getSerializable(EXTRA_PICTURE_DATE).toString();
    mNote = (PictureNote) NoteManager.get(getActivity()).getNote(date);

    mDateDisplay = (TextView) v.findViewById(R.id.picture_note_date);
    mDateDisplay.setText(mNote.getDate().toString());

    mImage = (ImageView) v.findViewById(R.id.picture);

    if (mNote.getUriString() == null) {
      Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      filename = mNote.getDate() + ".jpg";

      File file = new File(Environment.getExternalStorageDirectory(), filename);

      imageFileUri = Uri.fromFile(file);

      pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri);

      if (pictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
        startActivityForResult(pictureIntent, TAKE_PICTURE_REQUEST);
        mNote.setUriString(imageFileUri.toString());
        image = scaleBitmap(Uri.parse(mNote.getUriString()));
        mImage.setImageBitmap(image);

      } else {
        Toast.makeText(getActivity(), "No camera available", Toast.LENGTH_SHORT).show();
      }
    } else {
      imageFileUri = Uri.parse(mNote.getUriString());
      image = scaleBitmap(imageFileUri);
      mImage.setImageBitmap(image);
    }

    mTags = (EditText) v.findViewById(R.id.picture_tags);
    mTags.setText(mNote.getTags());
    mTags.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {

            mNote.setTags(s.toString());
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });

    return v;
  }
Ejemplo n.º 2
0
 public void run() {
   NoteField noteField = (NoteField) getLeafFieldWithFocus();
   task.deleteNote(noteField.note);
   notes.delete(noteField);
   com.zavitz.mytasks.functions.PersistentUtils.save();
 }