mikepenz / MaterialDrawer

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.
https://mikepenz.dev
Apache License 2.0
11.67k stars 2.05k forks source link

DrawerImageLoader not running set function #2715

Closed wakaztahir closed 3 years ago

wakaztahir commented 3 years ago

About this issue

I placed a Log call inside the set function and it just does't call , I have a profile item like this

addProfiles(
                ProfileDrawerItem().apply {
                    nameText = accountName
                    descriptionText = accountEmail
                    badgeStyle = BadgeStyle().apply {
                        textColor = ColorHolder.fromColor(Color.BLACK)
                        color = ColorHolder.fromColorRes(R.color.primaryColor)
                    }
                },
                ProfileSettingDrawerItem().apply {
                    name = StringHolder("Manage Account")
                    description = StringHolder("Manage Timeline Account")
                    icon = ImageHolder(
                        IconicsDrawable(
                            context,
                            CommunityMaterial.Icon.cmd_account_cog_outline
                        )
                    )
                    identifier = 100001
                }
            )

Details

Checklist

wakaztahir commented 3 years ago

I have also put the loader in the onCreate function before the content view is even set but that did't work , Glide is loading the image fine in other places but the set function is just not being called. I would also like to know , how to have multiple items selected in the drawer Thanks in advance Also when I opened the project in android studio , It gave a content prolog error , I wanted to see the sample app code but I think the issue is that I don't see a xml root tag in the xml files of the app content is not allowed in prolog

mikepenz commented 3 years ago

@wakaztahir the imageloader should be set in the application to ensure it happened before the drawer is used. beyond that. your sample does not look like setting a url as icon. it will only call the loader when it is needed (e.g. when you specify the url drawable to the item)

wakaztahir commented 3 years ago

Thanks , as soon as I specified a url , it started working but the image is still displaying squared ! Do you have any idea how to make it circular and make it fit , Otherwise thanks for help

mikepenz commented 3 years ago

@wakaztahir usually image loaders provide APIs which allow you to transform the image to the needed form. e.g. ciruclar.

Beyond this. the ProfileDrawerItem uses a BezelImageView and applies the style as defined in the theme https://github.com/mikepenz/MaterialDrawer/blob/develop/materialdrawer/src/main/res/layout/material_drawer_item_profile.xml#L16

wakaztahir commented 3 years ago

Thanks I used Glide.with(context).load(account?.photoUrl).placeholder(placeholder).circleCrop().into(imageView) which did it !