From cabb18d1d82c5f711a8fe38940928ea0351bedbf Mon Sep 17 00:00:00 2001 From: jinpark78 Date: Sat, 21 Jun 2014 21:16:14 -0500 Subject: [PATCH 1/4] abc xyz --- ex/DownloadApplication/.classpath | 2 +- ex/ThreadedDownload/.classpath | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ex/DownloadApplication/.classpath b/ex/DownloadApplication/.classpath index c06dfcb8e..51769745b 100644 --- a/ex/DownloadApplication/.classpath +++ b/ex/DownloadApplication/.classpath @@ -1,7 +1,7 @@ - + diff --git a/ex/ThreadedDownload/.classpath b/ex/ThreadedDownload/.classpath index 0b0840834..d57ec0251 100644 --- a/ex/ThreadedDownload/.classpath +++ b/ex/ThreadedDownload/.classpath @@ -1,7 +1,7 @@ - + From 1c51f740a562185de4c0c2f5d6545c9d279d02b3 Mon Sep 17 00:00:00 2001 From: jinpark78 Date: Sat, 21 Jun 2014 21:19:13 -0500 Subject: [PATCH 2/4] Revert "abc" This reverts commit cabb18d1d82c5f711a8fe38940928ea0351bedbf. --- ex/DownloadApplication/.classpath | 2 +- ex/ThreadedDownload/.classpath | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ex/DownloadApplication/.classpath b/ex/DownloadApplication/.classpath index 51769745b..c06dfcb8e 100644 --- a/ex/DownloadApplication/.classpath +++ b/ex/DownloadApplication/.classpath @@ -1,7 +1,7 @@ - + diff --git a/ex/ThreadedDownload/.classpath b/ex/ThreadedDownload/.classpath index d57ec0251..0b0840834 100644 --- a/ex/ThreadedDownload/.classpath +++ b/ex/ThreadedDownload/.classpath @@ -1,7 +1,7 @@ - + From 75024b94327a24b5454fe7e21e4ddcba3ec55adb Mon Sep 17 00:00:00 2001 From: jinpark78 Date: Sat, 21 Jun 2014 21:31:43 -0500 Subject: [PATCH 3/4] revert abc --- ex/DownloadApplication/.classpath | 2 +- ex/ThreadedDownload/.classpath | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ex/DownloadApplication/.classpath b/ex/DownloadApplication/.classpath index c06dfcb8e..51769745b 100644 --- a/ex/DownloadApplication/.classpath +++ b/ex/DownloadApplication/.classpath @@ -1,7 +1,7 @@ - + diff --git a/ex/ThreadedDownload/.classpath b/ex/ThreadedDownload/.classpath index 0b0840834..d57ec0251 100644 --- a/ex/ThreadedDownload/.classpath +++ b/ex/ThreadedDownload/.classpath @@ -1,7 +1,7 @@ - + From a1a2a15cfff223e61ac7b404434cd3f71ea6994a Mon Sep 17 00:00:00 2001 From: jinpark78 Date: Sat, 21 Jun 2014 21:32:17 -0500 Subject: [PATCH 4/4] Week 5 Assignment 4 Solution #1 --- .../vuum/mocca/AndroidPlatformStrategy.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/assignments/week-5-assignment-4/W5-A4-Android/src/edu/vuum/mocca/AndroidPlatformStrategy.java b/assignments/week-5-assignment-4/W5-A4-Android/src/edu/vuum/mocca/AndroidPlatformStrategy.java index bc684b5ce..a229790c5 100644 --- a/assignments/week-5-assignment-4/W5-A4-Android/src/edu/vuum/mocca/AndroidPlatformStrategy.java +++ b/assignments/week-5-assignment-4/W5-A4-Android/src/edu/vuum/mocca/AndroidPlatformStrategy.java @@ -47,6 +47,8 @@ public void begin() { /** (Re)initialize the CountDownLatch. */ // TODO - You fill in here. + /// simple. same as for console platform strategy. + mLatch = new CountDownLatch(NUMBER_OF_THREADS); } /** Print the outputString to the display. */ @@ -57,20 +59,40 @@ public void print(final String outputString) * and appends the outputString to a TextView. */ // TODO - You fill in here. + /// this one is different. can't have background android threads printing to console. + /// create runnable. use activity weak reference to post runnable to runonui thread. + Runnable myRunnable = new Runnable() { + @Override + public void run() { + mTextViewOutput.append(outputString); + } + }; + mActivity.get().runOnUiThread(myRunnable); } /** Indicate that a game thread has finished running. */ public void done() { // TODO - You fill in here. + /// simple. same as for console platform strategy. + /// can do 2 ways... 1) call runonui thread and pass a runnable that decrements the count. + /// or 2) call countdownlatch directly. + + mLatch.countDown(); } /** Barrier that waits for all the game threads to finish. */ public void awaitDone() { // TODO - You fill in here. + /// simple. same as for console platform strategy. + try { + mLatch.await(); + } + catch(java.lang.InterruptedException e) { + } } - + /** * Error log formats the message and displays it for the * debugging purposes.