@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_bookmark);

    Intent intent = getIntent();

    if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.hasExtra(Intent.EXTRA_TEXT)) {
      bookmark = new Bookmark();

      ShareCompat.IntentReader reader = ShareCompat.IntentReader.from(this);

      String url = StringUtils.getUrl(reader.getText().toString());
      bookmark.setUrl(url);

      if (reader.getSubject() != null) bookmark.setDescription(reader.getSubject());

      if (url.equals("")) {
        Toast.makeText(this, R.string.add_bookmark_invalid_url, Toast.LENGTH_LONG).show();
      }

      if (intent.hasExtra(Constants.EXTRA_DESCRIPTION)) {
        bookmark.setDescription(intent.getStringExtra(Constants.EXTRA_DESCRIPTION));
      }
      bookmark.setNotes(intent.getStringExtra(Constants.EXTRA_NOTES));
      bookmark.setTagString(intent.getStringExtra(Constants.EXTRA_TAGS));
      bookmark.setShared(!intent.getBooleanExtra(Constants.EXTRA_PRIVATE, privateDefault));

      try {
        Bookmark old = BookmarkManager.GetByUrl(bookmark.getUrl(), this);
        bookmark = old.copy();
      } catch (Exception e) {

      }

    } else if (Intent.ACTION_EDIT.equals(intent.getAction())) {
      int id = Integer.parseInt(intent.getData().getLastPathSegment());
      try {
        bookmark = BookmarkManager.GetById(id, this);
        oldBookmark = bookmark.copy();

        update = true;
      } catch (ContentNotFoundException e) {
        e.printStackTrace();
      }
    }

    if (update) setTitle(getString(R.string.add_bookmark_edit_title));
    else setTitle(getString(R.string.add_bookmark_add_title));

    frag =
        (AddBookmarkFragment)
            getSupportFragmentManager().findFragmentById(R.id.add_bookmark_fragment);
    frag.loadBookmark(bookmark, oldBookmark);
  }
 public void cancelHandler(View v) {
   frag.cancelHandler(v);
 }
 public void saveHandler(View v) {
   frag.saveHandler(v);
 }