Thumb view sample
Add the SDK
First add the SDK and required dependencies in your app/build.gradle file.
You can check the latest SDK version on Maven Central.
dependencies {
[...]
implementation 'com.joinstoriessdk:androidsdk:X:X:X'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.0" //latest version
[...]
}
Init
Then you should init the SDK. There isn't any side effect so you can implement it wherever you want. Just be sure to call the init method before any start method.
JoinStories.init(your_team_id)
Layout
Now you need to add our StoryScaffoldView and StoryPlayer views withing the layout of the Activity/Fragment that will be responsible to trigger their display.
<com.joinstoriessdk.androidsdk.ui.StoryScaffoldView
android:id="@+id/story_scaffold"
android:layout_width="0dp"
android:layout_height="144dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.joinstoriessdk.androidsdk.ui.player.StoryPlayer
android:id="@+id/story_player"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Trigger
At this point you are now ready to display and start our widget, by calling the startThumbView method.
It could be in the onResume method of your Activity for example:
override fun onResume() {
super.onResume()
val config = JoinStoriesThumbConfig(joinAlias = "your_alias")
JoinStories.startThumbView(
"config",
lifecycleScope,
container_view,
story_player,
story_scaffold,
this
)
}
For a complete list of the available configuration parameter, see the Thumb View document of the usage section.