Commit 75ca2642 by Alisa Jung

blub

playlists von editieractivity an verwaltungsactivity durchreichen geht man müsste noch auf gleiche art playlists an mainactivity durchreichen über die ids in der playlist kann man die lieder ansteuern siehe playSongWithID
parent 1ca37310
Pipeline #126 skipped
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
package com.soundapp.alisajung.ambientsounds; package com.soundapp.alisajung.ambientsounds;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
...@@ -8,6 +9,10 @@ import android.support.v7.app.AppCompatActivity; ...@@ -8,6 +9,10 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
public class ManagePlaylistsActivity extends AppCompatActivity { public class ManagePlaylistsActivity extends AppCompatActivity {
...@@ -15,10 +20,28 @@ public class ManagePlaylistsActivity extends AppCompatActivity { ...@@ -15,10 +20,28 @@ public class ManagePlaylistsActivity extends AppCompatActivity {
public static int PLAYLIST_EDIT = 1; public static int PLAYLIST_EDIT = 1;
public static String EDIT_MODE = "editmode"; public static String EDIT_MODE = "editmode";
public static int RESULT_NEW_PLAYLIST = 0;
public static int RESULT_CANCEL = 1;
public static int RESULT_EDITED = 2;
public static int RESULT_DELETED = 3;
private ArrayList<Playlist> playlists;
private ArrayList<String> playlist_names;
private ListView playlistView;
private ArrayAdapter arrayAdapater;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_playlists); setContentView(R.layout.activity_manage_playlists);
playlistView = (ListView) findViewById(R.id.playlists);
playlists = new ArrayList<Playlist>();
playlist_names = new ArrayList<String>();
arrayAdapater = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, playlist_names);
playlistView.setAdapter(arrayAdapater);
} }
public void backToMainMenu(View view){ public void backToMainMenu(View view){
...@@ -32,7 +55,25 @@ public class ManagePlaylistsActivity extends AppCompatActivity { ...@@ -32,7 +55,25 @@ public class ManagePlaylistsActivity extends AppCompatActivity {
Intent intent = new Intent(this, PlaylistEditor.class); Intent intent = new Intent(this, PlaylistEditor.class);
int message = PLAYLIST_ADD; int message = PLAYLIST_ADD;
intent.putExtra(EDIT_MODE,PLAYLIST_ADD); intent.putExtra(EDIT_MODE,PLAYLIST_ADD);
startActivity(intent); startActivityForResult(intent,PLAYLIST_ADD);
} }
public void onActivityResult(final int requestCode, int resultCode, final Intent data){
if (requestCode == PLAYLIST_ADD && resultCode == RESULT_NEW_PLAYLIST){
Log.d("Hopefully", "received new playlist");
Playlist p = (Playlist)data.getSerializableExtra("New Playlist");
if (playlist_names.contains(p.getName())){
Log.d("ERROR", "Playlist with this name already exists. abort. TODO show error message in app.");
return;
}
playlists.add(p);
playlist_names.add(p.getName());
Log.d("Playlist names: ", playlist_names.toString());
arrayAdapater = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, playlist_names);
playlistView.setAdapter(arrayAdapater);
//TODO when activity is finished, pass playlist list to main activity
//should work just like playlist is passed to this.
}
}
} }
package com.soundapp.alisajung.ambientsounds;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Created by die_hexe on 28.05.2016.
*/
public class Playlist implements Serializable{
private String title;
private ArrayList<Long> songIDs;
public Playlist(String title, ArrayList<Long> songs){
this.title = title;
this.songIDs = songs;
}
public ArrayList<Long> getSongIDs(){
return songIDs;
}
public String getName(){
return title;
}
}
...@@ -11,11 +11,13 @@ import android.net.Uri; ...@@ -11,11 +11,13 @@ import android.net.Uri;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -51,7 +53,10 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -51,7 +53,10 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
} }
else if (message == ManagePlaylistsActivity.PLAYLIST_EDIT){ else if (message == ManagePlaylistsActivity.PLAYLIST_EDIT){
//Auch media laden
//außerdem die auswählen, die in playlist sind
//iwie plalist reingeben
//todo todo todo
} }
else{ else{
Log.d("Hilfe", "FUCK FUCK FUCK "+message + " sollte " + ManagePlaylistsActivity.PLAYLIST_ADD); Log.d("Hilfe", "FUCK FUCK FUCK "+message + " sollte " + ManagePlaylistsActivity.PLAYLIST_ADD);
...@@ -59,11 +64,8 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -59,11 +64,8 @@ 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;
Log.d("Hallo", "osigh");
Cursor cursor = getContentResolver().query(uri, null, null, null, null); Cursor cursor = getContentResolver().query(uri, null, null, null, null);
Log.d("Hallo nochmal", "lll");
long lastid = 0; long lastid = 0;
...@@ -121,9 +123,48 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI ...@@ -121,9 +123,48 @@ public class PlaylistEditor extends AppCompatActivity implements AdapterView.OnI
mMediaPlayer.start(); mMediaPlayer.start();
} }
public void savePlaylist(View view){
TextView titleview = (TextView) findViewById(R.id.editText);
String title = titleview.getText().toString();
SparseBooleanArray checked = mediaListView.getCheckedItemPositions();
ArrayList<Long> selected = new ArrayList<Long>();
int count = mediaListView.getCount();
for (int i = 0; i < count; i++) {
if (checked.get(i)) {
// Do something
Log.d("Item ", i + " is checked.");
selected.add(arrayListIds.get(i));
} else Log.d("is not ", "checked");
}
Log.d("Hi", "array done");
Playlist p = new Playlist(title,selected);
Intent intent = new Intent();
intent.putExtra("New Playlist",p);
int resultCode = ManagePlaylistsActivity.RESULT_NEW_PLAYLIST;
setResult(resultCode, intent);
finish();
}
public void abort(View view){
Intent intent = new Intent();
setResult(ManagePlaylistsActivity.RESULT_CANCEL,intent);
finish();
}
public void deleteList(View view){
Log.d("TODO", "delete playlist");
Intent intent = new Intent();
setResult(ManagePlaylistsActivity.RESULT_DELETED);
finish();
}
@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"); Log.d(LOGTAG, "Item clicked");
playSongWithID(arrayListIds.get(position)); playSongWithID(arrayListIds.get(position));
} }
} }
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<ListView <ListView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/listView2" android:id="@+id/playlists"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_above="@+id/button2" /> android:layout_above="@+id/button2" />
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
android:id="@+id/button2" android:id="@+id/button2"
android:onClick="backToMainMenu" android:onClick="backToMainMenu"
android:layout_alignTop="@+id/button3" android:layout_alignTop="@+id/button3"
android:layout_alignRight="@+id/listView2" android:layout_alignParentRight="true"
android:layout_alignEnd="@+id/listView2" /> android:layout_alignParentEnd="true" />
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
android:id="@+id/button3" android:id="@+id/button3"
android:onClick="addPlaylist" android:onClick="addPlaylist"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:layout_centerHorizontal="true" />
android:layout_alignParentStart="true" />
</RelativeLayout> </RelativeLayout>
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/medialist1" android:id="@+id/medialist1"
android:choiceMode="multipleChoice"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_below="@+id/editText" /> android:layout_below="@+id/editText" />
...@@ -31,8 +32,9 @@ ...@@ -31,8 +32,9 @@
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Done" android:text="Save"
android:id="@+id/button2" android:id="@+id/button2"
android:onClick="savePlaylist"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" /> android:layout_alignParentEnd="true" />
...@@ -42,7 +44,17 @@ ...@@ -42,7 +44,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Delete List" android:text="Delete List"
android:id="@+id/button3" android:id="@+id/button3"
android:onClick="deleteList"
android:layout_alignTop="@+id/button2" android:layout_alignTop="@+id/button2"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" /> android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Abort"
android:id="@+id/button"
android:onClick="abort"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout> </RelativeLayout>
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