Search in sources :

Example 11 with MaterialAboutItemOnClickAction

use of com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction in project material-about-library by daniel-stoneuk.

the class ExampleMaterialAboutActivity method getMaterialAboutList.

@NonNull
@Override
protected MaterialAboutList getMaterialAboutList(@NonNull final Context c) {
    MaterialAboutCard.Builder advancedCardBuilder = new MaterialAboutCard.Builder();
    advancedCardBuilder.title("Advanced");
    advancedCardBuilder.addItem(new MaterialAboutTitleItem.Builder().text("TitleItem OnClickAction").icon(R.mipmap.ic_launcher).setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("http://www.danstone.uk"))).build());
    advancedCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Snackbar demo").icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_code_tags).sizeDp(18)).setOnClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            Snackbar.make(getRecyclerView(), "Test", Snackbar.LENGTH_SHORT).show();
        }
    }).build());
    advancedCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("OnLongClickAction demo").icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_hand_pointing_right).sizeDp(18)).setOnLongClickAction(new MaterialAboutItemOnClickAction() {

        @Override
        public void onClick() {
            Toast.makeText(c, "Long pressed", Toast.LENGTH_SHORT).show();
        }
    }).build());
    advancedCardBuilder.addItem(new MyCustomItem.Builder().text("Custom Item").icon(new IconicsDrawable(c).icon(CommunityMaterial.Icon.cmd_code_braces).sizeDp(18)).build());
    advancedCardBuilder.addItem(createDynamicItem("Tap for a random number & swap position", c));
    MaterialAboutCard.Builder customAdapterCardBuilder = new MaterialAboutCard.Builder();
    // Create list of libraries
    List<Library> libraries = new ArrayList<>();
    // Add libraries that are hosted on GitHub with an Apache v2 license.
    libraries.add(Licenses.fromGitHubApacheV2("yshrsmz/LicenseAdapter"));
    libraries.add(Licenses.fromGitHubApacheV2("daniel-stoneuk/material-about-library"));
    customAdapterCardBuilder.title("Custom Adapter (License Adapter)");
    customAdapterCardBuilder.customAdapter(new LicenseAdapter(libraries));
    return Demo.createMaterialAboutList(c, getIntent().getIntExtra(THEME_EXTRA, THEME_LIGHT)).addCard(advancedCardBuilder.build()).addCard(customAdapterCardBuilder.build());
}
Also used : MaterialAboutTitleItem(com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem) MaterialAboutItemOnClickAction(com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction) MaterialAboutCard(com.danielstone.materialaboutlibrary.model.MaterialAboutCard) LicenseAdapter(net.yslibrary.licenseadapter.LicenseAdapter) ConvenienceBuilder(com.danielstone.materialaboutlibrary.ConvenienceBuilder) MaterialAboutActionItem(com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem) ArrayList(java.util.ArrayList) Library(net.yslibrary.licenseadapter.Library) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) NonNull(androidx.annotation.NonNull)

Aggregations

MaterialAboutItemOnClickAction (com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction)11 Intent (android.content.Intent)7 ActivityNotFoundException (android.content.ActivityNotFoundException)5 MaterialAboutActionItem (com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem)5 ConvenienceBuilder (com.danielstone.materialaboutlibrary.ConvenienceBuilder)4 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)4 MaterialAboutCard (com.danielstone.materialaboutlibrary.model.MaterialAboutCard)3 MaterialAboutTitleItem (com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem)2 MaterialAboutList (com.danielstone.materialaboutlibrary.model.MaterialAboutList)2 DialogInterface (android.content.DialogInterface)1 Uri (android.net.Uri)1 WebView (android.webkit.WebView)1 NonNull (androidx.annotation.NonNull)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 IconDrawable (com.joanzapata.iconify.IconDrawable)1 ArrayList (java.util.ArrayList)1 Library (net.yslibrary.licenseadapter.Library)1 LicenseAdapter (net.yslibrary.licenseadapter.LicenseAdapter)1