diff --git a/app/ui/src/main/java/com/fsck/k9/fragment/MessageListAdapter.kt b/app/ui/src/main/java/com/fsck/k9/fragment/MessageListAdapter.kt index 2508364bb..1b84bbe2b 100644 --- a/app/ui/src/main/java/com/fsck/k9/fragment/MessageListAdapter.kt +++ b/app/ui/src/main/java/com/fsck/k9/fragment/MessageListAdapter.kt @@ -21,6 +21,7 @@ import android.widget.TextView import com.fsck.k9.Account import com.fsck.k9.K9 import com.fsck.k9.ui.R +import com.fsck.k9.Preferences import com.fsck.k9.contacts.ContactPictureLoader import com.fsck.k9.controller.MessageReference import com.fsck.k9.helper.MessageHelper @@ -28,6 +29,7 @@ import com.fsck.k9.mail.Address import com.fsck.k9.mailstore.DatabasePreviewType import com.fsck.k9.ui.ContactBadge +import com.fsck.k9.fragment.MLFProjectionInfo.ACCOUNT_UUID_COLUMN import com.fsck.k9.fragment.MLFProjectionInfo.ANSWERED_COLUMN import com.fsck.k9.fragment.MLFProjectionInfo.ATTACHMENT_COUNT_COLUMN import com.fsck.k9.fragment.MLFProjectionInfo.CC_LIST_COLUMN @@ -54,6 +56,7 @@ class MessageListAdapter internal constructor( private val layoutInflater: LayoutInflater, private val messageHelper: MessageHelper, private val contactsPictureLoader: ContactPictureLoader, + private val preferences: Preferences, private val showingThreadedList: Boolean = false ) : CursorAdapter(context, null, 0) { @@ -187,7 +190,7 @@ class MessageListAdapter internal constructor( } override fun bindView(view: View, context: Context, cursor: Cursor) { - val account = fragment.getAccountFromCursor(cursor) + val account = getAccount(cursor) val fromList = cursor.getString(SENDER_LIST_COLUMN) val toList = cursor.getString(TO_LIST_COLUMN) @@ -276,6 +279,11 @@ class MessageListAdapter internal constructor( } } + private fun getAccount(cursor: Cursor): Account { + val accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN) + return preferences.getAccount(accountUuid) + } + private fun formatPreviewText( preview: TextView, beforePreviewText: CharSequence, diff --git a/app/ui/src/main/java/com/fsck/k9/fragment/MessageListFragment.java b/app/ui/src/main/java/com/fsck/k9/fragment/MessageListFragment.java index d0b59c62f..ec58e319b 100644 --- a/app/ui/src/main/java/com/fsck/k9/fragment/MessageListFragment.java +++ b/app/ui/src/main/java/com/fsck/k9/fragment/MessageListFragment.java @@ -586,6 +586,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener layoutInflater, MessageHelper.getInstance(getActivity()), ContactPicture.getContactPictureLoader(), + preferences, showingThreadedList ); @@ -2736,7 +2737,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener adapter.swapCursor(null); } - Account getAccountFromCursor(Cursor cursor) { + private Account getAccountFromCursor(Cursor cursor) { String accountUuid = cursor.getString(ACCOUNT_UUID_COLUMN); return preferences.getAccount(accountUuid); }