An android library for generating 24STREAM HTML widgets to be used in WebView or any other nested browser.
Installation
To install the library you need to add JitPack repository first (if you haven't already).
For older projects in the root build.gradle
file add maven { url 'https://jitpack.io' }
inside allprojects->repositories
like following:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
For newer projects you need to add it to settings.gradle
. It should be in dependencyResolutionManagement->repositories
like following:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Then we need to add the dependency itself(in app module build.gradle):
dependencies {
...
implementation 'stream.24ttl.git.pub:24stream_android:0.5.3'
}
Usage
RichPage
A webview widget with rich html contents and automatic height.
Parameter |
Parameter type |
Description |
brand |
string |
Required. Brand name for the page |
productId |
string |
Required. Prouct ID for the page |
retailerDomain |
string |
Required. Domain of the retailer of the page |
templateType |
string |
Required. Template type of the page |
language |
string |
Language code for the page encoded as country_language. Country code should set according to ISO 3166-1 standard and the language code - to ISO 639-1. Defaults to ru |
onError |
(String) -> Unit |
A function to call when an error is occured |
contentType |
Stream24ContentType |
Content type of the page. One of .shopInShops or .minisite . Defaults to .minisite |
GetHTML
Returns HTML code of the page.
Parameter |
Parameter type |
Description |
brand |
string |
Required. Brand name for the page |
productId |
string |
Required. Prouct ID for the page |
retailerDomain |
string |
Required. Domain of the retailer of the page |
templateType |
string |
Required. Template type of the page |
language |
string |
Language code for the page encoded as country_language. Country code should set according to ISO 3166-1 standard and the language code - to ISO 639-1. Defaults to ru |
contentType |
Stream24ContentType |
Content type of the page. One of .shopInShops or .minisite . Defaults to .minisite |
Example
Using RichContent
import stream.ttl24.stream24.Stream24
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val rich = Stream24.RichContent(LocalContext.current, LocalDensity.current, "irshad.az", "Samsung", "16651081549", "master_template", ::onError, "ru_ru", Stream24.Stream24ContentType.shopInShops)
setContentView(rich)
}
}
fun onError(errorMessage:String) {
print(errorMessage)
}
Using GetHtml
import stream.ttl24.stream24.Stream24
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val webview = WebView(this)
val html = Stream24.GetHTML("Samsung", "16651081549", "irshad.az", "master_template", Stream24.Stream24ResultType.html, Stream24.Stream24ContentType.shopInShops)
webview.getSettings().javaScriptEnabled = true
webview.loadData(html,
"text/html", "UTF-8")
setContentView(webview)
}
}