Decouple MessageListAdapter from MessageListFragment.previewLines
This commit is contained in:
parent
8fa2ae65a8
commit
d1013ba901
2 changed files with 7 additions and 6 deletions
|
@ -42,6 +42,8 @@ import com.fsck.k9.fragment.MLFProjectionInfo.TO_LIST_COLUMN
|
|||
import com.fsck.k9.fragment.MLFProjectionInfo.UID_COLUMN
|
||||
import com.fsck.k9.helper.MessageHelper
|
||||
|
||||
import kotlin.math.max
|
||||
|
||||
class MessageListAdapter internal constructor(
|
||||
theme: Resources.Theme,
|
||||
private val res: Resources,
|
||||
|
@ -86,6 +88,9 @@ class MessageListAdapter internal constructor(
|
|||
array.recycle()
|
||||
}
|
||||
|
||||
private inline val previewLines: Int
|
||||
get() = K9.messageListPreviewLines
|
||||
|
||||
|
||||
private fun recipientSigil(toMe: Boolean, ccMe: Boolean): String {
|
||||
return if (toMe) {
|
||||
|
@ -129,7 +134,7 @@ class MessageListAdapter internal constructor(
|
|||
|
||||
|
||||
// 1 preview line is needed even if it is set to 0, because subject is part of the same text view
|
||||
holder.preview.setLines(Math.max(fragment.previewLines, 1))
|
||||
holder.preview.setLines(max(previewLines, 1))
|
||||
fontSizes.setViewTextSize(holder.preview, fontSizes.messageListPreview)
|
||||
holder.threadCount = view.findViewById(R.id.thread_count)
|
||||
fontSizes.setViewTextSize(holder.threadCount, fontSizes.messageListSubject) // thread count is next to subject
|
||||
|
@ -206,7 +211,7 @@ class MessageListAdapter internal constructor(
|
|||
val sigil = recipientSigil(toMe, ccMe)
|
||||
val messageStringBuilder = SpannableStringBuilder(sigil)
|
||||
.append(beforePreviewText)
|
||||
if (fragment.previewLines > 0) {
|
||||
if (previewLines > 0) {
|
||||
val preview = getPreview(cursor)
|
||||
messageStringBuilder.append(" ").append(preview)
|
||||
}
|
||||
|
|
|
@ -163,9 +163,6 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
|||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
Parcelable savedListState;
|
||||
|
||||
int previewLines = 0;
|
||||
|
||||
|
||||
private MessageListAdapter adapter;
|
||||
private View footerView;
|
||||
private FolderInfoHolder currentFolder;
|
||||
|
@ -411,7 +408,6 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
|||
preferences = Preferences.getPreferences(appContext);
|
||||
messagingController = MessagingController.getInstance(getActivity().getApplication());
|
||||
|
||||
previewLines = K9.getMessageListPreviewLines();
|
||||
checkboxes = K9.isShowMessageListCheckboxes();
|
||||
stars = K9.isShowMessageListStars();
|
||||
|
||||
|
|
Loading…
Reference in a new issue