Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cleanup to PlaybackFragment.java #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public class PlaybackFragment extends DialogFragment {
private TextView mFileNameTextView = null;
private TextView mFileLengthTextView = null;

//stores whether or not the mediaplayer is currently playing audio
// stores whether or not the mediaplayer is currently playing audio
private boolean isPlaying = false;

//stores minutes and seconds of the length of the file.
// stores minutes and seconds of the length of the file.
long minutes = 0;
long seconds = 0;

Expand Down Expand Up @@ -98,7 +98,6 @@ public void onActivityCreated(Bundle savedInstanceState) {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

Dialog dialog = super.onCreateDialog(savedInstanceState);

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
Expand Down Expand Up @@ -212,17 +211,15 @@ public void onDestroy() {
}

// Play start/stop
private void onPlay(boolean isPlaying){
private void onPlay(boolean isPlaying) {
if (!isPlaying) {
//currently MediaPlayer is not playing audio
if(mMediaPlayer == null) {
startPlaying(); //start from beginning
startPlaying(); // start from beginning
} else {
resumePlaying(); //resume the currently paused MediaPlayer
resumePlaying(); // resume the currently paused MediaPlayer
}

} else {
//pause the MediaPlayer
pausePlaying();
}
}
Expand Down Expand Up @@ -281,7 +278,7 @@ public void onCompletion(MediaPlayer mp) {
e.printStackTrace();
}

//keep screen on while playing audio
// keep screen on while playing audio
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

Expand Down Expand Up @@ -312,11 +309,11 @@ private void stopPlaying() {
mCurrentProgressTextView.setText(mFileLengthTextView.getText());
mSeekBar.setProgress(mSeekBar.getMax());

//allow the screen to turn off again once audio is finished playing
// allow the screen to turn off again once audio is finished playing
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

//updating mSeekBar
// updating mSeekBar
private Runnable mRunnable = new Runnable() {
@Override
public void run() {
Expand Down