Skip to content
Snippets Groups Projects
Commit 12878762 authored by Shaobo Xu's avatar Shaobo Xu
Browse files

cancel replacing events by adding new events

parent d3627bde
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,8 @@ import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.icu.util.GregorianCalendar;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
......@@ -17,10 +19,10 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.tabs.TabLayout;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;
public class MainActivity extends AppCompatActivity implements CustomAdapter.ItemClickListener {
public CustomAdapter popAdapter;
......@@ -33,6 +35,8 @@ public class MainActivity extends AppCompatActivity implements CustomAdapter.Ite
private int currentTabPosition = 0; //Initial tab position
private Event event;
GregorianCalendar startDate, endDate;
private EventRestoSuperClass eventRestoSelected = null;
......@@ -59,14 +63,19 @@ public class MainActivity extends AppCompatActivity implements CustomAdapter.Ite
if (additionEvent==null){
additionEvent= new ArrayList<String>();
additionEvent.add("1");
additionEvent.add("No Review");
additionEvent.add("This for nothing");
additionEvent.add(2,"3");
additionEvent.add(3,"2");
additionEvent.add(4,"2022");
additionEvent.add(5,"University of Saskatchewan");
additionEvent.add(6,"This is a description");
}
mModel = new Model(this.getApplication(), mUser,additionEvent);
startDate = new GregorianCalendar(Integer.valueOf(additionEvent.get(4)),Integer.valueOf(additionEvent.get(3)),Integer.valueOf(additionEvent.get(2)));
endDate = new GregorianCalendar(Integer.valueOf(additionEvent.get(4)),Integer.valueOf(additionEvent.get(3)),Integer.valueOf(additionEvent.get(2))+1);
event = new Event(additionEvent.get(1),startDate,endDate,additionEvent.get(5),additionEvent.get(6),new String[]{"twitter", "facebook", "discord"}, null , null, "sometime for new event.");
mModel = new Model(this.getApplication(), mUser,event);
......
......@@ -39,12 +39,12 @@ public class Model {
public Model(@NonNull Application app, User u, ArrayList<String> new_event) {
public Model(@NonNull Application app, User u, Event new_event) {
user = u;
application = app;
restaurants = new EventRestoList();
popList = createFakeList("A",new_event);
curList = createFakeList("B", new_event);
curList = createFakeList("B",new_event);
// Initialize with poplist, controller looks up id to see if the event is still in the list
pinController = new PinController(u, popList);
......@@ -129,12 +129,12 @@ public class Model {
}
return eList;
}
private EventRestoList createFakeList(String s, ArrayList<String> new_event) {
private EventRestoList createFakeList(String s, Event new_event) {
Resources res = application.getResources(); // Needed to get image_file //TODO
Drawable drawable = ResourcesCompat.getDrawable(res, R.drawable.no_image, null);
EventRestoList eList = new EventRestoList();
for (int i = 0; i < 9; i++){
for (int i = 0; i < 10; i++){
String name = s+i + "Name";
GregorianCalendar sDate = new GregorianCalendar(2022,i,i);
GregorianCalendar eDate = new GregorianCalendar(2022,i,i+1);
......@@ -144,12 +144,17 @@ public class Model {
event.addReview(new Review(new User(),"This is great!", 5));
eList.addItem(event);
}
GregorianCalendar sDate = new GregorianCalendar(Integer.valueOf(new_event.get(4)),Integer.valueOf(new_event.get(3)),Integer.valueOf(new_event.get(2)));
GregorianCalendar eDate = new GregorianCalendar(Integer.valueOf(new_event.get(4)),Integer.valueOf(new_event.get(3)),Integer.valueOf(new_event.get(2))+1);
Event event = new Event(new_event.get(1),sDate, eDate , new_event.get(5), new_event.get(6), new String[]{"twitter", "facebook", "discord"}, new String[]{getRandomTag(), getRandomTag()}, new Drawable[]{drawable}, "Firefox Inc.");
String name = "No Review";
GregorianCalendar sDate = new GregorianCalendar(2022,2,3);
GregorianCalendar eDate = new GregorianCalendar(2022,2,4);
String location = "University of Saskatchewan";
Event event = new Event(name,sDate, eDate , location, "This is a description", new String[]{"twitter", "facebook", "discord"}, new String[]{getRandomTag(), getRandomTag()}, new Drawable[]{drawable}, "Firefox Inc.");
eList.addItem(event);
if (s=="A"){
new_event.setTags(new String[]{getRandomTag(), getRandomTag()});
new_event.setPictures(new Drawable[]{drawable});
eList.addItem(new_event);
}
return eList;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment