Commit 06f709c7 authored by charley.punshon's avatar charley.punshon

Half working build playlist feature.

parent e18aa589
This diff is collapsed.
......@@ -22,12 +22,18 @@ public class ThaiAsyncTask extends AsyncTask<Void, Void, ArrayAdapter<String>>
public ArrayList<String> attributesSong7 = new ArrayList<>();
public ArrayList<String> songNamesList = new ArrayList<>();
public String[] songNames = new String[7];
public String test;
public ListView listView;
public Context context;
public databaseInterface.Cuisine cuisine;
public databaseInterface.Vibe vibe;
public databaseInterface.Time time;
public ThaiAsyncTask(Context context, databaseInterface.Cuisine cuisine, databaseInterface.Time time, databaseInterface.Vibe vibe) {
public ThaiAsyncTask(Context context) {
this.context = context;
this.cuisine = cuisine;
this.vibe = vibe;
this.time = time;
}
......@@ -37,7 +43,7 @@ public class ThaiAsyncTask extends AsyncTask<Void, Void, ArrayAdapter<String>>
try {
databaseInterface dbi = new databaseInterface();
thaiResults = dbi.getPlaylistByAttributes(databaseInterface.Cuisine.thai, databaseInterface.Vibe.any, databaseInterface.Time.any);
thaiResults = dbi.getPlaylistByAttributes(cuisine, vibe, time);
for(int i = 0; i < thaiResults.size(); i++) {
songNames[i] = dbi.getSongTitle(thaiResults.get(i));
}
......
......@@ -3,37 +3,120 @@ package com.example.soulfood_assignment2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import java.lang.reflect.Array;
import java.util.ArrayList;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.american;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.any;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.chinese;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.french;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.indian;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.italian;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.thai;
import static com.example.soulfood_assignment2.databaseInterface.Vibe.calming;
import static com.example.soulfood_assignment2.databaseInterface.Vibe.chill;
import static com.example.soulfood_assignment2.databaseInterface.Vibe.energetic;
public class build_playlist extends AppCompatActivity {
String vibe;
String cuisine;
String timeOfDay;
databaseInterface.Cuisine cuisineTag;
databaseInterface.Vibe vibeTag;
databaseInterface.Time timeTag;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.build_playlist);
String[] vibes = new String[] {"None", "Chilled", "Energetic", "Relaxing"};
ArrayList<String> vibes = new ArrayList<>();
vibes.add("any");
vibes.add("chilled");
vibes.add("energetic");
vibes.add("relaxing");
Spinner vibesSpinner = findViewById(R.id.vibe_dropdown);
ArrayAdapter<String> vibesAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, vibes);
vibesSpinner.setAdapter(vibesAdapter);
String[] cuisines = new String[] {"None", "Chinese", "Thai", "Indian", "Italian", "American", "French", "Spanish"};
vibesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
vibe = vibes.get(position);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
ArrayList<String> cuisines = new ArrayList<>();
cuisines.add("any");
cuisines.add("chinese");
cuisines.add("thai");
cuisines.add("indian");
cuisines.add("italian");
cuisines.add("american");
cuisines.add("french");
cuisines.add("spanish");
Spinner cuisineSpinner = findViewById(R.id.cuisine_dropdown);
ArrayAdapter<String> cuisineAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, cuisines);
cuisineSpinner.setAdapter(cuisineAdapter);
String[] timeOfDay = new String[] {"None", "Breakfast", "Lunch", "Dinner"};
cuisineSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
cuisine = cuisines.get(position);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
ArrayList<String> timeOfDays = new ArrayList<>();
timeOfDays.add("any");
timeOfDays.add("breakfast");
timeOfDays.add("lunch");
timeOfDays.add("dinner");
Spinner timeOfDaySpinner = findViewById(R.id.tod_dropdown);
ArrayAdapter<String> timeOfDayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, timeOfDay);
ArrayAdapter<String> timeOfDayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, timeOfDays);
timeOfDaySpinner.setAdapter(timeOfDayAdapter);
cuisineSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
timeOfDay = timeOfDays.get(position);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
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);
}
......
......@@ -2,12 +2,93 @@ package com.example.soulfood_assignment2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.american;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.any;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.chinese;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.french;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.indian;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.italian;
import static com.example.soulfood_assignment2.databaseInterface.Cuisine.thai;
import static com.example.soulfood_assignment2.databaseInterface.Time.breakfast;
import static com.example.soulfood_assignment2.databaseInterface.Time.dinner;
import static com.example.soulfood_assignment2.databaseInterface.Time.lunch;
import static com.example.soulfood_assignment2.databaseInterface.Vibe.calming;
import static com.example.soulfood_assignment2.databaseInterface.Vibe.chill;
import static com.example.soulfood_assignment2.databaseInterface.Vibe.energetic;
public class playlistView extends AppCompatActivity {
databaseInterface.Cuisine cuisineTag;
databaseInterface.Vibe vibeTag;
databaseInterface.Time timeTag;
ListView playlistView;
String cuisine;
String vibe;
String timeOfDay;
String anyVibe = "any";
String anyTime = "any";
String anyCuisine = "any";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playlist_view);
cuisine = getIntent().getStringExtra("cuisine");
vibe = getIntent().getStringExtra("vibe");
timeOfDay = getIntent().getStringExtra("timeofday");
if(cuisine == null) {
cuisineTag = any;
} else if(cuisine.equalsIgnoreCase(anyCuisine)) {
cuisineTag = any;
} else if(cuisine.equalsIgnoreCase("chinese")) {
cuisineTag = chinese;
} else if(cuisine.equalsIgnoreCase("thai")) {
cuisineTag = thai;
} else if(cuisine.equalsIgnoreCase("indian")) {
cuisineTag = indian;
} else if(cuisine.equalsIgnoreCase("italian")) {
cuisineTag = italian;
} else if(cuisine.equalsIgnoreCase("american")) {
cuisineTag = american;
} else if(cuisine.equalsIgnoreCase("french")) {
cuisineTag = french;
}
if(vibe == null) {
vibeTag = databaseInterface.Vibe.any;
} else if(vibe.equalsIgnoreCase(anyVibe)) {
vibeTag = databaseInterface.Vibe.any;
} else if(vibe.equalsIgnoreCase("chilled")) {
vibeTag = chill;
} else if(vibe.equalsIgnoreCase("energetic")) {
vibeTag = energetic;
} else if(vibe.equalsIgnoreCase("relaxed")) {
vibeTag = calming;
}
if(timeOfDay == null) {
timeTag = databaseInterface.Time.any;
} else if(timeOfDay.equalsIgnoreCase(anyTime)) {
timeTag = databaseInterface.Time.any;
} else if(timeOfDay.equalsIgnoreCase("breakfast")) {
timeTag = breakfast;
} else if(timeOfDay.equalsIgnoreCase("lunch")) {
timeTag = lunch;
} else if(timeOfDay.equalsIgnoreCase("dinner")) {
timeTag = dinner;
}
ThaiAsyncTask thaiAsyncTask = new ThaiAsyncTask(this, cuisineTag, timeTag, vibeTag);
thaiAsyncTask.listView = findViewById(R.id.playlistView);
thaiAsyncTask.execute();
playlistView = thaiAsyncTask.listView;
}
}
......@@ -29,10 +29,6 @@ public class settings extends AppCompatActivity {
setContentView(R.layout.activity_settings);
initControls();
Integer[] textSize = new Integer[] {18, 20, 24}; // get off Jade
Spinner eqSpinner = findViewById(R.id.eq_dropdown);
ArrayAdapter<Integer> spinnerAdapter = new ArrayAdapter<>(this, simple_spinner_dropdown_item, textSize);
eqSpinner.setAdapter(spinnerAdapter);
final MediaPlayer mp = MediaPlayer.create(this, R.raw.beepsoundeffect);
Button revertToFactorySettings = findViewById(R.id.factorySettings);
......
......@@ -142,7 +142,7 @@ public class swtViewScreen extends AppCompatActivity {
});
} else if(tagNameView.getText().toString().equals("Songs with 'Thai' Tag")) {
ThaiAsyncTask thaiAsyncTask = new ThaiAsyncTask(swtViewScreen.this);
ThaiAsyncTask thaiAsyncTask = new ThaiAsyncTask(swtViewScreen.this, databaseInterface.Cuisine.thai, databaseInterface.Time.any, databaseInterface.Vibe.any);
thaiAsyncTask.listView = findViewById(R.id.charleyNeedsHelp);
thaiAsyncTask.execute();
tagResults = thaiAsyncTask.listView;
......
......@@ -12,99 +12,14 @@
android:layout_height="41dp"
android:layout_marginStart="62dp"
android:layout_marginLeft="62dp"
android:layout_marginTop="104dp"
android:layout_marginEnd="44dp"
android:layout_marginRight="44dp"
android:layout_marginBottom="41dp"
android:layout_marginBottom="50dp"
android:text="Test"
android:textColor="#000000"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/occasion_dropdown4" />
<Spinner
android:id="@+id/occasion_dropdown4"
android:layout_width="247dp"
android:layout_height="30dp"
android:layout_marginStart="59dp"
android:layout_marginLeft="59dp"
android:layout_marginTop="42dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:background="?android:attr/colorButtonNormal"
android:spinnerMode="dropdown"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/textView15"
app:layout_constraintTop_toBottomOf="@+id/textsizeDropdown" />
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="28dp"
android:layout_marginLeft="28dp"
android:layout_marginTop="52dp"
android:text="Colour Blind"
android:textColor="#000000"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView14" />
<Spinner
android:id="@+id/textsizeDropdown"
android:layout_width="247dp"
android:layout_height="30dp"
android:layout_marginStart="58dp"
android:layout_marginLeft="58dp"
android:layout_marginTop="42dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:background="?android:attr/colorButtonNormal"
android:spinnerMode="dropdown"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView14"
app:layout_constraintTop_toBottomOf="@+id/eq_dropdown" />
<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="29dp"
android:layout_marginLeft="29dp"
android:layout_marginTop="42dp"
android:text="Text Size"
android:textColor="#000000"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView13" />
<Spinner
android:id="@+id/eq_dropdown"
android:layout_width="247dp"
android:layout_height="30dp"
android:layout_marginStart="95dp"
android:layout_marginLeft="95dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:background="?android:attr/colorButtonNormal"
android:spinnerMode="dropdown"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.95"
app:layout_constraintStart_toEndOf="@+id/textView13"
app:layout_constraintTop_toBottomOf="@+id/seekBar" />
<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="44dp"
android:layout_marginLeft="44dp"
android:layout_marginTop="48dp"
android:text="EQ"
android:textColor="#000000"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView12" />
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textView11"
......@@ -127,9 +42,11 @@
android:layout_height="25dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="16dp"
android:layout_marginTop="80dp"
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" />
......@@ -140,30 +57,15 @@
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="25dp"
android:layout_marginTop="80dp"
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/button"
android:layout_width="303dp"
android:layout_height="36dp"
android:layout_marginStart="62dp"
android:layout_marginLeft="62dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="44dp"
android:layout_marginRight="44dp"
android:layout_marginBottom="200dp"
android:text="Apply"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/factorySettings"
app:layout_constraintVertical_bias="1.0" />
</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