-
Notifications
You must be signed in to change notification settings - Fork 0
/
Presenter.kt
39 lines (27 loc) · 1.2 KB
/
Presenter.kt
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
package com.ninhydrin.doodly
import org.tensorflow.contrib.android.TensorFlowInferenceInterface
class Presenter(inferenceInterface: TensorFlowInferenceInterface) : MVP.ViewToPresenter, MVP.ModelToPresenter {
private val presenterToModel: MVP.PresenterToModel
private var presenterToView: MVP.PresenterToView? = null
private val model: Model = Model(this,inferenceInterface)
init {
presenterToModel = model.getPresenterToModel()
}
// ------------------------------view->Presenter-----------------------------------------//
override fun donePressed(pixels: IntArray) {
presenterToModel.done(pixels)
}
// --------------------------model->Presenter----------------------------------------------//
override fun passPrediction(prediction: String) {
presenterToView?.showResult(prediction)
}
// ------------------------lifecycle methods ---------------------------------------------//
fun attach(p: MVP.PresenterToView) {
presenterToView = p
}
fun detach() {
presenterToView = null
}
// -------------return instance --------------------//
fun getViewToPresenter() = this
}