diff options
author | Camil Staps | 2015-04-29 12:56:33 +0200 |
---|---|---|
committer | Camil Staps | 2015-04-29 12:56:33 +0200 |
commit | 28eb6a408045971d79b379ac5ef408cf6b84ecbd (patch) | |
tree | 366de8d3fa2bff7ecdd0d947aba3178750854523 /app/src/main | |
parent | code license (diff) |
Cleanup; victory sound
Diffstat (limited to 'app/src/main')
-rwxr-xr-x | app/src/main/java/com/camilstaps/rushhour/BoardLoader.java | 1 | ||||
-rw-r--r-- | app/src/main/java/com/camilstaps/rushhour/FinishedActivity.java | 19 | ||||
-rwxr-xr-x | app/src/main/java/com/camilstaps/rushhour/GamePlayActivity.java | 26 | ||||
-rw-r--r-- | app/src/main/java/com/camilstaps/rushhour/MainActivity.java | 2 | ||||
-rw-r--r-- | app/src/main/java/com/camilstaps/rushhour/TheSoundPool.java | 34 | ||||
-rw-r--r-- | app/src/main/res/values-v11/styles.xml | 15 | ||||
-rw-r--r-- | app/src/main/res/values/attrs.xml | 12 | ||||
-rw-r--r-- | app/src/main/res/values/colors.xml | 5 | ||||
-rw-r--r-- | app/src/main/res/values/styles.xml | 19 |
9 files changed, 40 insertions, 93 deletions
diff --git a/app/src/main/java/com/camilstaps/rushhour/BoardLoader.java b/app/src/main/java/com/camilstaps/rushhour/BoardLoader.java index cb5ded7..0f9cd6f 100755 --- a/app/src/main/java/com/camilstaps/rushhour/BoardLoader.java +++ b/app/src/main/java/com/camilstaps/rushhour/BoardLoader.java @@ -30,6 +30,7 @@ import java.util.Scanner; * Created by Jos on 23-4-2015.
*/
public class BoardLoader {
+
public BoardLoader()
{}
diff --git a/app/src/main/java/com/camilstaps/rushhour/FinishedActivity.java b/app/src/main/java/com/camilstaps/rushhour/FinishedActivity.java index 053006d..e0f3c37 100644 --- a/app/src/main/java/com/camilstaps/rushhour/FinishedActivity.java +++ b/app/src/main/java/com/camilstaps/rushhour/FinishedActivity.java @@ -1,21 +1,3 @@ -/* - * Rush Hour Android app - * Copyright (C) 2015 Randy Wanga, Jos Craaijo, Camil Staps - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ package com.camilstaps.rushhour; import android.app.Activity; @@ -56,6 +38,7 @@ public class FinishedActivity extends ActionBarActivity { final int score = getIntent().getIntExtra("score", -1); if (score != -1) { + TheSoundPool.getSoundPool(getBaseContext()).play(TheSoundPool.soundVictoryId, 1, 1, 1, 0, 1); final EditText input = new EditText(this); new AlertDialog.Builder(this) .setTitle("Congratulations!") diff --git a/app/src/main/java/com/camilstaps/rushhour/GamePlayActivity.java b/app/src/main/java/com/camilstaps/rushhour/GamePlayActivity.java index c5740b3..8399446 100755 --- a/app/src/main/java/com/camilstaps/rushhour/GamePlayActivity.java +++ b/app/src/main/java/com/camilstaps/rushhour/GamePlayActivity.java @@ -31,9 +31,6 @@ import java.io.InputStream; public class GamePlayActivity extends Activity implements Board.SolveListener { - private SoundPool soundPool; - private int soundBackgroundId, soundCarDriveId, soundCantMoveId; - Board board; boolean isFirstTime = true; @@ -44,7 +41,6 @@ public class GamePlayActivity extends Activity implements Board.SolveListener { setContentView(R.layout.activity_fullscreen); - setupSoundPool(); setupBoard(); } @@ -76,12 +72,12 @@ public class GamePlayActivity extends Activity implements Board.SolveListener { board.setDriveListener(new DriveListener() { @Override public void onDrive() { - soundPool.play(soundCarDriveId, 1, 1, 1, 0, 1); + TheSoundPool.getSoundPool(getBaseContext()).play(TheSoundPool.soundCarDriveId, 1, 1, 1, 0, 1); } @Override public void onBlocked() { - soundPool.play(soundCantMoveId, 1, 1, 1, 0, 1); + TheSoundPool.getSoundPool(getBaseContext()).play(TheSoundPool.soundCantMoveId, 1, 1, 1, 0, 1); } }); @@ -98,24 +94,6 @@ public class GamePlayActivity extends Activity implements Board.SolveListener { } } - /** - * Load sounds; start background music - */ - protected void setupSoundPool() { - soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); - soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { - @Override - public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { - if (sampleId == soundBackgroundId) { - soundPool.play(soundBackgroundId, 1, 1, 2, -1, 1); - } - } - }); - soundBackgroundId = soundPool.load(this, R.raw.tune, 2); - soundCarDriveId = soundPool.load(this, R.raw.car_drive, 1); - soundCantMoveId = soundPool.load(this, R.raw.cantmove, 1); - } - @Override public void onSolve(int score) { Intent intent = new Intent(this, FinishedActivity.class); diff --git a/app/src/main/java/com/camilstaps/rushhour/MainActivity.java b/app/src/main/java/com/camilstaps/rushhour/MainActivity.java index 01b28df..e0a511f 100644 --- a/app/src/main/java/com/camilstaps/rushhour/MainActivity.java +++ b/app/src/main/java/com/camilstaps/rushhour/MainActivity.java @@ -30,6 +30,8 @@ public class MainActivity extends ActionBarActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + + TheSoundPool.getSoundPool(this); } public void onClickHandler(View v) { diff --git a/app/src/main/java/com/camilstaps/rushhour/TheSoundPool.java b/app/src/main/java/com/camilstaps/rushhour/TheSoundPool.java new file mode 100644 index 0000000..c727979 --- /dev/null +++ b/app/src/main/java/com/camilstaps/rushhour/TheSoundPool.java @@ -0,0 +1,34 @@ +package com.camilstaps.rushhour; + +import android.content.Context; +import android.media.AudioManager; +import android.media.SoundPool; + +/** + * Created by camilstaps on 29-4-15. + */ +public class TheSoundPool { + + private static SoundPool soundPool; + public static int soundBackgroundId, soundCarDriveId, soundCantMoveId, soundVictoryId; + + public static SoundPool getSoundPool(Context context) { + if (soundPool == null) { + soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); + soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { + @Override + public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { + if (sampleId == soundBackgroundId) { + soundPool.play(soundBackgroundId, 1, 1, 2, -1, 1); + } + } + }); + soundBackgroundId = soundPool.load(context, R.raw.tune, 2); + soundCarDriveId = soundPool.load(context, R.raw.car_drive, 1); + soundCantMoveId = soundPool.load(context, R.raw.cantmove, 1); + soundVictoryId = soundPool.load(context, R.raw.victory, 1); + } + return soundPool; + } + +} diff --git a/app/src/main/res/values-v11/styles.xml b/app/src/main/res/values-v11/styles.xml deleted file mode 100644 index f72515d..0000000 --- a/app/src/main/res/values-v11/styles.xml +++ /dev/null @@ -1,15 +0,0 @@ -<resources> - - <style name="FullscreenTheme" parent="android:Theme.Holo"> - <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item> - <item name="android:windowActionBarOverlay">true</item> - <item name="android:windowBackground">@null</item> - <item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item> - <item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item> - </style> - - <style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar"> - <item name="android:background">@color/black_overlay</item> - </style> - -</resources> diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml deleted file mode 100644 index 7ce840e..0000000 --- a/app/src/main/res/values/attrs.xml +++ /dev/null @@ -1,12 +0,0 @@ -<resources> - - <!-- Declare custom theme attributes that allow changing which styles are - used for button bars depending on the API level. - ?android:attr/buttonBarStyle is new as of API 11 so this is - necessary to support previous API levels. --> - <declare-styleable name="ButtonBarContainerTheme"> - <attr name="metaButtonBarStyle" format="reference" /> - <attr name="metaButtonBarButtonStyle" format="reference" /> - </declare-styleable> - -</resources> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml deleted file mode 100644 index 327c060..0000000 --- a/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,5 +0,0 @@ -<resources> - - <color name="black_overlay">#66000000</color> - -</resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8d8c40e..766ab99 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -5,23 +5,4 @@ <!-- Customize your theme here. --> </style> - <style name="FullscreenTheme" parent="android:Theme.NoTitleBar"> - <item name="android:windowContentOverlay">@null</item> - <item name="android:windowBackground">@null</item> - <item name="metaButtonBarStyle">@style/ButtonBar</item> - <item name="metaButtonBarButtonStyle">@style/ButtonBarButton</item> - </style> - - <!-- Backward-compatible version of ?android:attr/buttonBarStyle --> - <style name="ButtonBar"> - <item name="android:paddingLeft">2dp</item> - <item name="android:paddingTop">5dp</item> - <item name="android:paddingRight">2dp</item> - <item name="android:paddingBottom">0dp</item> - <item name="android:background">@android:drawable/bottom_bar</item> - </style> - - <!-- Backward-compatible version of ?android:attr/buttonBarButtonStyle --> - <style name="ButtonBarButton" /> - </resources> |