private void updateList() {
   mCardsAdapter.notifyDataSetChanged();
   int count = mCards.size();
   setTitle(
       getResources()
           .getQuantityString(
               R.plurals.card_browser_title, count, mDeck.getDeckName(), count, mAllCards.size()));
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Themes.applyTheme(this);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.card_browser);

    mDeck = AnkiDroidApp.deck();
    mDeck.resetUndo();

    mBackground = Themes.getCardBrowserBackground();

    SharedPreferences preferences = PrefSettings.getSharedPrefs(getBaseContext());
    mrelativeBrowserFontSize =
        preferences.getInt("relativeCardBrowserFontSize", DEFAULT_FONT_SIZE_RATIO);
    mPrefFixArabic = preferences.getBoolean("fixArabicText", false);

    mCards = new ArrayList<HashMap<String, String>>();
    mAllCards = new ArrayList<HashMap<String, String>>();
    mCardsListView = (ListView) findViewById(R.id.card_browser_list);

    mCardsAdapter =
        new SizeControlledListAdapter(
            this,
            mCards,
            R.layout.card_item,
            new String[] {"question", "answer", "marSus"},
            new int[] {R.id.card_question, R.id.card_answer, R.id.card_item},
            mrelativeBrowserFontSize);
    mCardsAdapter.setViewBinder(
        new SimpleAdapter.ViewBinder() {
          @Override
          public boolean setViewValue(View view, Object arg1, String text) {
            if (view.getId() == R.id.card_item) {
              int which = BACKGROUND_NORMAL;
              if (text.equals("11")) {
                which = BACKGROUND_MARKED_SUSPENDED;
              } else if (text.substring(1, 2).equals("1")) {
                which = BACKGROUND_SUSPENDED;
              } else if (text.substring(0, 1).equals("1")) {
                which = BACKGROUND_MARKED;
              }
              view.setBackgroundResource(mBackground[which]);
              return true;
            }
            return false;
          }
        });

    mCardsListView.setAdapter(mCardsAdapter);
    mCardsListView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent editCard = new Intent(CardBrowser.this, CardEditor.class);
            mPositionInCardsList = position;
            mSelectedCard =
                mDeck.cardFromId(Long.parseLong(mCards.get(mPositionInCardsList).get("id")));
            sEditorCard = mSelectedCard;
            editCard.putExtra("callfromcardbrowser", true);
            startActivityForResult(editCard, EDIT_CARD);
            if (Integer.valueOf(android.os.Build.VERSION.SDK) > 4) {
              ActivityTransitionAnimation.slide(CardBrowser.this, ActivityTransitionAnimation.LEFT);
            }
          }
        });
    registerForContextMenu(mCardsListView);

    mSearchEditText = (EditText) findViewById(R.id.card_browser_search);
    mSearchEditText.addTextChangedListener(
        new TextWatcher() {
          public void afterTextChanged(Editable s) {
            mTimerHandler.removeCallbacks(updateList);
            mTimerHandler.postDelayed(updateList, WAIT_TIME_UNTIL_UPDATE);
          }

          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          public void onTextChanged(CharSequence s, int start, int before, int count) {}
        });
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    setTitle(mDeck.getDeckName());

    allTags = null;
    mSelectedTags = new HashSet<String>();

    getCards();
  }