From 277c55d03d189e4cc2046e6caca25bdec82f3144 Mon Sep 17 00:00:00 2001 From: Harun Ulum Fajar Date: Wed, 16 Sep 2020 23:12:23 +0700 Subject: [PATCH] Update Documentation (#29) * Update Documentation * Add note for permission and update XML attributes * update documentation * Delete compiler.xml * Delete jarRepositories.xml Co-authored-by: Gifary Dhimas --- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ad4f3d2..d2e7a4f 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,19 @@ dependencies { ## Usage +### Add some permission to android manifest: + +```xml + + + +``` + +Please note that the requirement of the permission is varied to your usage. + +- The `INTERNET` permission is required if you need to load the image from internet. +- The `EXTERNAL_STORAGE` permission is required if you need to load the image from device local storage. + ### Include following code in your layout: ```xml ``` +### Supported URI for Image Providers: + +Gridmenu support for multiple URI providers on each menu item's image. Some examples are displayed below, please check it out. + +- Drawable: Use this for load image from application resources. +- Network: Use this for load image by URL. +- Local: Use this for load image by file path. + +#### Drawable Image Usage: + +```java +final ArrayList list = new ArrayList<>(); +list.add(new MenuItem("satu", getResources().getDrawable(R.drawable.ic_launcher_background))); +``` + +```java +DrawableImageProvider drawableImageProvider = new DrawableImageProvider(getResources().getDrawable(R.drawable.ic_launcher_background)); + +final ArrayList list = new ArrayList<>(); +list.add(new MenuItem("dua", drawableImageProvider)); +``` + +#### Network Image Usage: + +```java +NetworkImageProvider networkImageProvider = new NetworkImageProvider(this, "https://bccfilkom.gridmenu.org/test.jpg"); + +final ArrayList list = new ArrayList<>(); +list.add(new MenuItem("tiga", networkImageProvider)); +``` + +#### Local Image Usage: + +```java +LocalImageProvider localImageProvider = new LocalImageProvider(this, "/storage/emulated/0/DCIM/Camera/gridmenu.jpg"); + +final ArrayList list = new ArrayList<>(); +list.add(new MenuItem("empat", localImageProvider)); +``` + ### Include following code in your activity: + ```java +final ArrayList list = new ArrayList<>(); +list.add(new MenuItem("satu", drawableImageProvider)); +list.add(new MenuItem("dua", networkImageProvider)); +list.add(new MenuItem("tiga", localImageProvider)); + GridMenu menu = findViewById(R.id.menu); menu.setMenuItems(list); +``` + +### Add menu item event: + +Menu's event for each menu item example + +```java +GridMenu menu = findViewById(R.id.square_menu); menu.setOnClickListener(new OnItemClickListener() { @Override public void onClick(int position) { @@ -69,11 +136,12 @@ menu.setOnClickListener(new OnItemClickListener() { }); ``` -## Supported xml Attributes +## Supported XML Attributes -| Attribute | Description | Value | Default Value | -| -----------|-------------------------------|---------|---------------| -| spanCount | Number of columns in GridMenu.| integer | 3 | +| Attribute | Description | Value | Default Value | +| -----------|-------------------------------|----------------------|---------------| +| spanCount | Number of columns in GridMenu.| integer | 3 | +| shapeItem | The shape of each item | `circle` or `square` | `circle` | ## Contributing to this project