-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMainModel.java
63 lines (53 loc) · 1.63 KB
/
MainModel.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.tinmegali.mvp_tutorial;
import android.util.Log;
import com.tinmegali.mvp_tutorial.modelos.Note;
/**
* ---------------------------------------------------
* Created by Tin Megali on 26/02/16.
* Project: MVP_Tutorial
* ---------------------------------------------------
* <a href="http://www.tinmegali.com">tinmegali.com</a>
* <a href="http://www.github.com/tinmegali>github</a>
*/
public class MainModel
implements MainMVP.ModelOps {
private String TAG = getClass().getSimpleName();
// Presenter reference
// Referência para layer Presenter
private MainMVP.RequiredPresenterOps mPresenter;
public MainModel(MainMVP.RequiredPresenterOps mPresenter) {
this.mPresenter = mPresenter;
}
/**
* Sent from {@link MainPresenter#onDestroy(boolean)}
* Should stop/kill operations that could be running
* and aren't needed anymore
*
* Disparada por {@link MainPresenter#onDestroy(boolean)}
* para as operações necessárias que eventualmente
* estiverem executando no BG
*/
@Override
public void onDestroy() {
Log.d(TAG, "startMVPOps()");
// destroying actions
}
// Insert Note in DB
// insere Nota no DB
@Override
public void insertNote(Note note) {
Log.d(TAG, "startMVPOps()");
// data business logic
// ...
mPresenter.onNoteInserted(note);
}
// Removes Note from DB
// remove Nota do DB
@Override
public void removeNote(Note note) {
Log.d(TAG, "startMVPOps()");
// data business logic
// ...
mPresenter.onNoteRemoved(note);
}
}