Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class MainActivity extends AppCompatActivity implements MainActivityView {
@BindView(R.id.lv_am_movie_list) ListView listView;
@BindView(R.id.pb_am_loading) ProgressBar progressBar;
public static MainPresenter mainPresenter;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
listView.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
if (mainPresenter == null) {
mainPresenter = new MainPresenter();
}
mainPresenter.attachView(this);
}
@Override protected void onDestroy() {
super.onDestroy();
mainPresenter.detachView();
if (isFinishing()) mainPresenter = null;
}
@Override public Context getAppContext() {
return getApplicationContext();
}
@Override public Context getActivityContext() {
return this;
}
@Override public ListView getListView() {
return listView;
}
@Override public ProgressBar getProgressBar() {
return progressBar;
}
}
@Jacksgong

This comment has been minimized.

Copy link

@Jacksgong Jacksgong commented May 27, 2017

Thanks for your demonstrate.

Why do you add if(isFinishing()) on onDestroy() method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.