Use Koin for creating instances of ContactPictureLoader

This commit is contained in:
cketti 2018-07-19 16:02:42 +02:00
parent 9ada669e0b
commit 4faf17fbf2
6 changed files with 7 additions and 10 deletions

View file

@ -39,7 +39,7 @@ public class K9ChooserTargetService extends ChooserTargetService {
Context applicationContext = getApplicationContext();
recipientLoader = RecipientLoader.getMostContactedRecipientLoader(applicationContext, MAX_TARGETS);
contactPictureLoader = ContactPicture.getContactPictureLoader(applicationContext);
contactPictureLoader = ContactPicture.getContactPictureLoader();
}
@Override

View file

@ -153,7 +153,7 @@ public class RecipientAdapter extends BaseAdapter implements Filterable {
}
public static void setContactPhotoOrPlaceholder(Context context, ImageView imageView, Recipient recipient) {
ContactPicture.getContactPictureLoader(context).loadContactPicture(recipient, imageView);
ContactPicture.getContactPictureLoader().loadContactPicture(recipient, imageView);
}
@Override

View file

@ -1,17 +1,13 @@
package com.fsck.k9.activity.misc;
import android.content.Context;
import com.fsck.k9.DI;
import com.fsck.k9.contacts.ContactLetterBitmapCreator;
import com.fsck.k9.contacts.ContactPictureLoader;
public class ContactPicture {
public static ContactPictureLoader getContactPictureLoader(Context context) {
ContactLetterBitmapCreator contactLetterBitmapCreator = DI.get(ContactLetterBitmapCreator.class);
return new ContactPictureLoader(context.getApplicationContext(), contactLetterBitmapCreator);
public static ContactPictureLoader getContactPictureLoader() {
return DI.get(ContactPictureLoader.class);
}
}

View file

@ -6,4 +6,5 @@ val contactsModule = applicationContext {
bean { ContactLetterExtractor() }
factory { ContactLetterBitmapConfig(get()) }
factory { ContactLetterBitmapCreator(get(), get()) }
factory { ContactPictureLoader(get(), get()) }
}

View file

@ -430,7 +430,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
stars = K9.messageListStars();
if (K9.showContactPicture()) {
contactsPictureLoader = ContactPicture.getContactPictureLoader(getActivity());
contactsPictureLoader = ContactPicture.getContactPictureLoader();
}
restoreInstanceState(savedInstanceState);

View file

@ -291,7 +291,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
if (K9.showContactPicture()) {
mContactBadge.setVisibility(View.VISIBLE);
mContactsPictureLoader = ContactPicture.getContactPictureLoader(mContext);
mContactsPictureLoader = ContactPicture.getContactPictureLoader();
} else {
mContactBadge.setVisibility(View.GONE);
}