Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
m7mdra authored Sep 2, 2018
1 parent c9b953f commit 4a4b0c6
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@




# HtmlRecycler
Converts a simple html page in to A `RecyclerView` with Native android widgets powered by [Jsoup library](https://jsoup.org/) and inspired by [Medium Textview](https://github.com/angebagui/medium-textview/)

Expand All @@ -27,18 +28,28 @@ Converts a simple html page in to A `RecyclerView` with Native android widgets p

## Implement in your project ?

HtmlRecycler.Builder(this)
.setSource(StringSource(Data.data))
.setAdapter(DefaultElementsAdapter(this) { element, i, view->
if (element is ImageElement)
supportFragmentManager.beginTransaction().apply {
replace(R.id.fragment_layout,ImageFragment.newInstance(element.ImageUrl))
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
commit()
addToBackStack("")
}
}).setRecyclerView(recyclerView)
```
val networkSource = NetworkSource("https://gist.githubusercontent.com/m7mdra/f22c62bc6941e08064b4fbceb4832a90/raw/ea8574d986635cf214541f1f5702ef37cc731aaf/article.html")
HtmlRecycler.Builder(this@MainActivity)
.setSource(networkSource)
.setAdapter(DefaultElementsAdapter(this@MainActivity)
{ element, i, view ->
}}).setRecyclerView(recyclerView)
.setLoadingCallback(object : HtmlRecycler.LoadCallback {
override fun onLoadingStart() {
progressBar.visibility = View.VISIBLE
}
override fun onLoaded(document: Document?) {
progressBar.visibility = View.GONE
}
})
.build()
```

the above code uses the existing implementation of `DefaultElementsAdapter` which `extends` `ElementsAdapter` class which inherently is a `RecylcerView Adpater`
the `DefaultElementsAdapter` uses a layout resources files defined by me but they not styled probably and are very buggy(especially the video, audio and iframe ones)

Expand Down Expand Up @@ -130,10 +141,10 @@ Add it in your root build.gradle at the end of repositories:
## TODO list:

- [ ] Define a standard Layout styling.
- [ ] allow `NetworkSource` to run on `UI thread` without crashing.
- [x] allow `NetworkSource` to run on `UI thread` without crashing.
- [ ] Support the following elements:
- [ ] `Table`
- [ ] `Div`
- [x] `Div`
- [x] `Section`
- [ ] Test Element Extractors for different data sets.
- [ ] other thing that i come up with...
Expand Down

0 comments on commit 4a4b0c6

Please sign in to comment.