Skip to content

Commit

Permalink
Merge pull request #35 from Bouquet2/develop
Browse files Browse the repository at this point in the history
Merge for alpha release
  • Loading branch information
vbouquet authored Mar 19, 2017
2 parents ec8a967 + d9d95b8 commit 2ce0033
Show file tree
Hide file tree
Showing 35 changed files with 666 additions and 323 deletions.
16 changes: 11 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@
<activity android:name=".ui.activites.LoginActivity" />
<activity android:name=".ui.activites.AssociationDashboardActivity" />
<activity android:name=".ui.activites.AgendaGeneratorActivity" />
<activity android:name=".ui.activites.AgendaActivity"/>
<activity android:name=".ui.activites.AgendaActivity" />
<activity android:name=".ui.activites.AgendaActivity" />
<activity android:name=".ui.activites.ListEventsActivity" />
<activity android:name=".ui.activites.EventInfosActivity"/>
<activity android:name=".ui.activites.CreateEventActivity"/>
<activity android:name=".ui.activites.EventResearchActivity"/>
<activity android:name=".ui.activites.ListAssociationActivity"></activity>
<activity android:name=".ui.activites.EventInfosActivity" />
<activity android:name=".ui.activites.EventResearchActivity" />
<activity android:name=".ui.activites.ShowAssociationActivity" />
<activity android:name=".ui.activites.EventInfosActivity" />
<activity android:name=".ui.activites.CreateEventActivity" />
<activity android:name=".ui.activites.EventResearchActivity" />
<activity android:name=".ui.activites.ListAssociationActivity" />
<activity android:name=".ui.activites.MainAssociationActivity" />
<activity android:name=".ui.activites.MainEventActivity"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
import java.util.HashMap;
import java.util.Map;

/**
* Created by wilpiron on 28/02/2017.
*/

public class Event {

public String id;
public String name;
public String start;
Expand All @@ -35,8 +30,8 @@ public class Event {
public Event(){
}

public Event(String uid, String name, String start, String end, String type, String association,
String description, String location, float price, int bail, int seat_number, int logo){
public Event(String uid,String name, String start, String end, String type, String description, String location,
float price, int bail, int seat_number, String association, int logo){
this.uid=uid;
this.name=name;
this.start=start;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package fr.paris10.projet.assogenda.assogenda.ui.activites;

import android.app.AlertDialog;
Expand Down Expand Up @@ -38,21 +39,25 @@ public class CreateEventActivity extends AppCompatActivity {
protected EditText eventLocationEditText;
protected EditText eventSeatsAvailableEditText;
protected EditText eventPriceEditText;
protected Button eventAdvancedButton;

protected DatabaseReference database = FirebaseDatabase.getInstance().getReference("events");


protected DatabaseReference dbAssoc = FirebaseDatabase.getInstance().getReference("associations");
protected String eventAsso;

protected Calendar c;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_event);
eventAsso = getIntent().getStringExtra("assoID");


//Initialization
c = Calendar.getInstance();
eventNameEditText = (EditText) findViewById(R.id.activity_create_event_name);
eventStartTimeEditText = (EditText) findViewById(R.id.activity_create_event_start_time);
eventStartDateEditText = (EditText) findViewById(R.id.activity_create_event_start_date);
Expand All @@ -64,6 +69,20 @@ protected void onCreate(Bundle savedInstanceState) {
eventLocationEditText = (EditText) findViewById(R.id.activity_create_event_location);
eventSeatsAvailableEditText = (EditText) findViewById(R.id.activity_create_event_seats_available);
eventPriceEditText = (EditText) findViewById(R.id.activity_create_event_price);
eventAdvancedButton = (Button) findViewById(R.id.activity_create_event_advanced_button);

//Hide advanced options
eventPriceEditText.setVisibility(View.GONE);
eventSeatsAvailableEditText.setVisibility(View.GONE);
eventDescriptionEditText.setVisibility(View.GONE);

//Default value (date and time)
eventStartDateEditText.setText(new SimpleDateFormat("dd/MM/yyyy").format(c.getTime()));
eventStartTimeEditText.setText(new SimpleDateFormat("kk:mm").format(c.getTime()));
eventEndDateEditText.setText(new SimpleDateFormat("dd/MM/yyyy").format(c.getTime()));
c.setTime(c.getTime());
c.add(Calendar.HOUR, 1);
eventEndTimeEditText.setText(new SimpleDateFormat("kk:mm").format(c.getTime()));

//Sets the spinner's content
ArrayAdapter<CharSequence> tmpAdapterEventTypes = ArrayAdapter.createFromResource(this,R.array.event_create_event_types, android.R.layout.simple_spinner_item);
Expand Down Expand Up @@ -98,6 +117,21 @@ public void onClick(View v) {
}
});

eventAdvancedButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (eventPriceEditText.getVisibility() == View.GONE){
eventPriceEditText.setVisibility(View.VISIBLE);
eventSeatsAvailableEditText.setVisibility(View.VISIBLE);
eventDescriptionEditText.setVisibility(View.VISIBLE);
}
else{
eventPriceEditText.setVisibility(View.GONE);
eventSeatsAvailableEditText.setVisibility(View.GONE);
eventDescriptionEditText.setVisibility(View.GONE);
}
}
});



