forked from CyanogenMod/android_packages_apps_Calculator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'literacyapp-org/cm-13.0' into cm-13.0
- Loading branch information
Showing
10 changed files
with
150 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/src/main/java/com/android/calculator2/util/PlayerUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.android.calculator2.util; | ||
|
||
import android.content.Context; | ||
import android.media.MediaPlayer; | ||
|
||
/** | ||
* Created by GSC on 12/11/2016. | ||
*/ | ||
public class PlayerUtil { | ||
|
||
public static String RAW_FILE_EQUALS = "equals"; | ||
|
||
public static final String[] NUMBER_RAW_FILES = new String[] { | ||
"digit_0", | ||
"digit_1", | ||
"digit_2", | ||
"digit_3", | ||
"digit_4", | ||
"digit_5", | ||
"digit_6", | ||
"digit_7", | ||
"digit_8", | ||
"digit_9" | ||
}; | ||
|
||
public static void playRawFile(Context context, String rawFile) { | ||
int rawId = context.getResources().getIdentifier(rawFile, "raw", context.getPackageName()); | ||
if (rawId != 0) { | ||
MediaPlayer mediaPlayer = MediaPlayer.create(context, rawId); | ||
mediaPlayer.start(); | ||
} | ||
} | ||
|
||
public static void playResult(final Context context, final String result) { | ||
int rawId = context.getResources().getIdentifier(RAW_FILE_EQUALS, "raw", context.getPackageName()); | ||
if (rawId != 0) { | ||
final MediaPlayer mediaPlayer = MediaPlayer.create(context, rawId); | ||
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { | ||
@Override | ||
public void onCompletion(MediaPlayer mp) { | ||
playRawFile(context, result); | ||
} | ||
}); | ||
mediaPlayer.start(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.