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 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
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=".playlistView" />
<activity android:name=".SavedPlaylists" />
......
......@@ -12,7 +12,7 @@ public class Listener implements View.OnClickListener {
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);
}
}
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>>
public ArrayList<String> attributesSong6 = new ArrayList<>();
public ArrayList<String> attributesSong7 = new ArrayList<>();
public ArrayList<String> songNamesList = new ArrayList<>();
public String[] songNames = new String[20];
public String[] songNames = new String[8];
public ListView listView;
public Context context;
public databaseInterface.Cuisine cuisine;
......
......@@ -114,7 +114,6 @@ public class build_playlist extends AppCompatActivity {
public void buildPlaylistOnClick(View view) {
Intent intent = new Intent(this, playlistView.class);
intent.putExtra("vibe", vibe);
Log.d("VibeBitch!", vibe);
intent.putExtra("cuisine", cuisine);
intent.putExtra("timeofday", timeOfDay);
startActivity(intent);
......
......@@ -72,4 +72,9 @@ public class homeScreen extends AppCompatActivity {
Intent intent = new Intent(this, settings.class);
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 {
public ListView songResults;
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;
@Override
......@@ -60,68 +46,38 @@ public class searchScreen extends AppCompatActivity {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
ChineseAsyncTask chineseAsyncTask = new ChineseAsyncTask();
chineseAsyncTask.execute();
chineseResults = chineseAsyncTask.chineseResults;
tagNamePage("Chinese", chineseResults);
tagNamePage("Chinese");
break;
case 1:
tagNamePage("Thai", thaiResults);
tagNamePage("Thai");
break;
case 2:
IndianAsyncTask indianAsyncTask = new IndianAsyncTask();
indianAsyncTask.execute();
indianResults = indianAsyncTask.indianResults;
tagNamePage("Indian", indianResults);
tagNamePage("Indian");
break;
case 3:
JapaneseAsyncTask japaneseAsyncTask = new JapaneseAsyncTask();
japaneseAsyncTask.execute();
japaneseResults = japaneseAsyncTask.japaneseResults;
tagNamePage("Japanese", japaneseResults);
tagNamePage("Japanese");
break;
case 4:
ItalianAsyncTask italianAsyncTask = new ItalianAsyncTask();
italianAsyncTask.execute();
italianResults = italianAsyncTask.italianResults;
tagNamePage("Italian", italianResults);
tagNamePage("Italian");
break;
case 5:
MexicanAsyncTask mexicanAsyncTask = new MexicanAsyncTask();
mexicanAsyncTask.execute();
mexicanResults = mexicanAsyncTask.mexicanResults;
tagNamePage("Mexican", mexicanResults);
tagNamePage("Mexican");
break;
case 6:
FrenchAsyncTask frenchAsyncTask = new FrenchAsyncTask();
frenchAsyncTask.execute();
frenchResults = frenchAsyncTask.frenchResults;
tagNamePage("French", frenchResults);
tagNamePage("French");
break;
case 7:
AmericanAsyncTask americanAsyncTask = new AmericanAsyncTask();
americanAsyncTask.execute();
americanResults = americanAsyncTask.americanResults;
tagNamePage("American", americanResults);
tagNamePage("American");
break;
case 8:
ChillAsyncTask chillAsyncTask = new ChillAsyncTask();
chillAsyncTask.execute();
chillResults = chillAsyncTask.chillResults;
tagNamePage("Chill", chillResults);
break;
// tagNamePage("Chill");
// break;
case 9:
HappyAsyncTask happyAsyncTask = new HappyAsyncTask();
happyAsyncTask.execute();
happyResults = happyAsyncTask.happyResults;
tagNamePage("Happy", happyResults);
break;
//tagNamePage("Happy");
//break;
case 10:
EnergeticAsyncTask energeticAsyncTask = new EnergeticAsyncTask();
energeticAsyncTask.execute();
energeticResults = energeticAsyncTask.energeticResults;
tagNamePage("energetic", energeticResults);
break;
//tagNamePage("energetic");
//break;
}
}
......@@ -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";
vibeView = new Intent(searchScreen.this, swtViewScreen.class);
vibeView.putExtra("tag_name", tagView);
vibeView.putExtra("tag_name_selected", tagNameMethod);
vibeView.putExtra("array_list",results);
startActivity(vibeView);
}
......
......@@ -2,6 +2,7 @@ package com.example.soulfood_assignment2;
import android.R.layout;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.provider.MediaStore;
......@@ -71,4 +72,9 @@ public class settings extends AppCompatActivity {
e.printStackTrace();
}
}
public void homeScreenViewOnClick(View view) {
Intent intent = new Intent(this, homeScreen.class);
startActivity(intent);
}
}
......@@ -50,7 +50,7 @@
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="100dp"
android:onClick="savedPlaylistViewOnClick"
android:onClick="savedViewOnClick"
android:text="SAVED PLAYLISTS"
android:textColor="#000000"
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 @@
android:id="@+id/factorySettings"
android:layout_width="309dp"
android:layout_height="41dp"
android:layout_marginStart="62dp"
android:layout_marginLeft="62dp"
android:layout_marginEnd="44dp"
android:layout_marginRight="44dp"
android:layout_marginBottom="50dp"
android:layout_marginBottom="296dp"
android:text="Test"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
......@@ -42,11 +38,9 @@
android:layout_height="25dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="80dp"
android:layout_marginTop="140dp"
android:layout_marginEnd="22dp"
android:layout_marginRight="22dp"
android:layout_marginBottom="478dp"
app:layout_constraintBottom_toTopOf="@+id/factorySettings"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView12"
app:layout_constraintTop_toBottomOf="@+id/textView11" />
......@@ -57,15 +51,24 @@
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="80dp"
android:layout_marginTop="144dp"
android:layout_marginEnd="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="484dp"
android:text="Volume"
android:textColor="#000000"
app:layout_constraintBottom_toTopOf="@+id/factorySettings"
app:layout_constraintEnd_toStartOf="@+id/seekBar"
app:layout_constraintStart_toStartOf="parent"
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>
\ 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