From deead50800d2234d40908a3e661bfdabd4de69e8 Mon Sep 17 00:00:00 2001 From: kenkeiras Date: Tue, 23 Jan 2018 22:38:57 +0100 Subject: [PATCH] Update interfaces when stepping back to them. --- .../minicards/CardActivity.java | 37 ++++++++++++------- .../minicards/DeckPreviewActivity.java | 6 ++- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/codigoparallevar/minicards/CardActivity.java b/app/src/main/java/com/codigoparallevar/minicards/CardActivity.java index 0257d2d..5b9cee7 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/CardActivity.java +++ b/app/src/main/java/com/codigoparallevar/minicards/CardActivity.java @@ -47,20 +47,6 @@ public class CardActivity extends AppCompatActivity { // Use manually controlled canvas canvasView = (CanvasView) findViewById(R.id.canvasView); canvasView.setParentActivity(this); - String cardPath = this.getIntent().getStringExtra(CARD_PATH_KEY); - if (cardPath == null) { - finish(); - } - - try { - canvasView.loadCard(cardPath); - } catch (IOException e) { - e.printStackTrace(); - finish(); - } catch (ErrorLoadingCardException e) { - e.printStackTrace(); - finish(); - } // Initialize auxiliary elements partsHolder = new PartsHolder(this); @@ -131,10 +117,33 @@ public class CardActivity extends AppCompatActivity { CardActivity.this.setDevMode(false); } }); + } + @Override + protected void onResume() { + super.onResume(); + loadCard(); + } + + private void loadCard() { + String cardPath = this.getIntent().getStringExtra(CARD_PATH_KEY); + if (cardPath == null) { + finish(); + } + + try { + canvasView.loadCard(cardPath); + } catch (IOException e) { + e.printStackTrace(); + finish(); + } catch (ErrorLoadingCardException e) { + e.printStackTrace(); + finish(); + } setDevMode(devMode); } + private void setDevMode(boolean goToDevMode) { boolean willInvalidate = devMode != goToDevMode; diff --git a/app/src/main/java/com/codigoparallevar/minicards/DeckPreviewActivity.java b/app/src/main/java/com/codigoparallevar/minicards/DeckPreviewActivity.java index d688d3e..bf49372 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/DeckPreviewActivity.java +++ b/app/src/main/java/com/codigoparallevar/minicards/DeckPreviewActivity.java @@ -46,11 +46,15 @@ public class DeckPreviewActivity extends AppCompatActivity { }); listView = (ListView) findViewById(R.id.card_deck_list); + } + + @Override + protected void onResume() { + super.onResume(); cardArrayAdapter = new CardPreviewArrayAdapter(getApplicationContext(), listAvailableCards()); listView.setAdapter(cardArrayAdapter); - } private void createOpenCardDialog() {