Buggy code:
public static final String TARGET_LANGUAGE = "TARGET_LANGUAGE" ; public static final String SOURCE_TEXT = "SOURCE_TEXT" ; public static final String TARGET_TEXT = "TARGET_TEXT" ; public static final String DECKPATH = "DECK_PATH" ; public static final String CARD_EDITOR_ACTION = "cea" ; public static final int EDIT_REVIEWER_CARD = 0 ; public static final int EDIT_BROWSER_CARD = 1 ; public static final int ADD_CARD = 2 ; public static final int COPY_CARD = 3 ; private static final int DIALOG_MODEL_SELECT = 0 ; private static final int DIALOG_CARD_MODEL_SELECT = 1 ; private static final int DIALOG_TAGS = 2 ; private static final int DIALOG_DECK_SELECT = 3 ; private static final int DIALOG_RESET_CARD = 4 ; private static final String INTENT_CREATE_FLASHCARD = "org.openintents.indiclash.CREATE_FLASHCARD" ; private static final String INTENT_CREATE_FLASHCARD_SEND = "android.intent.action.SEND" ; private static final int MENU_LOOKUP = 0 ; private static final int MENU_RESET = 1 ; private static final int MENU_COPY_CARD = 2 ; private static final int MENU_ADD_CARD = 3 ; private static final int MENU_RESET_CARD_PROGRESS = 4 ; private static final int ACTION_ADD_CARD = 0 ; private BroadcastReceiver mUnmountReceiver = null ; private LinearLayout mFieldsLayoutContainer ; private HashMap < Long , Model > mModels ; private Button mSave ; private Button mCancel ; private Button mTags ; private LinearLayout mModelButtons ; private Button mModelButton ; private Button mSwapButton ; private Button mCardModelButton ; private StyledDialog mCardModelDialog ; private Fact mEditorFact ; private boolean mAddFact = false ; private boolean mForCopy = false ; private boolean mIntentAdd = false ; private String mDeckPath ; private boolean mCardReset = false ; private Deck mDeck ; private Long mCurrentSelectedModelId ; private LinkedList < CardEditor . FieldEditText > mEditFields ; private LinkedHashMap < Long , CardModel > mCardModels ; private LinkedHashMap < Long , CardModel > mSelectedCardModels ; private LinkedHashMap < Long , CardModel > mNewSelectedCardModels ; private ArrayList < Long > cardModelIds = new ArrayList < Long > ( ) ; private boolean mModified ; private String [ ] allTags ; private HashSet < String > mSelectedTags ; private String mFactTags = "" ; private EditText mNewTagEditText ; private StyledDialog mTagsDialog ; private ProgressDialog mProgressDialog ; private HashMap < String , String > mFullDeckPaths ; private String [ ] mDeckNames ; private String mSourceText ; private String mTargetText ; private int mSourcePosition = 0 ; private int mTargetPosition = 1 ; private boolean mCancelled = false ; private boolean mPrefFixArabic ; private int mFilledFields = 0 ; private TaskListener mSaveFactHandler = new DeckTask . TaskListener ( ) { @ Override public void onPreExecute ( ) { } @ Override public void onProgressUpdate ( DeckTask ... values ) { } @ Override public void onPostExecute ( DeckTask . TaskData result ) { } } ; @ Override protected void onCreate ( Bundle savedInstanceState ) { } @ Override public boolean onKeyDown ( int keyCode , KeyEvent event ) { } @ Override protected void onDestroy ( ) { } @ Override public boolean onCreateOptionsMenu ( Menu menu ) { } @ Override public boolean onPrepareOptionsMenu ( Menu menu ) { } @ Override public boolean onOptionsItemSelected ( MenuItem item ) { } public void registerExternalStorageListener ( ) { } private void loadContents ( ) { } private void prepareForIntentAddition ( ) { } private void finishNoStorageAvailable ( ) { } private void closeCardEditor ( ) { } @ Override protected Dialog onCreateDialog ( int id ) { } @ Override protected void onPrepareDialog ( int id , Dialog dialog ) { StyledDialog ad = ( ( StyledDialog ) ( dialog ) ) ; switch ( id ) { case CardEditor . DIALOG_TAGS : if ( ( allTags ) == null ) { <START_BUG> String [ ] oldTags = AnkiDroidApp . deck ( ) . allUserTags ( ) ; <END_BUG> if ( oldTags == null ) { Themes . showThemedToast ( this , getResources ( ) . getString ( error_insufficient_memory ) , false ) ; ad . setEnabled ( false ) ; return ; } Log . i ( TAG , ( "all<seq2seq4repair_space>tags:<seq2seq4repair_space>" + ( Arrays . toString ( oldTags ) ) ) ) ; allTags = new String [ oldTags . length ] ; for ( int i = 0 ; i < ( oldTags . length ) ; i ++ ) { allTags [ i ] = oldTags [ i ] ; } } mSelectedTags . clear ( ) ; List < String > selectedList = Arrays . asList ( Utils . parseTags ( mFactTags ) ) ; int length = allTags . length ; boolean [ ] checked = new boolean [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { String tag = allTags [ i ] ; if ( selectedList . contains ( tag ) ) { checked [ i ] = true ; mSelectedTags . add ( tag ) ; } } ad . setMultiChoiceItems ( allTags , checked , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface arg0 , int which ) { String tag = allTags [ which ] ; if ( mSelectedTags . contains ( tag ) ) { Log . i ( TAG , ( "unchecked<seq2seq4repair_space>tag:<seq2seq4repair_space>" + tag ) ) ; mSelectedTags . remove ( tag ) ; } else { Log . i ( TAG , ( "checked<seq2seq4repair_space>tag:<seq2seq4repair_space>" + tag ) ) ; mSelectedTags . add ( tag ) ; } } } ) ; break ; case CardEditor . DIALOG_CARD_MODEL_SELECT : mCardModels = mDeck . cardModels ( mEditorFact ) ; int size = mCardModels . size ( ) ; String [ ] dialogItems = new String [ size ] ; cardModelIds . clear ( ) ; int i = 0 ; for ( Long id2 : mCardModels . keySet ( ) ) { dialogItems [ i ] = mCardModels . get ( id2 ) . getName ( ) ; cardModelIds . add ( id2 ) ;

Fix:
String [ ] oldTags = mDeck . allUserTags ( ) ;