@Override
 public void bookmarkNodeChanged(BookmarkItem node) {
   if (mBookmarkId.equals(node.getId())
       || node.getId()
           .equals(mEnhancedBookmarksModel.getBookmarkById(mBookmarkId).getParentId())) {
     updateViewContent();
   }
 }
 @Override
 public void bookmarkNodeMoved(
     BookmarkItem oldParent, int oldIndex, BookmarkItem newParent, int newIndex) {
   BookmarkId movedBookmark =
       mEnhancedBookmarksModel.getChildAt(newParent.getId(), newIndex);
   if (movedBookmark.equals(mBookmarkId)) {
     mFolderTextView.setText(newParent.getTitle());
   }
 }
 @Override
 public void bookmarkNodeRemoved(
     BookmarkItem parent, int oldIndex, BookmarkItem node, boolean isDoingExtensiveChanges) {
   if (mBookmarkId.equals(node.getId())) {
     finish();
   }
 }
  private void updateViewContent() {
    BookmarkItem bookmarkItem = mEnhancedBookmarksModel.getBookmarkById(mBookmarkId);

    if (!TextUtils.equals(mTitleEditText.getTrimmedText(), bookmarkItem.getTitle())) {
      mTitleEditText.setText(bookmarkItem.getTitle());
    }
    String folderTitle = mEnhancedBookmarksModel.getBookmarkTitle(bookmarkItem.getParentId());
    if (!TextUtils.equals(mFolderTextView.getText(), folderTitle)) {
      mFolderTextView.setText(folderTitle);
    }
    if (!TextUtils.equals(mUrlEditText.getTrimmedText(), bookmarkItem.getUrl())) {
      mUrlEditText.setText(bookmarkItem.getUrl());
    }
    mUrlEditText.setEnabled(bookmarkItem.isUrlEditable());
    mFolderTextView.setEnabled(bookmarkItem.isMovable());
  }
 private void updateViewContent() {
   BookmarkItem bookmarkItem = mEnhancedBookmarksModel.getBookmarkById(mBookmarkId);
   mTitleEditText.setText(bookmarkItem.getTitle());
   mUrlEditText.setText(bookmarkItem.getUrl());
   mFolderTextView.setText(mEnhancedBookmarksModel.getBookmarkTitle(bookmarkItem.getParentId()));
 }
Ejemplo n.º 6
0
 /**
  * Generate color based on bookmarked url's hash code. Same color will always be returned given
  * same bookmark item.
  *
  * @param item bookmark the color represents for
  * @return int for the generated color
  */
 public static int generateBackgroundColor(BookmarkItem item) {
   int normalizedIndex =
       MathUtils.positiveModulo(item.getUrl().hashCode(), DEFAULT_BACKGROUND_COLORS.length);
   return DEFAULT_BACKGROUND_COLORS[normalizedIndex];
 }