Commit bae5f7dd authored by Adrien Dorsaz's avatar Adrien Dorsaz

Fix bug with onPause() : we have to handle different "onPause" one if the back...

Fix bug with onPause() : we have to handle different "onPause" one if the back button is pressed and another if it's different onPause() call.
parent 85bbcada
......@@ -27,10 +27,13 @@ public class ArticleDetailActivity extends Activity implements OnClickListener {
private Button mStarButton = null;
private Button mBrowserButton = null;
private boolean isBackButtonPressed = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.articlelist_detail);
mArticle = this.getIntent().getParcelableExtra(
ArticleListActivity.ARTICLE_KEY);
......@@ -90,14 +93,25 @@ public class ArticleDetailActivity extends Activity implements OnClickListener {
}
}
@Override
public void onBackPressed() {
// Here you get Back Key Press So make boolean false
isBackButtonPressed = true;
super.onBackPressed();
}
@Override
public void onPause() {
super.onPause();
Intent intent = new Intent(ArticleDetailActivity.this,
ArticleListActivity.class);
intent.putExtra(ArticleListActivity.ARTICLE_KEY, mArticle);
startActivity(intent);
finish();
if (isBackButtonPressed) {
goBackToArticleList();
}
}
@Override
protected void onResume() {
super.onResume();
isBackButtonPressed = false;
}
public void updateReadButton() {
......@@ -127,4 +141,15 @@ public class ArticleDetailActivity extends Activity implements OnClickListener {
Toast.LENGTH_SHORT).show();
}
}
private void goBackToArticleList() {
Intent intent = new Intent(ArticleDetailActivity.this,
ArticleListActivity.class);
intent.putExtras(getIntent());
intent.putExtra(ArticleListActivity.ARTICLE_KEY, mArticle);
startActivity(intent);
finish();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment