-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainActivity.kt
More file actions
46 lines (37 loc) · 1.29 KB
/
MainActivity.kt
File metadata and controls
46 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package net.vrgsoft.rxurlparser
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.Toast
import io.reactivex.disposables.Disposable
import net.vrgsoft.library.LinkCrawler
import net.vrgsoft.rxurlparser.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
private lateinit var mBinding: ActivityMainBinding
private val crawler = LinkCrawler()
private var githubSubscription: Disposable? = null
private var youtubeSubscription: Disposable? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main)
crawler.onPreload {
Toast.makeText(this, "Preload url", Toast.LENGTH_SHORT)
.show()
}
githubSubscription =
crawler.parseUrl("https://github.com")
.subscribe { t ->
mBinding.contentGithub = t.result
}
youtubeSubscription =
crawler.parseUrl("https://youtu.be/X1RVYt2QKQE")
.subscribe { t ->
mBinding.contentYoutube = t.result
}
}
override fun onPause() {
githubSubscription?.dispose()
youtubeSubscription?.dispose()
super.onPause()
}
}