Commit 1ca37310 by Alisa Jung

bugfreier zwischenstand. buttons um activities zu wechseln, add playlist button…

bugfreier zwischenstand. buttons um activities zu wechseln, add playlist button lädt alle lieder. nächster schritt: playlist machen.
parent d3abf1ff
...@@ -27,7 +27,6 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -27,7 +27,6 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
private static String LOGTAG = "Media Importer"; private static String LOGTAG = "Media Importer";
private ListView mediaListView; private ListView mediaListView;
private Context context; private Context context;
private ArrayList arrayListTitles;
private ArrayList<Long> arrayListIds; private ArrayList<Long> arrayListIds;
private ArrayAdapter arrayAdapater; private ArrayAdapter arrayAdapater;
...@@ -38,22 +37,17 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -38,22 +37,17 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
setContentView(R.layout.activity_playlist_editor); setContentView(R.layout.activity_playlist_editor);
mediaListView = (ListView) findViewById(R.id.medialist1); mediaListView = (ListView) findViewById(R.id.medialist1);
ContentResolver cr = getContentResolver();
Intent intent = getIntent(); Intent intent = getIntent();
int message = intent.getIntExtra(ManagePlaylistsActivity.EDIT_MODE,-1); int message = intent.getIntExtra(ManagePlaylistsActivity.EDIT_MODE,-1);
Log.d("Hilfe", "Test");
Log.d("Hilfe", "Message: " + message);
if (message == ManagePlaylistsActivity.PLAYLIST_ADD){ if (message == ManagePlaylistsActivity.PLAYLIST_ADD){
Log.d("Hilfe", "bla");
arrayListIds = new ArrayList<Long>(); arrayListIds = new ArrayList<Long>();
Log.d("Hilfe", "bla4");
mediaListView.setOnItemClickListener(this); mediaListView.setOnItemClickListener(this);
Log.d("Hilfe", "bla5"); Log.d("Hilfe", "bla5");
//loadMedia(); loadMedia();
//Log.d("Hilfe", "bla3"); Log.d("Hilfe", "bla3");
} }
else if (message == ManagePlaylistsActivity.PLAYLIST_EDIT){ else if (message == ManagePlaylistsActivity.PLAYLIST_EDIT){
...@@ -65,8 +59,11 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -65,8 +59,11 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
} }
private void loadMedia() { private void loadMedia() {
Log.d("Hallo", "Start load media");
Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = contentResolver.query(uri, null, null, null, null); Log.d("Hallo", "osigh");
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
Log.d("Hallo nochmal", "lll");
long lastid = 0; long lastid = 0;
...@@ -79,13 +76,14 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -79,13 +76,14 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
} else { } else {
Log.d(LOGTAG, "Stuff."); Log.d(LOGTAG, "Stuff.");
arrayListTitles = new ArrayList(); ArrayList arrayListTitles = new ArrayList();
arrayAdapater = new ArrayAdapter(context, android.R.layout.simple_list_item_1, arrayListTitles); Log.d(LOGTAG, "Create adapter");
arrayAdapater = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, arrayListTitles);
Log.d(LOGTAG, "Set adapter");
mediaListView.setAdapter(arrayAdapater); mediaListView.setAdapter(arrayAdapater);
Log.d(LOGTAG, "Do cursor stuff");
int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.TITLE); int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.TITLE);
int idColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media._ID); int idColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media._ID);
arrayListIds.clear();
arrayListTitles.clear();
do { do {
long thisId = cursor.getLong(idColumn); long thisId = cursor.getLong(idColumn);
String thisTitle = cursor.getString(titleColumn); String thisTitle = cursor.getString(titleColumn);
...@@ -110,7 +108,7 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -110,7 +108,7 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
MediaPlayer mMediaPlayer = new MediaPlayer(); MediaPlayer mMediaPlayer = new MediaPlayer();
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try { try {
mMediaPlayer.setDataSource(context, contentUri); mMediaPlayer.setDataSource(getApplicationContext(), contentUri);
} catch (IOException e) { } catch (IOException e) {
Log.d(LOGTAG, "Fail. mist."); Log.d(LOGTAG, "Fail. mist.");
e.printStackTrace(); e.printStackTrace();
...@@ -125,6 +123,7 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -125,6 +123,7 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d(LOGTAG, "Item clicked");
playSongWithID(arrayListIds.get(position)); playSongWithID(arrayListIds.get(position));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment