PageViewModel: docs
This commit is contained in:
parent
f02220f430
commit
020f48149b
|
@ -16,15 +16,20 @@ import java.nio.charset.Charset
|
||||||
@ExperimentalCoroutinesApi
|
@ExperimentalCoroutinesApi
|
||||||
class PageViewModel(@Suppress("unused") private val savedStateHandle: SavedStateHandle) :
|
class PageViewModel(@Suppress("unused") private val savedStateHandle: SavedStateHandle) :
|
||||||
ViewModel() {
|
ViewModel() {
|
||||||
|
/** Currently viewed page URL. */
|
||||||
var currentUrl: String = ""
|
var currentUrl: String = ""
|
||||||
private var requestJob: Job? = null
|
/** Observable page viewer state. */
|
||||||
val state: MutableLiveData<State> by lazy { MutableLiveData<State>(State.IDLE) }
|
val state: MutableLiveData<State> by lazy { MutableLiveData<State>(State.IDLE) }
|
||||||
private var linesList = ArrayList<Line>()
|
/** Observable page viewer lines (backed up by `linesList` but updated less often). */
|
||||||
val lines: MutableLiveData<List<Line>> by lazy { MutableLiveData<List<Line>>() }
|
val lines: MutableLiveData<List<Line>> by lazy { MutableLiveData<List<Line>>() }
|
||||||
|
/** Observable page viewer latest event. */
|
||||||
val event: MutableLiveData<Event> by lazy { MutableLiveData<Event>() }
|
val event: MutableLiveData<Event> by lazy { MutableLiveData<Event>() }
|
||||||
|
|
||||||
/** A non-saved list of visited URLs. Not an history, just used for going back. */
|
/** A non-saved list of visited URLs. Not an history, just used for going back. */
|
||||||
val visitedUrls = mutableListOf<String>()
|
val visitedUrls = mutableListOf<String>()
|
||||||
|
/** Latest request job created, stored to cancel it if needed. */
|
||||||
|
private var requestJob: Job? = null
|
||||||
|
/** Lines for the current page. */
|
||||||
|
private var linesList = ArrayList<Line>()
|
||||||
|
|
||||||
enum class State {
|
enum class State {
|
||||||
IDLE, CONNECTING, RECEIVING
|
IDLE, CONNECTING, RECEIVING
|
||||||
|
|
Reference in a new issue