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; }
private void fillImageDataAuthor() { boolean wasFilling = mFillingImageData; mFillingImageData = true; SelectedBitmap current = getCurrentBitmap(); mAuthorName.setText(""); mAuthorSource.setText(""); mAuthorExtras.setText(""); if (current != null && current.mBuilder.getAuthor() != null) { ImageAuthor author = current.mBuilder.getAuthor(); mAuthorName.setText(author.getName()); mAuthorSource.setText(author.getSource()); mAuthorExtras.setText(author.getExtras()); } updateApplyToOthersButton(current); mFillingImageData = wasFilling; }
private void applyAuthorInfoToOthers() { mSaveResult = ImageXmlWriter.RESULT_NONE; boolean updateStatus = false; boolean updateApplyToOthers = false; synchronized (mSelectedBitmaps) { SelectedBitmap current = getCurrentBitmap(); if (current == null) { return; } ImageAuthor author = current.mBuilder.getAuthor(); if (author == null) { return; // should not be clickable if there is not an author for current } if (mApplyToOthersStateRemoveConnection) { ImageAuthor copy = new ImageAuthor( author.getName(), author.getSource(), author.getLicense(), author.getTitle(), author.getExtras()); current.mBuilder.setAuthor(copy); updateApplyToOthers = true; } else { for (SelectedBitmap curr : mSelectedBitmaps) { if (curr.mBuilder.getAuthor() == null) { curr.mBuilder.setAuthor(author); updateApplyToOthers = true; if (curr.checkedBuild()) { updateStatus = true; } } } } if (updateApplyToOthers) { updateApplyToOthersButton(current); } } if (updateStatus) { updateStatus(); } }