Added Android code
[wl-app.git] / Android / app / src / main / java / com / moiseum / wolnelektury / base / mvp / PresenterActivity.java
1 package com.moiseum.wolnelektury.base.mvp;
2
3 import android.os.Bundle;
4
5 import com.moiseum.wolnelektury.base.AbstractActivity;
6
7 /**
8  * Created by Piotr Ostrowski on 13.06.2018.
9  */
10 public abstract class PresenterActivity<P extends Presenter> extends AbstractActivity {
11
12     private P presenter;
13
14     protected abstract P createPresenter();
15
16     protected P getPresenter() {
17         return presenter;
18     }
19
20     @Override
21     public void onCreate(Bundle savedInstanceState) {
22         super.onCreate(savedInstanceState);
23         presenter = createPresenter();
24         presenter.onCreate(savedInstanceState);
25     }
26
27     @Override
28     public void onStart() {
29         super.onStart();
30         presenter.onStart();
31     }
32
33     @Override
34     public void onStop() {
35         super.onStop();
36         presenter.onStop();
37     }
38
39     @Override
40     public void onResume() {
41         super.onResume();
42         presenter.onResume();
43     }
44
45     @Override
46     public void onPause() {
47         super.onPause();
48         presenter.onPause();
49     }
50
51     @Override
52     public void onDestroy() {
53         super.onDestroy();
54         presenter.onDestroy();
55     }
56
57     @Override
58     public void onSaveInstanceState(Bundle outState) {
59         super.onSaveInstanceState(outState);
60         presenter.onSaveInstanceState(outState);
61     }
62 }