daniel-stoneuk / material-about-library

Makes it easy to create beautiful about screens for your apps
Apache License 2.0
1.12k stars 140 forks source link

Feature: custom layout file for single MaterialAboutActionItem #31

Closed Scrounger closed 7 years ago

Scrounger commented 7 years ago

@daniel-stoneuk: Can you please implement the option to set a custom layout file for a single MaterialAboutActionItem

something like that: .layout(R.layout.myCustomMaterialAboutActionItem)

        MaterialAboutCard.Builder licenseCardBuilder = new MaterialAboutCard.Builder();
        licenseCardBuilder.title(getString(R.string.licenses));

        licenseCardBuilder.addItem(new MaterialAboutActionItem.Builder()
                .text(getString(R.string.open_source_licenses))
                .icon(R.drawable.ic_about_licenses_24dp)
                .layout(R.layout.myCustomMaterialAboutActionItem)
                .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                    @Override
                    public void onClick() {
                        Intent i = new Intent(c, OpenSourceLicenseActivity.class);
                        startActivity(i);
                    }
                })
                .build());
daniel-stoneuk commented 7 years ago

Sure. I won't create a new release for it just yet, but you can use the individual commit for now.

daniel-stoneuk commented 7 years ago

Ah. This isn't possible with the RecyclerView unless you create a custom MaterialAboutActionItem. I am instead working on creating a more modular system. Hang tight.

daniel-stoneuk commented 7 years ago

Spent quite a while on this. Creating a custom MaterialAboutItem (Extending MaterialAboutItem) & a custom ViewTypeManager (extending ViewTypeManager). Is the quickest way of doing it right now. Might look into easier support in the future.

Can't guarantee stability in this build as I haven't properly tested if it even works. Cheers.

Use:

compile 'com.github.daniel-stoneuk:material-about-library:7f7bb3f922'
Scrounger commented 7 years ago

@daniel-stoneuk: I played a bit around but didn't get it to work. Can you post an example please?

daniel-stoneuk commented 7 years ago

Sorry about that, I'll spend some time now creating a demo for it. Thanks.

daniel-stoneuk commented 7 years ago

Took quite a long time but it's fun! I've added custom items to the demo. You can try and figure out how it works if you'd like as I don't have the time to document it.

Just quickly though, you need to:

  1. Extend ViewTypeManager
  2. Extend MaterialAboutItem ( see demo )
  3. Return your ViewTypeManager in the activity or fragment

Use: compile 'com.github.daniel-stoneuk:material-about-library:9280cbda33'

Scrounger commented 7 years ago

@daniel-stoneuk: Great, now i understand the concept, thanks a lot! Works like a charm, now its possible to customize also ohter Items like ActionTitlteItem