No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle/wrapper
sdk-example-java
sdk-example-kt
studyplus-android-sdk2
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Studyplus-Android-SDK-V2

Maven Central

Requirements

Import in your Project

Gradle file (app)

repositories {
    mavenCentral()
}
dependencies {
    implementation 'jp.studyplus.android.sdk:studyplus-android-sdk2:2.1.2'
}

Maven

<dependency>
  <groupId>jp.studyplus.android.sdk</groupId>
  <artifactId>studyplus-android-sdk2</artifactId>
  <version>2.1.2</version>
</dependency>

or download the latest JAR via Central Repository

Usage

Setup

Studyplus.instance.setup("consumer_key", "consumer_secret")

Authenticate

Open an Activity to connect with Studyplus.

try {
    Studyplus.instance.startAuth(this@MainActivity, REQUEST_CODE_AUTH)
} catch (e: ActivityNotFoundException) {
    e.printStackTrace()
    Toast.makeText(context, "Need for Studyplus 2.14.0+", Toast.LENGTH_LONG).show()
}

Then save its result.

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    when (requestCode) {
        REQUEST_CODE_AUTH -> {
            if (resultCode == Activity.RESULT_OK) {
                Studyplus.instance.setAuthResult(this, data)
                Toast.makeText(this@MainActivity, "Success!!", Toast.LENGTH_LONG).show()
            }
        }
    }
}

Post a record to Studyplus

Create a record and post.

val record = StudyRecordBuilder()
        .setComment("勉強した!!!")
        .setAmountTotal(30)
        .setDurationSeconds(2 * 60)
        .build()
Studyplus.instance.postRecord(this@MainActivity, record,
        object : Studyplus.Companion.OnPostRecordListener {
            override fun onResult(success: Boolean, recordId: Long?, throwable: Throwable?) {
                if (success) {
                    Toast.makeText(context, "Post Study Record!! ($recordId)", Toast.LENGTH_LONG).show()
                } else {
                    throwable?.apply {
                        Toast.makeText(context, "error!!", Toast.LENGTH_LONG).show()
                        printStackTrace()
                    }
                }
            }
        })

More

License