Advertisement
Guest User

Untitled

a guest
Mar 16th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.60 KB | None | 0 0
  1. package com.example.bronx.englishforfun;
  2.  
  3. import android.content.Intent;
  4. import android.media.MediaPlayer;
  5. import android.support.v7.app.ActionBarActivity;
  6. import android.os.Bundle;
  7. import android.view.Menu;
  8. import android.view.MenuItem;
  9. import android.view.View;
  10. import android.widget.ArrayAdapter;
  11. import android.widget.Button;
  12. import android.widget.ListView;
  13. import android.widget.SeekBar;
  14. import android.widget.TextView;
  15.  
  16. import java.util.ArrayList;
  17. import java.util.Arrays;
  18.  
  19.  
  20. public class podcastPlayer extends ActionBarActivity {
  21.  
  22.    // public class podcastPlayer extends ActionBarActivity implements View.OnClickListener {
  23.     private MediaPlayer mp1;
  24.  
  25.     int item;
  26.     SeekBar sb1;
  27.     Button playbtn;
  28.     Thread updateSeekBar1;
  29.     ListView lvpodcast;
  30.     ArrayAdapter<String> adapter ;
  31.  
  32.  
  33.  
  34.     @Override
  35.     protected void onCreate(Bundle savedInstanceState) {
  36.         super.onCreate(savedInstanceState);
  37.         setContentView(R.layout.activity_podcast_player);
  38.  
  39.  
  40.         playbtn = (Button) findViewById(R.id.playpBtn);
  41.         sb1 = (SeekBar) findViewById(R.id.seekBar2);
  42.         lvpodcast = (ListView) findViewById(R.id.lvpod);
  43.  
  44.         updateSeekBar1 = new Thread() {
  45.  
  46.             public void run() {
  47.                 int totalDuration = mp1.getDuration();
  48.                 int currentPosition = 0;
  49.                 while (currentPosition < totalDuration) {
  50.                     try {
  51.                         sleep(500);
  52.                         currentPosition = mp1.getCurrentPosition();
  53.                         sb1.setProgress(currentPosition);
  54.                     } catch (InterruptedException e) {
  55.                         e.printStackTrace();
  56.                     }
  57.                 }
  58.             }
  59.         };
  60.  
  61.  
  62.  
  63.  
  64.         Intent u = getIntent();
  65.         Bundle t = u.getExtras();
  66.         item = t.getInt("podcast1");
  67.  
  68.  
  69.  
  70.         if (item == 0) {
  71.  
  72.             String podcast1[] = {"Gloria: Did you hear that Manuel is quitting? He took a job with another company.",
  73.                     "Sam: I'm not surprised. He came up against the glass ceiling and he decided to jump ship.",
  74.                     "Gloria: Really? I didn't know he was bucking for promotion.",
  75.                     "Sam: He's been trying to become a manager for three years, but other people have been promoted over him or they've hired from outside the company.",
  76.                     "Gloria: I didn't know that. I was aware of the wage disparities within the company and the gender pay gap within each department, but this is news to me.",
  77.                     "Sam: Haven't you noticed that people who take extended leave to have children or try for some type of work-life balance are passed over for plum assignments, raises, and promotions? There are definite limits to advancement.",
  78.                     "Gloria: I thought it was just favoritism on the part of the bosses. Their friends got promoted and other people didn't.",
  79.                     "Sam: That's certainly true, but that's only part of the story.",
  80.                     "Gloria: Why are we still working for a company with such unfair policies?",
  81.                     "Sam: Speak for yourself. I'm giving notice today."};
  82.             ArrayList<String> podL = new ArrayList<String>();
  83.             podL.addAll( Arrays.asList(podcast1) );
  84.             adapter = new ArrayAdapter<String>(this, R.layout.row, podL);
  85.  
  86.             lvpodcast.setAdapter(adapter);
  87.  
  88.             if(mp1!=null){
  89.                 mp1.stop();
  90.                 mp1.release();
  91.             }
  92.  
  93.             mp1 = MediaPlayer.create(podcastPlayer.this, R.raw.limits);
  94.             mp1.start();
  95.             sb1.setMax(mp1.getDuration());
  96.             updateSeekBar1.start();
  97.             playbtn.setOnClickListener(new View.OnClickListener() {
  98.                 @Override
  99.                 public void onClick(View v) {
  100.                     if (mp1.isPlaying()) {
  101.                         playbtn.setText("ODTWARZAJ");
  102.                         mp1.pause();
  103.                     } else {
  104.                         playbtn.setText("ZATRZYMAJ");
  105.                         mp1.start();
  106.                     }
  107.                 }
  108.             });
  109.             sb1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
  110.                 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
  111.                 }
  112.                 public void onStartTrackingTouch(SeekBar seekBar) {
  113.                 }
  114.                 public void onStopTrackingTouch(SeekBar seekBar) {
  115.                     mp1.seekTo(seekBar.getProgress());
  116.                 }
  117.             });
  118.  
  119.         }
  120.  
  121.  
  122.  
  123.  
  124.         Intent j = getIntent();
  125.         Bundle g = j.getExtras();
  126.         item = g.getInt("podcast2");
  127.  
  128.         if (item == 1) {
  129.  
  130.             String podcast1[] = {"Nico: I’ve moving to Atlanta. I want a fresh start.\n" +
  131.                     "\n" +
  132.                     "Celia: This is a surprise. I thought you were going to stick it out here and try to put the past behind you.\n" +
  133.                     "\n" +
  134.                     "Nico: There are too many reminders here. I want a clean slate. What’s done is done and I’m tired of blame and recriminations.\n" +
  135.                     "\n" +
  136.                     "Celia: I’m glad to hear you’ve stopped beating yourself up over what’s happened, but are you sure moving away will help you move on?\n" +
  137.                     "\n" +
  138.                     "Nico: The world is my oyster now, isn’t it? I can live anywhere I want to and do anything I want to.\n" +
  139.                     "\n" +
  140.                     "Celia: I guess so, but are you sure you want to uproot and leave town?\n" +
  141.                     "\n" +
  142.                     "Nico: I’m not trying to reinvent myself, but if I’m going to start over, I might as well do it in a new town.\n" +
  143.                     "\n" +
  144.                     "Celia: I guess a new town is a good place to start a new life and maybe you’ll find a new love. Many people bounce back from a difficult divorce.\n" +
  145.                     "\n" +
  146.                     "Nico: I’ve sworn off women. The only female I want in my life right now is my dog Fifi!"};
  147.             ArrayList<String> podL = new ArrayList<String>();
  148.             podL.addAll( Arrays.asList(podcast1));
  149.             adapter = new ArrayAdapter<String>(this, R.layout.row, podL);
  150.  
  151.             lvpodcast.setAdapter(adapter);
  152.  
  153.             if(mp1!=null){
  154.                 mp1.stop();
  155.                 mp1.release();
  156.             }
  157.  
  158.             mp1 = MediaPlayer.create(podcastPlayer.this, R.raw.getting);
  159.             mp1.start();
  160.             sb1.setMax(mp1.getDuration());
  161.             updateSeekBar1.start();
  162.             playbtn.setOnClickListener(new View.OnClickListener() {
  163.                 @Override
  164.                 public void onClick(View v) {
  165.                     if (mp1.isPlaying()) {
  166.                         playbtn.setText("ODTWARZAJ");
  167.                         mp1.pause();
  168.                     } else {
  169.                         playbtn.setText("ZATRZYMAJ");
  170.                         mp1.start();
  171.                     }
  172.                 }
  173.             });
  174.         }
  175.  
  176.         Intent k = getIntent();
  177.         Bundle f = k.getExtras();
  178.         item = f.getInt("podcast3");
  179.  
  180.         if (item == 2) {
  181.  
  182.             String podcast1[] = {"Amelia: I wish we had hired a professional videographer to film it instead of asking your friend Lenny to do it.\n" +
  183.                     "\n" +
  184.                     "Victor: This video isn’t so bad. The production quality isn’t the best, but he did a pretty good job.\n" +
  185.                     "\n" +
  186.                     "Amelia: It’s not bad if you like your video out-of-focus. There are no transitions between scenes and the lighting is terrible. At best, it looks like a rough cut.\n" +
  187.                     "\n" +
  188.                     "Victor: It is a little rough, I admit.\n" +
  189.                     "\n" +
  190.                     "Amelia: There are problems with the audio, too. There are sections of dead air when the audio cuts out. And when there is audio, the volume isn’t uniform.\n" +
  191.                     "\n" +
  192.                     "Victor: That’s true, too, I guess…\n" +
  193.                     "\n" +
  194.                     "Amelia: And the handheld camera footage is so shaky that I feel ill watching it.\n" +
  195.                     "\n" +
  196.                     "Victor: Lenny was just having a good time, getting into the spirit of it.\n" +
  197.                     "\n" +
  198.                     "Amelia: Is that why he got close-up shots of all of the pretty women and none of the other guests?\n" +
  199.                     "\n" +
  200.                     "Victor: Well, you know Lenny. He’ll do better next time.\n" +
  201.                     "\n" +
  202.                     "Amelia: Next time?! How many times do you plan to get married? "};
  203.             ArrayList<String> podL = new ArrayList<String>();
  204.             podL.addAll( Arrays.asList(podcast1));
  205.             adapter = new ArrayAdapter<String>(this, R.layout.row, podL);
  206.  
  207.             lvpodcast.setAdapter(adapter);
  208.  
  209.  
  210.             if(mp1!=null){
  211.                 mp1.stop();
  212.                 mp1.release();
  213.             }
  214.  
  215.             mp1 = MediaPlayer.create(podcastPlayer.this, R.raw.describing);
  216.             mp1.start();
  217.             sb1.setMax(mp1.getDuration());
  218.             updateSeekBar1.start();
  219.             playbtn.setOnClickListener(new View.OnClickListener() {
  220.                 @Override
  221.                 public void onClick(View v) {
  222.                     if (mp1.isPlaying()) {
  223.                         playbtn.setText("ODTWARZAJ");
  224.                         mp1.pause();
  225.                     } else {
  226.                         playbtn.setText("ZATRZYMAJ");
  227.                         mp1.start();
  228.                     }
  229.                 }
  230.             });
  231.         }
  232.     }
  233.  
  234.     @Override
  235.     public boolean onCreateOptionsMenu(Menu menu) {
  236.         // Inflate the menu; this adds items to the action bar if it is present.
  237.         getMenuInflater().inflate(R.menu.menu_podcast_player, menu);
  238.         return true;
  239.     }
  240.  
  241.     @Override
  242.     public boolean onOptionsItemSelected(MenuItem item) {
  243.         // Handle action bar item clicks here. The action bar will
  244.         // automatically handle clicks on the Home/Up button, so long
  245.         // as you specify a parent activity in AndroidManifest.xml.
  246.         int id = item.getItemId();
  247.  
  248.         //noinspection SimplifiableIfStatement
  249.         if (id == R.id.action_settings) {
  250.             return true;
  251.         }
  252.  
  253.         return super.onOptionsItemSelected(item);
  254.     }
  255.     public void onBackPressed(){
  256.         mp1.stop();
  257.         finish();
  258.     }
  259.  
  260. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement