Skip to content

Commit

Permalink
add java code example and description of classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bkhezry committed Nov 17, 2016
1 parent b77e3df commit 8bbedae
Showing 1 changed file with 100 additions and 8 deletions.
108 changes: 100 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
###A quick overview
- compatible with **API Level 17**
- **RTL** support
- **multi themes** support
- **full screen** mode
- **multi theme** support
- with **full screen** mode
- share URL **easy way**
- search in page support
- with **Bookmark** and **Vote** icon that handle with **EventBus** library
Expand All @@ -17,18 +17,110 @@ You can download the latest demo APK from here: https://github.com/bkhezry/Extra
##Screenshots
<img src="assets/screenshot_1.png" />
<img src="assets/screenshot_2.png" />
<img src="assets/screenshot_3.png" width="400px"/>
###full screen mode
<img src="assets/screenshot_3.png" width="350px"/>

#Setup
##1. Provide the gradle dependency

Add it in your root build.gradle at the end of repositories:
```gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```
Add the dependency:
```gradle
dependencies {
compile 'com.github.bkhezry:ExtraWebView:1.2.0'
}
```

##2. Add your code


add ItemActivity to AndroidManifest.xml
```xml
<activity
android:name="com.github.bkhezry.extrawebview.ItemActivity"
android:screenOrientation="portrait" />
```
```java
DataModel dataModel = new DataModelBuilder()
.withId(id)
.withType("blog")
.withBy(authorName)
.withTime(timestamp)
.withUrl(url)
.withDescription(description)
.withBookmark(true)
.withViewed(true)
.withRank(0)
.withVoted(true)
.withPageTitle(title)
.build();
new ExtraWebViewCreator()
.withContext(MainActivity.this)
.withBookmarkIcon(true)
.withVoteIcon(true)
.withCustomFont("fonts/IRANSansMobile.ttf")
.withThemeName(themeName)
.withDataModel(dataModel)
.show();
```
after that new activity start with WebView ui

## DataModel attributes

| Name | Type | Default | Description |
|:----:|:----:|:-------:|:-----------:|
|id|Long|@NonNull| unique id of post. use in bookmark and vote icon event handler |
|type|String|blog| type of post. use in future development |
|by|String|@NonNull| author name of post|
|time|Long|@NonNull| create time of post as timestamp format |
|url|String|@NonNull | url of post |
|description|String|@NonNull | description of post |
|bookmark|boolean|false| bookmark status of post |
|viewed|boolean|false| viewed status of post. use in future development |
|rank|integer |0 | rank of post by users. use in future development |
|voted|boolean|false | vote status of post |
|pageTitle|String|@NonNull | title of post |

## ExtraWebViewCreator attributes
| Name | Type | Default | Description |
|:----:|:----:|:-------:|:-----------:|
|context|Context|@NonNull| context of current activity |
|bookmarkIcon|boolean|false| show icon of bookmark when true |
|customFont|String|@Nullable| use calligraphy library to set custom font. path of font in assets folder|
|themeName|String|light| name of theme use in WebView ui |
|dataModel|DataModel|@NonNull | object of DataModel class |

List of theme name: `light`, `dark`, `sepia`, `green`, `solarized` and `solarized_dark`
[ThemePreference.java](https://github.com/bkhezry/ExtraWebView/blob/master/library/src/main/java/com/github/bkhezry/extrawebview/data/ThemePreference.java)
#Additional Setup


you can handle bookmark and vote icon click event.
add this code to onCreate method of activity:
```java
EventBus.getDefault().register(this);
```
after that subscribe method as listener:
```java
@Subscribe(threadMode = ThreadMode.MAIN)
public void doThis(IntentServiceResult intentServiceResult) {
if (intentServiceResult.isChecked()) {

} else {

}
}
```
when each icon has been clicked, EventBus return object of IntentServiceResult.
## IntentServiceResult attributes
| Name | Type | value |
|:----:|:----:|:-------:|
|id|Long|current post id |
|typeEvent|String| BOOKMARK or VOTE|
|isChecked|boolean|status of icon. if true icon is checked |
#Credits

- Ha Duy Trung - [GitHub](https://github.com/hidroh)
Expand Down

0 comments on commit 8bbedae

Please sign in to comment.