-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
563 additions
and
10 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
83 changes: 83 additions & 0 deletions
83
app/src/main/java/io/wriprin/android/ipod/MusicAdapter.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,83 @@ | ||
package io.wriprin.android.ipod; | ||
|
||
import android.content.Context; | ||
import android.media.MediaMetadata; | ||
import android.media.MediaMetadataRetriever; | ||
import android.net.Uri; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.bumptech.glide.Glide; | ||
|
||
import org.w3c.dom.Text; | ||
|
||
import java.lang.reflect.Array; | ||
import java.util.ArrayList; | ||
|
||
public class MusicAdapter extends RecyclerView.Adapter<MusicAdapter.MyVieHolder> { | ||
|
||
private Context mContext; | ||
private ArrayList<MusicFiles> mFiles; | ||
|
||
MusicAdapter(Context mContext, ArrayList<MusicFiles> mFiles) | ||
{ | ||
this.mFiles = mFiles; | ||
this.mContext = mContext; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public MyVieHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View view = LayoutInflater.from(mContext).inflate(R.layout.music_items,parent,false); | ||
return new MyVieHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull MyVieHolder holder, int position) { | ||
holder.file_name.setText(mFiles.get(position).getTitle()); | ||
byte[] image = getAmbumArt(mFiles.get(position).getPath()); | ||
if (image != null) | ||
{ | ||
Glide.with(mContext).asBitmap() | ||
.load(image) | ||
.into(holder.album_art); | ||
} | ||
else { | ||
Glide.with(mContext) | ||
.load(R.drawable.bewedoc) | ||
.into(holder.album_art); | ||
} | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return mFiles.size(); | ||
} | ||
|
||
public class MyVieHolder extends RecyclerView.ViewHolder | ||
{ | ||
TextView file_name; | ||
ImageView album_art; | ||
|
||
public MyVieHolder(@NonNull View itemView) { | ||
super(itemView); | ||
file_name = itemView.findViewById(R.id.music_file_name); | ||
album_art = itemView.findViewById(R.id.music_img); | ||
} | ||
} | ||
|
||
private byte[] getAmbumArt(String uri) | ||
{ | ||
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); | ||
retriever.setDataSource(uri); | ||
byte[] art = retriever.getEmbeddedPicture(); | ||
retriever.release(); | ||
return art; | ||
} | ||
} |
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,60 @@ | ||
package io.wriprin.android.ipod; | ||
|
||
public class MusicFiles { | ||
private String path; | ||
private String title; | ||
private String artist; | ||
private String album; | ||
private String duration; | ||
|
||
public MusicFiles(String path, String title, String artist, String album, String duration) { | ||
this.path = path; | ||
this.title = title; | ||
this.artist = artist; | ||
this.album = album; | ||
this.duration = duration; | ||
} | ||
|
||
public MusicFiles() { | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
public void setPath(String path) { | ||
this.path = path; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getArtist() { | ||
return artist; | ||
} | ||
|
||
public void setArtist(String artist) { | ||
this.artist = artist; | ||
} | ||
|
||
public String getAlbum() { | ||
return album; | ||
} | ||
|
||
public void setAlbum(String album) { | ||
this.album = album; | ||
} | ||
|
||
public String getDuration() { | ||
return duration; | ||
} | ||
|
||
public void setDuration(String duration) { | ||
this.duration = duration; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/io/wriprin/android/ipod/PlayerActivity.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,14 @@ | ||
package io.wriprin.android.ipod; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.os.Bundle; | ||
|
||
public class PlayerActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_player); | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<gradient android:startColor="@color/colorPrimaryDark" android:angle="90"/> | ||
</shape> |
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="?attr/colorControlNormal"> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/> | ||
</vector> |
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="?attr/colorControlNormal"> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/> | ||
</vector> |
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="?attr/colorControlNormal"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/> | ||
</vector> |
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,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="?attr/colorControlNormal"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M8,5v14l11,-7z"/> | ||
</vector> |
Oops, something went wrong.