Currently, the project structure is too coupled to make modifications, for example, you have the following code inside your ViewHolder
public void onClick(View v) {
int position = getAdapterPosition();
mCursor.moveToPosition(position);
int topicNameIndex = mCursor.getColumnIndex(DatabaseContract.FlashCardsEntry.FLASH_CARD_TOPIC_NAME);
int questionIndex = mCursor.getColumnIndex(DatabaseContract.FlashCardsEntry.FLASH_CARD_QUESTION);
int answerIndex = mCursor.getColumnIndex(DatabaseContract.FlashCardsEntry.FLASH_CARD_ANSWER);
String topicName = mCursor.getString(topicNameIndex);
String question = mCursor.getString(questionIndex);
String answer = mCursor.getString(answerIndex);
flashCardsRecyclerViewCursorAdapterOnClickListener.onFlashCardClicked(new FlashCard(topicName,question,answer));
}
A ViewHolder shouldn't know that we're using Cursors for storing data, Instead it should only deals with a DTO and do the conversion to cursor inside a helper class for loading/saving.
@vincent-paing Yeah i do agree with your suggestions. This coupling may be present in more than one place but we should take one at a time starting from this one. You can definitely go ahead and fix it. :smile:
Currently, the project structure is too coupled to make modifications, for example, you have the following code inside your ViewHolder
A ViewHolder shouldn't know that we're using Cursors for storing data, Instead it should only deals with a DTO and do the conversion to cursor inside a helper class for loading/saving.