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
private static String LOGTAG = "Media Importer";
private ListView mediaListView;
private Context context;
private ArrayList arrayListTitles;
private ArrayList<Long> arrayListIds;
private ArrayAdapter arrayAdapater;
......@@ -38,22 +37,17 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
setContentView(R.layout.activity_playlist_editor);
mediaListView = (ListView) findViewById(R.id.medialist1);
ContentResolver cr = getContentResolver();
Intent intent = getIntent();
int message = intent.getIntExtra(ManagePlaylistsActivity.EDIT_MODE,-1);
Log.d("Hilfe", "Test");
Log.d("Hilfe", "Message: " + message);
if (message == ManagePlaylistsActivity.PLAYLIST_ADD){
Log.d("Hilfe", "bla");
arrayListIds = new ArrayList<Long>();
Log.d("Hilfe", "bla4");
mediaListView.setOnItemClickListener(this);
Log.d("Hilfe", "bla5");
//loadMedia();
//Log.d("Hilfe", "bla3");
loadMedia();
Log.d("Hilfe", "bla3");
}
else if (message == ManagePlaylistsActivity.PLAYLIST_EDIT){
......@@ -65,8 +59,11 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
}
private void loadMedia() {
Log.d("Hallo", "Start load media");
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;
......@@ -79,13 +76,14 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
} else {
Log.d(LOGTAG, "Stuff.");
arrayListTitles = new ArrayList();
arrayAdapater = new ArrayAdapter(context, android.R.layout.simple_list_item_1, arrayListTitles);
ArrayList arrayListTitles = new ArrayList();
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);
Log.d(LOGTAG, "Do cursor stuff");
int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.TITLE);
int idColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Media._ID);
arrayListIds.clear();
arrayListTitles.clear();
do {
long thisId = cursor.getLong(idColumn);
String thisTitle = cursor.getString(titleColumn);
......@@ -110,7 +108,7 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
MediaPlayer mMediaPlayer = new MediaPlayer();
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mMediaPlayer.setDataSource(context, contentUri);
mMediaPlayer.setDataSource(getApplicationContext(), contentUri);
} catch (IOException e) {
Log.d(LOGTAG, "Fail. mist.");
e.printStackTrace();
......@@ -125,6 +123,7 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d(LOGTAG, "Item clicked");
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