Skip to content
Snippets Groups Projects
Commit e3a85467 authored by Lencelot's avatar Lencelot
Browse files

Extras

L'activité Login communique l'identifiant utilisateur à la Main activité afin qu'il instancie l'User
parent 7ffeedb9
Branches master
No related merge requests found
...@@ -12,4 +12,29 @@ class Event { ...@@ -12,4 +12,29 @@ class Event {
private EventType eventType; private EventType eventType;
private boolean hasInvitationList; private boolean hasInvitationList;
private boolean hasInscritpionList; private boolean hasInscritpionList;
public Event(String name, String descritpion, Date creationDate, Date eventDate, int limitInscritpion, Date inscriptionLimitdate, EventType eventType, boolean hasInvitationList, boolean hasInscritpionList) {
this.name = name;
this.descritpion = descritpion;
this.creationDate = creationDate;
this.eventDate = eventDate;
this.limitInscritpion = limitInscritpion;
this.inscriptionLimitdate = inscriptionLimitdate;
this.eventType = eventType;
this.hasInvitationList = hasInvitationList;
this.hasInscritpionList = hasInscritpionList;
}
public Event(String name, String descritpion, Date eventDate, int limitInscritpion, Date inscriptionLimitdate, EventType eventType) {
this.name = name;
this.descritpion = descritpion;
this.eventDate = eventDate;
this.limitInscritpion = limitInscritpion;
this.inscriptionLimitdate = inscriptionLimitdate;
this.eventType = eventType;
this.hasInscritpionList = false;
this.hasInvitationList = false;
this.creationDate = new Date();
}
} }
...@@ -2,7 +2,7 @@ package com.example.maillard_clovis_event_manager.DataBase; ...@@ -2,7 +2,7 @@ package com.example.maillard_clovis_event_manager.DataBase;
import java.util.Date; import java.util.Date;
class User { public class User {
private String id; private String id;
private String login; private String login;
private String firstName; private String firstName;
...@@ -11,4 +11,19 @@ class User { ...@@ -11,4 +11,19 @@ class User {
private String imageUrl; private String imageUrl;
private boolean activated; private boolean activated;
private Date creatDate; private Date creatDate;
public User(String id, String login, String firstName, String lastName, String email, String imageUrl, boolean activated, Date creatDate) {
this.id = id;
this.login = login;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.imageUrl = imageUrl;
this.activated = activated;
this.creatDate = creatDate;
}
public String getLogin() {
return login;
}
} }
package com.example.maillard_clovis_event_manager; package com.example.maillard_clovis_event_manager;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import com.example.maillard_clovis_event_manager.DataBase.User;
import com.example.maillard_clovis_event_manager.ui.NewEvent.NewEventFragment; import com.example.maillard_clovis_event_manager.ui.NewEvent.NewEventFragment;
import com.example.maillard_clovis_event_manager.ui.data.UserDataSource;
import com.example.maillard_clovis_event_manager.ui.login.LoginActivity;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import android.view.View; import android.view.View;
...@@ -21,13 +25,25 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -21,13 +25,25 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private AppBarConfiguration mAppBarConfiguration; private AppBarConfiguration mAppBarConfiguration;
private User user;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
if(getIntent().getExtras() != null){
try {
user = UserDataSource.getUserById(getIntent().getExtras().getString("loginId"));
Toast.makeText(getApplicationContext(), getString(R.string.wellcome) + user.getLogin(), Toast.LENGTH_LONG).show();
}catch(Exception e){
user = null;
}
}
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
......
package com.example.maillard_clovis_event_manager.ui.data;
import com.example.maillard_clovis_event_manager.DataBase.User;
import com.example.maillard_clovis_event_manager.R;
import java.util.Date;
public class UserDataSource {
//généré en dur car pas de BDD pour le moment
public static User getUserById(String id) throws Exception {
if (!id.equals("1")) {
throw new Exception("User not found in the Data Base !");
}
return new User("1", "JeanMich", "Jean", "Michel", "jeanmi@hotmail.fr", "/test.png", true, new Date());
}
}
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
<string name="register">"Please tip your "</string> <string name="register">"Please tip your "</string>
<string name="title_activity_regesiter">Register Activity</string> <string name="title_activity_regesiter">Register Activity</string>
<string name="valid_register">You were successfully registered</string> <string name="valid_register">You were successfully registered</string>
<string name="user_not_found">User not found in Data Base !</string>
<string name="wellcome">Wellcome back </string>
<!-- TODO: Remove or change this placeholder text --> <!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string> <string name="hello_blank_fragment">Hello blank fragment</string>
......
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