Last active
July 3, 2017 10:50
-
-
Save GauravChaddha1996/f9f27aa580d9947657d4dac42bb21e3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyActivity extends AppCompatActivity implements MyViewInterface { | |
private MyPresenter presenter; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_my); | |
presenter = new MyPresenter(DataManager.getDataManager()); | |
} | |
@Override | |
protected void onStart() { | |
super.onStart(); | |
// instantiates views and sets on click on them. | |
initView(); | |
} | |
@Override | |
protected void onPause() { | |
// Detach the view as UI isn't going to be visible | |
presenter.detachView(); | |
super.onPause(); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
// Attach the view interface as we want UI updated again. | |
presenter.attachView(this); | |
} | |
private void initView() { | |
// initialize views and set on click and other stuff here | |
/* the following line isn't syntactically correct but I | |
just want to give an idea */ | |
submitButton.setOnClickListener(presenter.saveName(name)); | |
} | |
@Override | |
public void updateUI(MyState state) { | |
/* Update the UI using the MyState object*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment