Skip to content

Commit

Permalink
fixed an issue where the deck builder deck-list wasn't restored prope…
Browse files Browse the repository at this point in the history
…rly after screen rotation
  • Loading branch information
efarraro committed Nov 16, 2014
1 parent 79722d3 commit 4d35799
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
versionName "0.3.0"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ protected void onCreate(Bundle savedInstanceState) {
}

// add the rest of the deck builder
DeckBuilderFragment deckBuilderFragment = null;
if(savedInstanceState == null) {
DeckBuilderFragment deckBuilderFragment = new DeckBuilderFragment();
deckBuilderFragment = new DeckBuilderFragment();
Bundle bundle = new Bundle();

// pass in the ID of the deck we're working with
Expand All @@ -73,16 +74,21 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, deckBuilderFragment)
.commit();
}

// need to do this to restore the right-drawer deck list
if(deckBuilderFragment == null)
deckBuilderFragment = (DeckBuilderFragment)
getSupportFragmentManager().findFragmentById(R.id.container);

// set up for the right-bar deck list
mDeckDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDeckDrawer = (ListView) findViewById(R.id.deck_builder_deck_drawer);
// set up for the right-bar deck list
mDeckDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDeckDrawer = (ListView) findViewById(R.id.deck_builder_deck_drawer);

mListAdapter =
new DeckListArrayAdapter(this, deckBuilderFragment.getDeck().getCards());
mDeckDrawer.setAdapter(mListAdapter);

mListAdapter =
new DeckListArrayAdapter(this, deckBuilderFragment.getDeck().getCards());
mDeckDrawer.setAdapter(mListAdapter);
}

// set the title ("Deck Builder (0/30)")
setTitle(String.format(getString(R.string.activity_deck_builder), 0, 30));
Expand Down

0 comments on commit 4d35799

Please sign in to comment.