예제 #1
0
  private boolean updateCurrentAuthorData() {
    boolean updateStatus = false;
    SelectedBitmap current = getCurrentBitmap();
    if (current == null) {
      return false;
    }
    mSaveResult = ImageXmlWriter.RESULT_NONE;
    ImageAuthor author = current.mBuilder.getAuthor();
    String authorNameText = mAuthorName.getText().toString();
    if (author == null) {
      author = new ImageAuthor();
      current.mBuilder.setAuthor(author);
      updateApplyToOthersButton(current);
      updateStatus = true;
    } else {
      if (TextUtils.isEmpty(author.getName()) && !TextUtils.isEmpty(authorNameText)) {
        updateStatus = true;
      }
    }
    author.setName(authorNameText);
    author.setSource(mAuthorSource.getText().toString());
    author.setExtras(mAuthorExtras.getText().toString());
    if (updateStatus) {
      current.checkedBuild();
      synchronized (mSelectedBitmaps) {
        for (SelectedBitmap bitmap : mSelectedBitmaps) {
          if (bitmap.mBuilder.getAuthor() == author) {
            bitmap.checkedBuild();
          }
        }
      }
    }
    if (TextUtils.isEmpty(author.getName())) {
      boolean authorCleared =
          TextUtils.isEmpty(author.getSource()) && TextUtils.isEmpty(author.getExtras());
      // if author data cleared, remove author from this and connected bitmaps
      // in any case clear image as name is required
      synchronized (mSelectedBitmaps) {
        for (SelectedBitmap bitmap : mSelectedBitmaps) {
          if (bitmap.mBuilder.getAuthor() == author) {
            if (authorCleared) {
              bitmap.mBuilder.setAuthor(null);
            }
            bitmap.mImage = null;
          }
        }
      }
      updateApplyToOthersButton(current);

      updateStatus = true;
    }
    return updateStatus;
  }