Skip to content

Commit

Permalink
News header bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gotosleep committed May 12, 2014
1 parent a0e1808 commit 5d0d8fe
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/io/itch/activities/MyGamesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_my_games);
this.gamesList = (ListView) findViewById(id.listViewGames);
this.gamesAdapter = new GameAdapter(this, R.layout.list_item_game);
loadNewsHeader(null);
this.gamesList.setAdapter(this.gamesAdapter);
this.gamesList.setEmptyView(getEmptyView());
this.gamesList.setOnItemClickListener(new OnItemClickListener() {
Expand All @@ -68,8 +69,8 @@ public void onItemClick(AdapterView<?> list, View item, int position, long id) {
@Override
protected void onStart() {
super.onStart();
this.updateGames();
this.updateNews();
this.updateGames();
}

@Override
Expand Down Expand Up @@ -160,22 +161,23 @@ public void success(PostsResponse result, Response arg1) {
}

private void loadNewsHeader(Post post) {
View header = LayoutInflater.from(this).inflate(R.layout.news_header, null);
PostViewHelper.populateView(this, header, post);
ListView list = (ListView) findViewById(R.id.listViewGames);
setHeader(header, list);
View header = getHeader();
if (post != null) {
header.setVisibility(View.VISIBLE);
PostViewHelper.populateView(this, header, post);
header.invalidate();
} else {
header.setVisibility(View.GONE);
}
}

private void setHeader(View header, ListView list) {
if (header != this.header) {
if (this.header != null) {
list.removeHeaderView(this.header);
}
this.header = header;
if (this.header != null) {
list.addHeaderView(this.header);
}
private View getHeader() {
if (this.header == null) {
this.header = LayoutInflater.from(this).inflate(R.layout.news_header, null);
ListView list = (ListView) findViewById(R.id.listViewGames);
list.addHeaderView(this.header);
}
return this.header;
}

@Override
Expand Down

0 comments on commit 5d0d8fe

Please sign in to comment.