Skip to content

Commit

Permalink
init new truetime on app launch
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikgopal committed Nov 26, 2020
1 parent de1045d commit d46b3e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 12 additions & 8 deletions app/src/main/java/com/instacart/library/sample/App.kt
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
package com.instacart.library.sample

import android.annotation.SuppressLint
import android.app.Application
import android.os.AsyncTask
import android.util.Log

import com.instacart.library.truetime.TrueTime
import com.instacart.library.truetime.TrueTime2
import com.instacart.library.truetime.TrueTimeImpl
import com.instacart.library.truetime.TrueTimeParameters
import com.instacart.library.truetime.TrueTimeRx

import java.io.IOException
import java.util.Date

import com.instacart.library.truetime.sntp.SntpClient
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.observers.DisposableSingleObserver
import io.reactivex.schedulers.Schedulers
import java.io.IOException

@Suppress("unused")
class App : Application() {

companion object {
private val TAG = App::class.java.simpleName
val trueTime2: TrueTime2 = TrueTimeImpl(SntpClient())
}

override fun onCreate() {
super.onCreate()

trueTime2.initialize(with = TrueTimeParameters())
initRxTrueTime()
//initTrueTime()
// initTrueTime()
}

/**
Expand Down Expand Up @@ -58,8 +61,9 @@ class App : Application() {
/**
* Initialize the TrueTime using RxJava.
*/
@SuppressLint("CheckResult")
private fun initRxTrueTime() {
val disposable = TrueTimeRx.build()
TrueTimeRx.build()
.withConnectionTimeout(31428)
.withRetryCount(100)
.withSharedPreferencesCache(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import java.util.TimeZone

class SampleActivity : AppCompatActivity() {

val tt2: TrueTime2 = TrueTimeImpl(SntpClient())

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down

0 comments on commit d46b3e2

Please sign in to comment.