@Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

    Intent i;

    switch (item.getItemId()) {
      case MENU_OPEN_IN_TAB:
        i = new Intent();
        i.putExtra(Constants.EXTRA_ID_NEW_TAB, true);
        i.putExtra(Constants.EXTRA_ID_URL, mDbAdapter.getBookmarkById(info.id)[1]);
        setResult(RESULT_OK, i);
        finish();
        return true;

      case MENU_EDIT_BOOKMARK:
        i = new Intent(this, EditBookmarkActivity.class);
        i.putExtra(Constants.EXTRA_ID_BOOKMARK_ID, info.id);
        i.putExtra(Constants.EXTRA_ID_BOOKMARK_TITLE, mDbAdapter.getBookmarkById(info.id)[0]);
        i.putExtra(Constants.EXTRA_ID_BOOKMARK_URL, mDbAdapter.getBookmarkById(info.id)[1]);

        startActivityForResult(i, ACTIVITY_EDIT_BOOKMARK);
        return true;

      case MENU_DELETE_BOOKMARK:
        mDbAdapter.deleteBookmark(info.id);
        fillData();
        return true;
      default:
        return super.onContextItemSelected(item);
    }
  }
  @Override
  public void run() {
    mDbAdapter = new DbAdapter(mContext);
    mDbAdapter.open();

    updateBookmarkScreenShot();

    mDbAdapter.close();
  }
Пример #3
0
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

      Log.d(TAG, "Upgrading database.");

      switch (oldVersion) {
        case 1:
          db.execSQL(
              "ALTER TABLE " + BOOKMARKS_DATABASE_TABLE + " ADD " + BOOKMARKS_THUMBNAIL + " BLOB;");
        case 2:
          db.execSQL(
              "ALTER TABLE "
                  + BOOKMARKS_DATABASE_TABLE
                  + " ADD "
                  + BOOKMARKS_COUNT
                  + " INTEGER NOT NULL DEFAULT 0;");
        case 3:
          db.execSQL(ADBLOCK_WHITELIST_DATABASE_CREATE);
          mParent.mAdBlockListNeedPopulate = true;
        case 4:
          db.execSQL(MOBILE_VIEW_DATABASE_CREATE);
        default:
          break;
      }
    }
Пример #4
0
 @Override
 public void onCreate(SQLiteDatabase db) {
   db.execSQL(BOOKMARKS_DATABASE_CREATE);
   db.execSQL(HISTORY_DATABASE_CREATE);
   db.execSQL(ADBLOCK_WHITELIST_DATABASE_CREATE);
   db.execSQL(MOBILE_VIEW_DATABASE_CREATE);
   mParent.mAdBlockListNeedPopulate = true;
 }
  /** Update the bookmark screen shot. */
  private void updateBookmarkScreenShot() {

    Cursor c = mDbAdapter.getBookmarkFromUrl(mWebView.getOriginalUrl(), mWebView.getLoadedUrl());

    if ((c != null) && (c.moveToFirst())) {

      long id = c.getLong(c.getColumnIndex(DbAdapter.BOOKMARKS_ROWID));

      Bitmap bm = createScreenshot();

      if (bm != null) {

        mDbAdapter.updateBookmarkThumbnail(id, bm);
      }

      mDbAdapter.updateBookmarkCount(id);
    }

    c.close();
  }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    Intent result = new Intent();
    result.putExtra(Constants.EXTRA_ID_NEW_TAB, false);
    result.putExtra(Constants.EXTRA_ID_URL, mDbAdapter.getBookmarkById(id)[1]);

    setResult(RESULT_OK, result);
    finish();
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    long id = ((AdapterContextMenuInfo) menuInfo).id;
    if (id != -1) {
      menu.setHeaderTitle(mDbAdapter.getBookmarkById(id)[0]);
    }

    menu.add(0, MENU_OPEN_IN_TAB, 0, R.string.BookmarksListActivity_MenuOpenInTab);
    menu.add(0, MENU_EDIT_BOOKMARK, 0, R.string.BookmarksListActivity_MenuEditBookmark);
    menu.add(0, MENU_DELETE_BOOKMARK, 0, R.string.BookmarksListActivity_MenuDeleteBookmark);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bookmarkslistactivity);

    setTitle(R.string.BookmarksListActivity_Title);

    mDbAdapter = new DbAdapter(this);
    mDbAdapter.open();

    registerForContextMenu(getListView());

    fillData();
  }
  /** Fill the bookmark to the list UI. */
  private void fillData() {
    mCursor = mDbAdapter.fetchBookmarks();
    startManagingCursor(mCursor);

    String[] from = new String[] {DbAdapter.BOOKMARKS_TITLE, DbAdapter.BOOKMARKS_URL};
    int[] to = new int[] {R.id.BookmarkRow_Title, R.id.BookmarkRow_Url};

    mCursorAdapter = new BookmarksCursorAdapter(this, R.layout.bookmarkrow, mCursor, from, to);
    setListAdapter(mCursorAdapter);

    setAnimation();

    // mCursor.close();
  }
 @Override
 protected void onDestroy() {
   mDbAdapter.close();
   super.onDestroy();
 }