Android Open Source - RadioRake Recordio Base Activity






From Project

Back to project page RadioRake.

License

The source code is released under:

GNU General Public License

If you think the Android project RadioRake listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.asp.radiorake;
//from   www. j a  v a2  s. c  o m

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaPlayer;


import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.asp.radiorake.recording.RecorderService;
import com.aspillai.R;


public class RecordioBaseActivity extends SherlockActivity {

    private static final int ADD_FAVOURITE = 1;
    private static final int EXIT = 2;
    private static final int SCHEDULED_RECORDINGS = 3;
    private static final int RECORDINGS = 4;
    private static final String TAG = "com.asp.radiorake.RecordioBaseActivity";

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void finish() {
        super.finish();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add(Menu.NONE, ADD_FAVOURITE, Menu.NONE, "Add Favourite");
        menu.add(Menu.NONE, EXIT, Menu.NONE, "Exit RadioRake!");
        menu.add(Menu.NONE, SCHEDULED_RECORDINGS, Menu.NONE, "Scheduled Recordings");
        menu.add(Menu.NONE, RECORDINGS, Menu.NONE, "Recordings");
        return (super.onCreateOptionsMenu(menu));
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        RadioApplication radioApplication = (RadioApplication) getApplication();
        switch (item.getItemId()) {

            case ADD_FAVOURITE:

                RadioDetails radioDetails = new RadioDetails();

                if (alreadyPlaying()) {
                    radioDetails = radioApplication.getPlayingStation();
                }

                Intent confirmDetailsIntent = new Intent(RecordioBaseActivity.this, ConfirmDetailsActivity.class);
                confirmDetailsIntent.putExtra(getString(R.string.radio_details_key), radioDetails);
                startActivity(confirmDetailsIntent);
                finish();
                return true;

            case SCHEDULED_RECORDINGS:

                Intent scheduledRecordingsIntent = new Intent(RecordioBaseActivity.this, ListScheduledRecordingsActivity.class);
                startActivity(scheduledRecordingsIntent);
                finish();
                return true;

            case RECORDINGS:

                Intent recordingsIntent = new Intent(RecordioBaseActivity.this, RecordingsActivity.class);
                startActivity(recordingsIntent);
                finish();
                return true;

            case EXIT:
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setMessage("Exit RadioRake?")
                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialogInterface, int i) {
                                checkIfExitingFromRadioActivity();
                            }
                        })
                        .setNegativeButton("No", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialogInterface, int i) {
                            }
                        });
                builder.create().show();
                return true;

            default:
                return super.onOptionsItemSelected(item);
        }
    }

    private void checkIfExitingFromRadioActivity() {
//        if (getClass().getSimpleName().equals("RadioActivity")) {
        MediaPlayer mediaPlayer = ((RadioApplication) getApplication()).getMediaPlayer();
        if (mediaPlayer != null && mediaPlayer.isPlaying()) {
            PlayerService.sendWakefulWork(getApplicationContext(), createPlayingIntent(null, RadioApplication.StopPlaying));
        }
        if (RecorderService.alreadyRecording()) {
            RecorderService.cancelRecording();
        }
//        } else {
//            ((RadioApplication) getApplication()).
// (true);
//        }
        finish();
    }


    public boolean alreadyPlaying() {
        RadioApplication radioApplication = (RadioApplication) getApplication();
        MediaPlayer mediaPlayer = radioApplication.getMediaPlayer();
        return mediaPlayer != null && mediaPlayer.isPlaying();
    }

    protected Intent createRecordingIntent(RadioDetails radioDetails) {
        Intent intent = new Intent("com.asp.radiorake.recording.RecorderService");
        if (radioDetails != null) {
            intent.putExtra(getString(R.string.radio_details_key), radioDetails);
        }
        return intent;
    }

    protected Intent createPlayingIntent(RadioDetails radioDetails, int operation) {
        Intent intent = new Intent("com.asp.radiorake.PlayerService");

        if (radioDetails != null) {
            intent.putExtra(getString(R.string.radio_details_key), radioDetails);
        }

        intent.putExtra(getString(R.string.player_service_operation_key), operation);
        return intent;
    }
}




Java Source Code List

com.asp.radiorake.AddNewScheduledRecordingActivity.java
com.asp.radiorake.AlarmHelper.java
com.asp.radiorake.CallReceiver.java
com.asp.radiorake.ConfirmDetailsActivity.java
com.asp.radiorake.DatabaseHelper.java
com.asp.radiorake.DatePickerFragment.java
com.asp.radiorake.LastPlayedFile.java
com.asp.radiorake.ListScheduledRecordingsActivity.java
com.asp.radiorake.NotificationHelper.java
com.asp.radiorake.PlayerService.java
com.asp.radiorake.PlayingFile.java
com.asp.radiorake.RadioActivity.java
com.asp.radiorake.RadioApplication.java
com.asp.radiorake.RadioDetails.java
com.asp.radiorake.RebootBroadcastReceiver.java
com.asp.radiorake.RecordingsActivity.java
com.asp.radiorake.RecordioBaseActivity.java
com.asp.radiorake.RemoteControlReceiver.java
com.asp.radiorake.ScheduledRecordingsCursorAdaptor.java
com.asp.radiorake.TimePickerFragment.java
com.asp.radiorake.filehandling.FileHandler.java
com.asp.radiorake.filehandling.M3uHandler.java
com.asp.radiorake.filehandling.PlsHandler.java
com.asp.radiorake.recording.RecorderService.java
com.asp.radiorake.recording.RecordingBroadcastReceiver.java
com.asp.radiorake.utils.DateUtils.java
com.asp.radiorake.utils.StringUtils.java