Skip to content

Android

Download

Use Gradle:

repositories {
  maven { url 'https://jitpack.io' }
}

dependencies {
  implementation 'com.github.wistory:sdk.android:tag'
}

, tag is a current version of library

Integration guide

First put the wistory view in your layout xml :

<ru.vvdev.wistory.WistoryView
        android:id="@+id/storiesView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

Add your company token into manifest :

<meta-data
    android:name="WISTORY_TOKEN"
    android:value="YOUR_TOKEN" />

Optional: Add server url into manifest for standalone Wistory version. Skip this step for default installation.

<meta-data
    android:name="WISTORY_SERVER_URL"
    android:value="YOUR_SERVER_URL" />

And initialize library in application class :

class App : Application() {

    override fun onCreate() {
        super.onCreate()
        Wistory.initialize(this)
    }
}

Customise

You can customize wistory view

by xml:

  • format can be fixed or fullscreen

  • statusBarAlignment can be at top or at bottom

or by code using Kotlin DSL:

storiesView {
    config {
        format = UiConfig.Format.FIXED
        statusBarPosition = UiConfig.VerticalAlignment.BOTTOM
    }
}

Event listener

Wistory provides handlers for most of common cases. The listener can also be added using Kotlin DSL:

storiesView {
    eventListener = this@MainActivity
}

Events

  • fun onItemsLoaded()

Called if the stories are successfully downloaded from the server

  • fun onRead(storyId: String)

It's called when story was readen. Passes the story object

  • fun onPrevSnap(storyId: String)

Called when switching to the previous "snap". Passes the story object

  • fun onNextSnap(storyId: String)

Called when switching to the next "snap". Passes the story object

  • fun onNavigate(action: String, value: String)

Called up by pressing the action button. Passes the action type and value

  • fun onFavorite(id: String, isFavorite: Boolean)

Called up by clicking the add to favorites button. Passes id of story and value

  • fun onRelation(id: String, relation: String)

Called up by pressing the like or dislike button. Passes id of story and value

  • fun onPoll(storyId: String, sheet: Int, newpoll: String? = null, oldpoll: String? = null)

Called up after the answer choice is made in the voting. Passes the story, "snap" position and the answer choice id

  • fun onError(e: Exception)

Called on any error. Mostly by network layer

Licence

Shield: CC BY 4.0

This work is licensed under a Creative Commons Attribution 4.0 International License.

CC BY 4.0