Skip to content

Commit

Permalink
Collapse news after someone views it
Browse files Browse the repository at this point in the history
  • Loading branch information
gotosleep committed May 18, 2014
1 parent 919c3e3 commit 550f573
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/io/itch/activities/MyGamesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class MyGamesActivity extends BaseActivity {
private View header;
private ProgressBar progress;
private Post latestNews;
private Post seenInThisSession;
private boolean preventCollapse;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -58,6 +58,7 @@ public void onItemClick(AdapterView<?> list, View item, int position, long id) {
if (headerCount > 0 && position < headerCount) {
Intent i = new Intent(MyGamesActivity.this, NewsActivity.class);
startActivity(i);
setPreventCollapse(false);
} else {
position -= headerCount;
Game game = gamesAdapter.getItem(position);
Expand All @@ -83,7 +84,7 @@ protected void onStop() {
super.onStop();
Post post = this.getLatestNews();
if (post != null && !PostViewHelper.hasBeenSeen(this, post)) {
this.setSeenInThisSession(post);
this.setPreventCollapse(true);
PostViewHelper.setHasBeenSeen(this, post);
}
}
Expand Down Expand Up @@ -186,7 +187,7 @@ private void loadNewsHeader(Post post) {
View collapsed = header.findViewById(R.id.viewGroupNewsHeaderContentCollapsed);
if (post != null) {
View view;
if (PostViewHelper.hasBeenSeen(this, post) && this.getSeenInThisSession() == null) {
if (PostViewHelper.hasBeenSeen(this, post) && !this.preventCollapse()) {
content.setVisibility(View.GONE);
view = collapsed;
} else {
Expand Down Expand Up @@ -220,12 +221,12 @@ public void setLatestNews(Post latestNews) {
this.latestNews = latestNews;
}

public Post getSeenInThisSession() {
return seenInThisSession;
public boolean preventCollapse() {
return preventCollapse;
}

public void setSeenInThisSession(Post seen) {
this.seenInThisSession = seen;
public void setPreventCollapse(boolean flag) {
this.preventCollapse = flag;
}

@Override
Expand Down

0 comments on commit 550f573

Please sign in to comment.