Expand All @@ -108,32 +142,30 @@ public void onClick(View v) {
final String eventStart = eventDatesConverter(eventStartTimeEditText, eventStartDateEditText);
final String eventEnd = eventDatesConverter(eventEndTimeEditText, eventEndDateEditText);
final String eventType = eventTypeSpinner.getItemAtPosition(eventTypeSpinner.getSelectedItemPosition()).toString().trim();
final String eventDescription = eventDescriptionEditText.getText().toString().trim();
String eventDescription = eventDescriptionEditText.getText().toString().trim();
final String eventLocation = eventLocationEditText.getText().toString().trim();
final String eventSeatsAvailable = eventSeatsAvailableEditText.getText().toString().trim();
final String eventPrice = eventPriceEditText.getText().toString().trim();
String eventSeatsAvailable = eventSeatsAvailableEditText.getText().toString().trim();
String eventPrice = eventPriceEditText.getText().toString().trim();
final String eventAssociation = eventAsso;

if (eventName.isEmpty() || eventDescription.isEmpty() || eventStart == null || eventEnd == null
|| eventType.isEmpty() || eventLocation.isEmpty() || eventSeatsAvailable.isEmpty() || eventPrice.isEmpty()) {
AlertDialog.Builder builder = new AlertDialog.Builder(CreateEventActivity.this);
builder.setMessage(R.string.event_create_submit_error_message)
.setTitle(R.string.event_create_submit_error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
//Checking value of optional fields
if (eventDescription.isEmpty()){
eventDescription = "";
}
else if (Integer.parseInt(eventSeatsAvailable) < 5){
AlertDialog.Builder builder = new AlertDialog.Builder(CreateEventActivity.this);
builder.setMessage(R.string.event_create_submit_seats_error_message)
.setTitle(R.string.event_create_submit_error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
//Value to -1 means there are no seats limit
if (eventSeatsAvailable.isEmpty()){
eventSeatsAvailable = "-1";
}
//Value to -1 means there are no price, it's free
if (eventPrice.isEmpty()){
eventPrice = "-1.0";
}
else if(Float.parseFloat(eventPrice) < 0.0){

// NOTE : SEATS / PRICE / DESCRIPTION => OPTIONAL

if (eventName.isEmpty() || eventStart == null || eventEnd == null || eventType.isEmpty() || eventLocation.isEmpty() ) {
AlertDialog.Builder builder = new AlertDialog.Builder(CreateEventActivity.this);
builder.setMessage(R.string.event_create_submit_price_error_message)
builder.setMessage(R.string.event_create_submit_error_message)
.setTitle(R.string.event_create_submit_error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
Expand All @@ -151,7 +183,7 @@ else if (!firstDateAnteriorToSecond(eventStart, eventEnd)){
database.push()
.setValue(new Event( "", eventName, eventStart, eventEnd, eventType, eventAssociation, eventLocation,
Float.parseFloat(eventPrice), Integer.parseInt(eventSeatsAvailable), eventDescription)
.toMap());
.toMap());
loadMain();
}
}
Expand Down Expand Up @@ -233,4 +265,4 @@ public void loadMain(){
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.widget.Toast;

import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
Expand All @@ -24,29 +26,37 @@
import java.util.HashMap;

import fr.paris10.projet.assogenda.assogenda.R;
import fr.paris10.projet.assogenda.assogenda.model.Association;
import fr.paris10.projet.assogenda.assogenda.model.Event;

/**
* Event infos page, display event infos.
*/
public class EventInfosActivity extends AppCompatActivity {

private ArrayList<HashMap<String, Object>> listValues = new ArrayList<>();
public class EventInfosActivity extends AppCompatActivity {
private ListView listInfos;
private ArrayList<HashMap<String,Object>> listValues = new ArrayList<>();
private SimpleAdapter adapter;
private String eventUID;
private Event event;
private TextView nameEvent;
private TextView nameAsso;
private FirebaseAuth mFirebaseAuth;
private FirebaseUser mFirebaseUser;
private String name;
private Date eventEndDate;
private TextView participateButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseUser = mFirebaseAuth.getCurrentUser();
setContentView(R.layout.activity_event_infos);
eventUID = (String) getIntent().getExtras().get("eventUID");
name = (String) getIntent().getExtras().get("eventName");
String eventEnd = (String) getIntent().getExtras().get("eventEndDate");
nameEvent = (TextView) findViewById(R.id.activity_event_infos_name_event);
participateButton = (Button) findViewById(R.id.activity_event_infos_participate_button);
nameAsso = (TextView) findViewById(R.id.activity_event_infos_name_asso);

loadEventInfoInBackground();

try {
Expand Down Expand Up @@ -139,53 +149,68 @@ public void loadEventInfoInBackground() {
reference.child(eventUID).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Event event;
SimpleAdapter adapter;
ListView listInfos;

event = dataSnapshot.getValue(Event.class);
event.uid = eventUID;
nameEvent.setText(event.name);
HashMap<String, Object> hashMapValueDateBegin = new HashMap<>();
hashMapValueDateBegin.put("title_info", "Date de début : ");
hashMapValueDateBegin.put("content_info", event.start);
HashMap<String, Object> hashMapValueDateEnd = new HashMap<>();
hashMapValueDateEnd.put("title_info", "Date de fin : ");
hashMapValueDateEnd.put("content_info", event.end);
HashMap<String, Object> hashMapValuePrice = new HashMap<>();
hashMapValuePrice.put("title_info", "Prix : ");
hashMapValuePrice.put("content_info", event.price);
HashMap<String, Object> hashMapValueSpace = new HashMap<>();
hashMapValueSpace.put("title_info", "Places disponible : ");
hashMapValueSpace.put("content_info", String.valueOf(dataSnapshot.child("seats free").getValue()));
HashMap<String, Object> hashMapValueBail = new HashMap<>();
hashMapValueBail.put("title_info", "Caution : ");
hashMapValueBail.put("content_info", event.bail);
HashMap<String, Object> hashMapValuePlace = new HashMap<>();
hashMapValuePlace.put("title_info", "Lieu : ");
hashMapValuePlace.put("content_info", event.location);
HashMap<String, Object> hashMapValueDescription = new HashMap<>();
hashMapValueDescription.put("title_info", "Description : ");
hashMapValueDescription.put("content_info", event.description);
HashMap<String, Object> hashMapValueCategorie = new HashMap<>();
hashMapValueCategorie.put("title_info", "Categorie : ");
hashMapValueCategorie.put("content_info", event.type);

listValues.add(hashMapValueDateBegin);
listValues.add(hashMapValueDateEnd);
listValues.add(hashMapValuePrice);
listValues.add(hashMapValueSpace);
listValues.add(hashMapValueBail);
listValues.add(hashMapValuePlace);
listValues.add(hashMapValueDescription);
listValues.add(hashMapValueCategorie);

String[] from = new String[]{"title_info", "content_info"};
int[] to = new int[]{R.id.content_infos_event_title_info, R.id.content_infos_event_content_info};

listInfos = (ListView) findViewById(R.id.activity_event_infos_list);
adapter = new SimpleAdapter(EventInfosActivity.this, listValues, R.layout.content_infos_event, from, to);
listInfos.setAdapter(adapter);
if (dataSnapshot.exists()) {
event = dataSnapshot.getValue(Event.class);
event.uid=eventUID;
nameEvent.setText(event.name);
nameAsso.setText(" ");
DatabaseReference references = FirebaseDatabase.getInstance().getReference("association");
references.child(event.association).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataS) {
if (dataS.exists()) {
Association a = dataS.getValue(Association.class);
nameAsso.setText(a.name);
}
}

@Override
public void onCancelled(DatabaseError databaseError) {

}
});
HashMap<String,Object> hashMapValueDateBegin = new HashMap<>();
hashMapValueDateBegin.put("title_info","Date de début : ");
hashMapValueDateBegin.put("content_info",event.start);
HashMap<String,Object> hashMapValueDateEnd = new HashMap<>();
hashMapValueDateEnd.put("title_info","Date de fin : ");
hashMapValueDateEnd.put("content_info",event.end);
HashMap<String,Object> hashMapValuePrice = new HashMap<>();
hashMapValuePrice.put("title_info","Prix : ");
hashMapValuePrice.put("content_info",event.price+" €");
HashMap<String,Object> hashMapValueSpace = new HashMap<>();
hashMapValueSpace.put("title_info","Places disponible : ");
hashMapValueSpace.put("content_info",event.seat_free);
HashMap<String,Object> hashMapValueBail = new HashMap<>();
hashMapValueBail.put("title_info","Caution : ");
hashMapValueBail.put("content_info",event.bail);
HashMap<String,Object> hashMapValuePlace = new HashMap<>();
hashMapValuePlace.put("title_info","Lieu : ");
hashMapValuePlace.put("content_info",event.location);
HashMap<String,Object> hashMapValueDescription = new HashMap<>();
hashMapValueDescription.put("title_info","Description : ");
hashMapValueDescription.put("content_info",event.description);
HashMap<String,Object> hashMapValueCategorie = new HashMap<>();
hashMapValueCategorie.put("title_info","Categorie : ");
hashMapValueCategorie.put("content_info",event.type);

listValues.add(hashMapValueDateBegin);
listValues.add(hashMapValueDateEnd);
listValues.add(hashMapValuePrice);
listValues.add(hashMapValueSpace);
listValues.add(hashMapValueBail);
listValues.add(hashMapValuePlace);
listValues.add(hashMapValueDescription);
listValues.add(hashMapValueCategorie);

String[] from = new String[] {"title_info","content_info"};
int[] to = new int[] {R.id.content_infos_event_title_info,R.id.content_infos_event_content_info};

listInfos = (ListView) findViewById(R.id.activity_event_infos_list);
adapter = new SimpleAdapter(EventInfosActivity.this,listValues,R.layout.content_infos_event,from,to);
listInfos.setAdapter(adapter);
}


updateParticipate();
}
Expand Down
Loading

0 comments on commit 2ce0033

Please sign in to comment.