Commit 32259739 authored by charley.punshon's avatar charley.punshon

Cleaned up code for the search view.

parent 188982d7
This diff is collapsed.
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".SongInformationPage"></activity> <activity android:name=".SavedPlaylistView"></activity>
<activity android:name=".SongInformationPage" />
<activity android:name=".SongScreenView" /> <activity android:name=".SongScreenView" />
<activity android:name=".playlistView" /> <activity android:name=".playlistView" />
<activity android:name=".SavedPlaylists" /> <activity android:name=".SavedPlaylists" />
......
...@@ -12,7 +12,7 @@ public class Listener implements View.OnClickListener { ...@@ -12,7 +12,7 @@ public class Listener implements View.OnClickListener {
Log.d("Testing", "Button pressed"); Log.d("Testing", "Button pressed");
Intent i = new Intent(v.getContext(), SavedPlaylists.class); Intent i = new Intent(v.getContext(), SavedPlaylistView.class);
v.getContext().startActivity(i); v.getContext().startActivity(i);
} }
} }
package com.example.soulfood_assignment2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class SavedPlaylistView extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_saved_playlists);
}
}
package com.example.soulfood_assignment2;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
public class SavedPlaylists extends AppCompatActivity {
public static SharedPreferences playlists;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_saved_playlists);
playlists = getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = playlists.edit();
editor.putString("playlist 1", "1");
editor.commit();
ArrayList<String> saved = new ArrayList<>();
saved.add("Playlist " + playlists.getString("playlist 1", "0"));
saved.add("Playlist " + playlists.getString("playlist 2", "0"));
saved.add("Playlist " + playlists.getString("playlist 3", "0"));
for (String s: saved) {
if(s.equals("Playlist 0")) {
saved.remove(s);
}
}
ListView listView = findViewById(R.id.listViewPlaylists);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, saved);
listView.setAdapter(adapter);
}
}
...@@ -21,7 +21,7 @@ public class ThaiAsyncTask extends AsyncTask<Void, Void, ArrayAdapter<String>> ...@@ -21,7 +21,7 @@ public class ThaiAsyncTask extends AsyncTask<Void, Void, ArrayAdapter<String>>
public ArrayList<String> attributesSong6 = new ArrayList<>(); public ArrayList<String> attributesSong6 = new ArrayList<>();
public ArrayList<String> attributesSong7 = new ArrayList<>(); public ArrayList<String> attributesSong7 = new ArrayList<>();
public ArrayList<String> songNamesList = new ArrayList<>(); public ArrayList<String> songNamesList = new ArrayList<>();
public String[] songNames = new String[20]; public String[] songNames = new String[8];
public ListView listView; public ListView listView;
public Context context; public Context context;
public databaseInterface.Cuisine cuisine; public databaseInterface.Cuisine cuisine;
......
...@@ -114,7 +114,6 @@ public class build_playlist extends AppCompatActivity { ...@@ -114,7 +114,6 @@ public class build_playlist extends AppCompatActivity {
public void buildPlaylistOnClick(View view) { public void buildPlaylistOnClick(View view) {
Intent intent = new Intent(this, playlistView.class); Intent intent = new Intent(this, playlistView.class);
intent.putExtra("vibe", vibe); intent.putExtra("vibe", vibe);
Log.d("VibeBitch!", vibe);
intent.putExtra("cuisine", cuisine); intent.putExtra("cuisine", cuisine);
intent.putExtra("timeofday", timeOfDay); intent.putExtra("timeofday", timeOfDay);
startActivity(intent); startActivity(intent);
......
...@@ -72,4 +72,9 @@ public class homeScreen extends AppCompatActivity { ...@@ -72,4 +72,9 @@ public class homeScreen extends AppCompatActivity {
Intent intent = new Intent(this, settings.class); Intent intent = new Intent(this, settings.class);
startActivity(intent); startActivity(intent);
} }
public void savedViewOnClick(View view) {
Intent intent = new Intent(this, SavedPlaylists.class);
startActivity(intent);
}
} }
...@@ -23,20 +23,6 @@ public class searchScreen extends AppCompatActivity { ...@@ -23,20 +23,6 @@ public class searchScreen extends AppCompatActivity {
public ListView songResults; public ListView songResults;
public ArrayAdapter<String> adapter; public ArrayAdapter<String> adapter;
public ArrayList<String> chineseResults;
public ArrayList<String> thaiResults;
public ArrayList<String> indianResults;
public ArrayList<String> japaneseResults;
public ArrayList<String> italianResults;
public ArrayList<String> mexicanResults;
public ArrayList<String> frenchResults;
public ArrayList<String> americanResults;
public ArrayList<String> chillResults;
public ArrayList<String> happyResults;
public ArrayList<String> energeticResults;
public Intent vibeView; public Intent vibeView;
@Override @Override
...@@ -60,68 +46,38 @@ public class searchScreen extends AppCompatActivity { ...@@ -60,68 +46,38 @@ public class searchScreen extends AppCompatActivity {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) { switch (position) {
case 0: case 0:
ChineseAsyncTask chineseAsyncTask = new ChineseAsyncTask(); tagNamePage("Chinese");
chineseAsyncTask.execute();
chineseResults = chineseAsyncTask.chineseResults;
tagNamePage("Chinese", chineseResults);
break; break;
case 1: case 1:
tagNamePage("Thai", thaiResults); tagNamePage("Thai");
break; break;
case 2: case 2:
IndianAsyncTask indianAsyncTask = new IndianAsyncTask(); tagNamePage("Indian");
indianAsyncTask.execute();
indianResults = indianAsyncTask.indianResults;
tagNamePage("Indian", indianResults);
break; break;
case 3: case 3:
JapaneseAsyncTask japaneseAsyncTask = new JapaneseAsyncTask(); tagNamePage("Japanese");
japaneseAsyncTask.execute();
japaneseResults = japaneseAsyncTask.japaneseResults;
tagNamePage("Japanese", japaneseResults);
break; break;
case 4: case 4:
ItalianAsyncTask italianAsyncTask = new ItalianAsyncTask(); tagNamePage("Italian");
italianAsyncTask.execute();
italianResults = italianAsyncTask.italianResults;
tagNamePage("Italian", italianResults);
break; break;
case 5: case 5:
MexicanAsyncTask mexicanAsyncTask = new MexicanAsyncTask(); tagNamePage("Mexican");
mexicanAsyncTask.execute();
mexicanResults = mexicanAsyncTask.mexicanResults;
tagNamePage("Mexican", mexicanResults);
break; break;
case 6: case 6:
FrenchAsyncTask frenchAsyncTask = new FrenchAsyncTask(); tagNamePage("French");
frenchAsyncTask.execute();
frenchResults = frenchAsyncTask.frenchResults;
tagNamePage("French", frenchResults);
break; break;
case 7: case 7:
AmericanAsyncTask americanAsyncTask = new AmericanAsyncTask(); tagNamePage("American");
americanAsyncTask.execute();
americanResults = americanAsyncTask.americanResults;
tagNamePage("American", americanResults);
break; break;
case 8: case 8:
ChillAsyncTask chillAsyncTask = new ChillAsyncTask(); // tagNamePage("Chill");
chillAsyncTask.execute(); // break;
chillResults = chillAsyncTask.chillResults;
tagNamePage("Chill", chillResults);
break;
case 9: case 9:
HappyAsyncTask happyAsyncTask = new HappyAsyncTask(); //tagNamePage("Happy");
happyAsyncTask.execute(); //break;
happyResults = happyAsyncTask.happyResults;
tagNamePage("Happy", happyResults);
break;
case 10: case 10:
EnergeticAsyncTask energeticAsyncTask = new EnergeticAsyncTask(); //tagNamePage("energetic");
energeticAsyncTask.execute(); //break;
energeticResults = energeticAsyncTask.energeticResults;
tagNamePage("energetic", energeticResults);
break;
} }
} }
...@@ -131,12 +87,11 @@ public class searchScreen extends AppCompatActivity { ...@@ -131,12 +87,11 @@ public class searchScreen extends AppCompatActivity {
} }
public void tagNamePage(String tagNameMethod, ArrayList<String> results) { public void tagNamePage(String tagNameMethod) {
String tagView = "Songs with '" + tagNameMethod +"' Tag"; String tagView = "Songs with '" + tagNameMethod +"' Tag";
vibeView = new Intent(searchScreen.this, swtViewScreen.class); vibeView = new Intent(searchScreen.this, swtViewScreen.class);
vibeView.putExtra("tag_name", tagView); vibeView.putExtra("tag_name", tagView);
vibeView.putExtra("tag_name_selected", tagNameMethod); vibeView.putExtra("tag_name_selected", tagNameMethod);
vibeView.putExtra("array_list",results);
startActivity(vibeView); startActivity(vibeView);
} }
......
...@@ -2,6 +2,7 @@ package com.example.soulfood_assignment2; ...@@ -2,6 +2,7 @@ package com.example.soulfood_assignment2;
import android.R.layout; import android.R.layout;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.provider.MediaStore; import android.provider.MediaStore;
...@@ -71,4 +72,9 @@ public class settings extends AppCompatActivity { ...@@ -71,4 +72,9 @@ public class settings extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
} }
public void homeScreenViewOnClick(View view) {
Intent intent = new Intent(this, homeScreen.class);
startActivity(intent);
}
} }
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:layout_marginBottom="100dp" android:layout_marginBottom="100dp"
android:onClick="savedPlaylistViewOnClick" android:onClick="savedViewOnClick"
android:text="SAVED PLAYLISTS" android:text="SAVED PLAYLISTS"
android:textColor="#000000" android:textColor="#000000"
android:textSize="24sp" android:textSize="24sp"
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.soulfood_assignment2.SavedPlaylistView">
<ListView
android:id="@+id/savedPlaylists"
android:layout_width="wrap_content"
android:layout_height="500dp"
android:layout_marginTop="76dp"
android:layout_marginBottom="77dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView9"></ListView>
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="28dp"
android:text="SoulFood"
android:textColor="#000000"
android:textSize="36sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.soulfood_assignment2.SavedPlaylists">
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="Saved Playlists"
app:layout_constraintBottom_toTopOf="@+id/_dynamic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.51" />
<ListView
android:id="@+id/listViewPlaylists"
android:layout_width="395dp"
android:layout_height="640dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView10" />
</android.support.constraint.ConstraintLayout>
...@@ -10,11 +10,7 @@ ...@@ -10,11 +10,7 @@
android:id="@+id/factorySettings" android:id="@+id/factorySettings"
android:layout_width="309dp" android:layout_width="309dp"
android:layout_height="41dp" android:layout_height="41dp"
android:layout_marginStart="62dp" android:layout_marginBottom="296dp"
android:layout_marginLeft="62dp"
android:layout_marginEnd="44dp"
android:layout_marginRight="44dp"
android:layout_marginBottom="50dp"
android:text="Test" android:text="Test"
android:textColor="#000000" android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
...@@ -42,11 +38,9 @@ ...@@ -42,11 +38,9 @@
android:layout_height="25dp" android:layout_height="25dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginTop="80dp" android:layout_marginTop="140dp"
android:layout_marginEnd="22dp" android:layout_marginEnd="22dp"
android:layout_marginRight="22dp" android:layout_marginRight="22dp"
android:layout_marginBottom="478dp"
app:layout_constraintBottom_toTopOf="@+id/factorySettings"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView12" app:layout_constraintStart_toEndOf="@+id/textView12"
app:layout_constraintTop_toBottomOf="@+id/textView11" /> app:layout_constraintTop_toBottomOf="@+id/textView11" />
...@@ -57,15 +51,24 @@ ...@@ -57,15 +51,24 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="32dp" android:layout_marginStart="32dp"
android:layout_marginLeft="32dp" android:layout_marginLeft="32dp"
android:layout_marginTop="80dp" android:layout_marginTop="144dp"
android:layout_marginEnd="60dp" android:layout_marginEnd="60dp"
android:layout_marginRight="60dp" android:layout_marginRight="60dp"
android:layout_marginBottom="484dp"
android:text="Volume" android:text="Volume"
android:textColor="#000000" android:textColor="#000000"
app:layout_constraintBottom_toTopOf="@+id/factorySettings"
app:layout_constraintEnd_toStartOf="@+id/seekBar" app:layout_constraintEnd_toStartOf="@+id/seekBar"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView11" /> app:layout_constraintTop_toBottomOf="@+id/textView11" />
<Button
android:id="@+id/homeScreenView"
android:layout_width="310dp"
android:layout_height="48dp"
android:layout_marginBottom="200dp"
android:onClick="homeScreenViewOnClick"
android:text="Back to home"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
\ No newline at end of file
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