Skip to content

Commit 280cb11

Browse files
authored
Merge pull request #28 from rees46/feat/stories-by-id-kotlin
docs(stories): stories by id initialization
2 parents eeea2e6 + 1bd4570 commit 280cb11

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

source/includes/_stories.md.erb

+35-2
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,48 @@ let product: StoriesPromoCodeElement?
206206
```
207207

208208
```kotlin
209+
210+
// Initialization by adding code into layout
211+
<com.personalizatio.stories.views.StoriesView
212+
android:layout_width="match_parent"
213+
android:layout_height="wrap_content"
214+
app:code="STORY BLOCK CODE" />
215+
216+
val storiesView = findViewById<StoriesView>(R.id.stories_view)
217+
sdk.initializeStoriesView(storiesView)
218+
219+
// Programmatic initialization
220+
val storiesView = StoriesView(this, "STORY BLOCK CODE")
221+
findViewById<ViewGroup>(R.id.stories).addView(storiesView)
222+
sdk.initializeStoriesView(storiesView)
223+
224+
//Font setup
209225
val stories = findViewById<StoriesView>(R.id.story_view)
210226
stories.settings.apply {
211227
label_font_size = 16
212228
label_font_family = Typeface.SERIF
213229
button_font_family = Typeface.MONOSPACE
214230
products_button_font_family = Typeface.DEFAULT_BOLD
215231
}
216-
```
217-
```
232+
233+
// Set item click listener:
234+
val storiesView = findViewById<StoriesView>(R.id.stories_view)
235+
storiesView.itemClickListener = object : OnLinkClickListener {
236+
override fun onClick(url: String): Boolean {
237+
// return true if need to opening using the SDK
238+
return false
239+
}
240+
241+
override fun onClick(product: Product): Boolean {
242+
// return true if need to opening using the SDK
243+
return false
244+
}
245+
}
246+
247+
// Show story by id:
248+
249+
sdk.showStory(STORY_ID)
250+
218251

219252
// TextBlock
220253

0 commit comments

Comments
 (0)