protected AwesomeBarCursorAdapter getCursorAdapter() { if (mCursorAdapter == null) { // Load the list using a custom adapter so we can create the bitmaps mCursorAdapter = new AwesomeBarCursorAdapter(mContext); mCursorAdapter.setFilterQueryProvider( new FilterQueryProvider() { @Override public Cursor runQuery(CharSequence constraint) { long start = SystemClock.uptimeMillis(); Cursor c = BrowserDB.filter(getContentResolver(), constraint, MAX_RESULTS); c.getCount(); postLoadFavicons(); long end = SystemClock.uptimeMillis(); if (!mTelemetrySent && TextUtils.isEmpty(constraint)) { int time = (int) (end - start); Telemetry.HistogramAdd("FENNEC_AWESOMEBAR_ALLPAGES_EMPTY_TIME", time); mTelemetrySent = true; } return c; } }); } return mCursorAdapter; }
private void addAllPagesTab() { Log.d(LOGTAG, "Creating All Pages tab"); addAwesomeTab(ALL_PAGES_TAB, R.string.awesomebar_all_pages_title, R.id.all_pages_list); // Load the list using a custom adapter so we can create the bitmaps mAllPagesCursorAdapter = new AwesomeBarCursorAdapter( mContext, R.layout.awesomebar_row, null, new String[] {URLColumns.TITLE, URLColumns.URL, URLColumns.FAVICON}, new int[] {R.id.title, R.id.url, R.id.favicon}); mAllPagesCursorAdapter.setViewBinder(new AwesomeCursorViewBinder()); mAllPagesCursorAdapter.setFilterQueryProvider( new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { ContentResolver resolver = mContext.getContentResolver(); long start = SystemClock.uptimeMillis(); Cursor c = BrowserDB.filter(resolver, constraint, MAX_RESULTS); c.getCount(); // ensure the query runs at least once long end = SystemClock.uptimeMillis(); Log.i(LOGTAG, "Got cursor in " + (end - start) + "ms"); return c; } }); final ListView allPagesList = (ListView) findViewById(R.id.all_pages_list); allPagesList.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { handleItemClick(allPagesList, position); } }); allPagesList.setAdapter(mAllPagesCursorAdapter); allPagesList.setOnTouchListener(mListTouchListener); }