Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
LogAnd1 committed Jan 9, 2018
2 parents c0310bb + 4a3d423 commit bd91979
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
28 changes: 19 additions & 9 deletions app/src/main/java/com/example/pp/podcastplayer/MP3Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@


import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

Expand All @@ -25,7 +28,7 @@ public class MP3Activity extends AppCompatActivity {
String path_slika = "";
String naslov = "";
MediaPlayer MP = new MediaPlayer();
Timer timer = new Timer();


@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -49,7 +52,7 @@ protected void onCreate(Bundle savedInstanceState) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
path_mp3 = bundle.getString("mp3");
//path_slika = bundle.getString("slika");
path_slika = bundle.getString("slika");
naslov = bundle.getString("naslov");
}
}
Expand All @@ -67,9 +70,13 @@ protected void onCreate(Bundle savedInstanceState) {
e.printStackTrace();
}
TVNaslov.setText(naslov);
//TVDur.setText(MP.getDuration());
//Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+path_slika);
//IV.setImageBitmap(bitmap);
Date date = new Date(MP.getDuration());
DateFormat formatter = new SimpleDateFormat("mm:ss");
String dateFormatted = formatter.format(date);
TVDur.setText(dateFormatted);
System.out.println(path_slika);
Bitmap bitmap = BitmapFactory.decodeFile(path_slika);
IV.setImageBitmap(bitmap);


}
Expand All @@ -83,8 +90,8 @@ public void onClick(View view) {
IBPause.setVisibility(View.VISIBLE);
ImageButton IBPlay = (ImageButton) findViewById(R.id.playbutton);
IBPlay.setVisibility(View.GONE);

/*timer.scheduleAtFixedRate(new TimerTask() {
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
Expand All @@ -94,7 +101,10 @@ public void run() {
TVCurr.post(new Runnable() {
@Override
public void run() {
TVCurr.setText(MP.getCurrentPosition());
Date date = new Date(MP.getCurrentPosition());
DateFormat formatter = new SimpleDateFormat("mm:ss");
String dateFormatted = formatter.format(date);
TVCurr.setText(dateFormatted);
}
});
} else {
Expand All @@ -104,7 +114,7 @@ public void run() {
}
});
}
}, 0, 1000);*/
}, 0, 1000);


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void onClick(View v) {
//Downloader d = new Downloader();
//String code = d.DownloadFile(urlMP3, "downloads/mp3", nameMP3[nameMP3.length - 1]);
//downloadFile(urlMP3, nameMP3[nameMP3.length - 1],PATH2);
DownloadObjects Doo = new DownloadObjects(v,urlMP3,nameMP3[nameMP3.length - 1],label.getText().toString());
DownloadObjects Doo = new DownloadObjects(v,urlMP3,nameMP3[nameMP3.length - 1],label.getText().toString(),image);
new DownloadFilesTask().execute(Doo);

} catch (Exception e) {
Expand All @@ -86,11 +86,10 @@ public void onClick(View v) {

Intent intent = new Intent(v.getContext(), MP3Activity.class);
Bundle bundle = new Bundle();
System.out.println(PATH);
System.out.println(label.getText().toString());
bundle.putString("mp3",(String) PATH);
bundle.putString("naslov",(String) label.getText().toString());
// bundle.putString("path_slika",(String) url.getText());
String PATH3 = Environment.getExternalStorageDirectory().toString()+ "/downloads/images/" + image;
bundle.putString("slika",(String) PATH3);

intent.putExtras(bundle);
v.getContext().startActivity(intent);
Expand Down Expand Up @@ -237,19 +236,22 @@ public static class DownloadObjects {
private String url;
private String name;
private String naslov;
private String image;

DownloadObjects(View v, String url, String name, String naslov){
DownloadObjects(View v, String url, String name, String naslov, String image){
this.v=v;
this.url=url;
this.name=name;
this.naslov=naslov;
this.image=image;
}
}

private static class DownloadFilesTask extends AsyncTask<DownloadObjects, Integer, Long> {
View vi;
String naslov;
String name;
String image;
protected Long doInBackground(DownloadObjects... object) {
int count = object.length;
long totalSize = 0;
Expand All @@ -259,6 +261,7 @@ protected Long doInBackground(DownloadObjects... object) {
vi=object[i].v;
naslov=object[i].naslov;
name=object[i].name;
image=object[i].image;
if (isCancelled()) break;
}
return totalSize;
Expand All @@ -273,10 +276,16 @@ protected void onPostExecute(Long result) {
String PATH = Environment.getExternalStorageDirectory().toString()+ "/downloads/mp3/" + name;
bundle.putString("mp3",(String) PATH);
bundle.putString("naslov",naslov);
// bundle.putString("path_slika",(String) url.getText());
String PATH3 = Environment.getExternalStorageDirectory().toString()+ "/downloads/images/" + image;
bundle.putString("slika",(String) PATH3);

intent.putExtras(bundle);
vi.getContext().startActivity(intent);





}
}
}

0 comments on commit bd91979

Please sign in to comment.