Skip to content

Commit

Permalink
Update Documentation (#29)
Browse files Browse the repository at this point in the history
* Update Documentation

* Add note for permission and update XML attributes

* update documentation

* Delete compiler.xml

* Delete jarRepositories.xml

Co-authored-by: Gifary Dhimas <gifff@users.noreply.github.com>
  • Loading branch information
Harun Ulum Fajar and gifff authored Sep 16, 2020
1 parent c151cbb commit 277c55d
Showing 1 changed file with 72 additions and 4 deletions.
76 changes: 72 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ dependencies {

## Usage

### Add some permission to android manifest:

```xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

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
<com.bcc.gridmenuview.GridMenu
Expand All @@ -57,10 +70,64 @@ dependencies {
app:spanCount="4"/>
```

### 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<MenuItem> 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<MenuItem> 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<MenuItem> 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<MenuItem> list = new ArrayList<>();
list.add(new MenuItem("empat", localImageProvider));
```

### Include following code in your activity:

```java
final ArrayList<MenuItem> 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) {
Expand All @@ -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

Expand Down

0 comments on commit 277c55d

Please sign in to comment.