Skip to content

Commit 2e7fe19

Browse files
committed
commit
1 parent ae4825c commit 2e7fe19

File tree

10 files changed

+374
-68
lines changed

10 files changed

+374
-68
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies {
3838
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
3939
implementation 'com.google.android.material:material:1.2.1'
4040
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
41+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
4142
testImplementation 'junit:junit:4.12'
4243
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
4344
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.example.webapplicationwithspring;
2+
3+
import android.app.Fragment;
4+
import android.content.Context;
5+
import android.os.Bundle;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.TextView;
10+
11+
import androidx.annotation.NonNull;
12+
import androidx.annotation.Nullable;
13+
14+
import com.example.webapplicationwithspring.Events.EventsController;
15+
16+
// class for the event fragment click
17+
public class EventFragment extends Fragment {
18+
// static class creation with parameter index, index is needed to display particular event from eventController
19+
public static EventFragment newInstance(int index) {
20+
EventFragment f = new EventFragment();
21+
Bundle args = new Bundle();
22+
args.putInt("index", index);
23+
f.setArguments(args);
24+
return f;
25+
}
26+
27+
// here we initialize all the data to eventFragment layout and return the View
28+
@Nullable
29+
@Override
30+
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
31+
LayoutInflater layoutInflater = (LayoutInflater) getActivity().getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
32+
View event = layoutInflater.inflate(R.layout.event, null, false);
33+
TextView name = event.findViewById(R.id.textView_name);
34+
TextView date = event.findViewById(R.id.textView_date);
35+
TextView description = event.findViewById(R.id.textView_description);
36+
TextView place = event.findViewById(R.id.textView_place);
37+
38+
name.setText(EventsController.getEvent(getArguments().getInt("index",0)).getEventName());
39+
date.setText(EventsController.getEvent(getArguments().getInt("index",0)).getEventDate());
40+
description.setText(EventsController.getEvent(getArguments().getInt("index",0)).getEventDescription());
41+
place.setText(EventsController.getEvent(getArguments().getInt("index",0)).getEventPlace());
42+
43+
return event;
44+
}
45+
}
46+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.example.webapplicationwithspring.Events;
2+
3+
public class Event {
4+
private String eventName;
5+
private String eventDate;
6+
private String eventDescription;
7+
private String eventPlace;
8+
private int id;
9+
10+
11+
12+
public Event(String eventName, String eventDate, String eventDescription, String eventPlace, int id) {
13+
this.eventName = eventName;
14+
this.eventDate = eventDate;
15+
this.eventDescription = eventDescription;
16+
this.eventPlace = eventPlace;
17+
this.id = id;
18+
}
19+
20+
public String getEventName() {
21+
return eventName;
22+
}
23+
24+
public void setEventName(String eventName) {
25+
this.eventName = eventName;
26+
}
27+
28+
public String getEventDate() {
29+
return eventDate;
30+
}
31+
32+
public void setEventDate(String eventDate) {
33+
this.eventDate = eventDate;
34+
}
35+
36+
public String getEventDescription() {
37+
return eventDescription;
38+
}
39+
40+
public void setEventDescription(String eventDescription) {
41+
this.eventDescription = eventDescription;
42+
}
43+
44+
public String getEventPlace() {
45+
return eventPlace;
46+
}
47+
48+
public void setEventPlace(String eventPlace) {
49+
this.eventPlace = eventPlace;
50+
}
51+
52+
public int getId() {
53+
return id;
54+
}
55+
56+
public void setId(int id) {
57+
this.id = id;
58+
}
59+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.example.webapplicationwithspring.Events;
2+
3+
import java.util.Collection;
4+
import java.util.HashMap;
5+
import java.util.Map;
6+
7+
public class EventsController {
8+
private static Map<Integer,Event> eventsMap= new HashMap<Integer,Event>();
9+
public static void addEvent(String eventName, String eventDate, String eventDescription, String eventPlace, int id){
10+
eventsMap.put(id, new Event(eventName,eventDate,eventDescription,eventPlace,id));
11+
}
12+
public static Event getEvent(int index){
13+
return eventsMap.get(index);
14+
}
15+
public static Collection<Event> getValue(){
16+
return eventsMap.values();
17+
}
18+
public static int getSize(){ return eventsMap.size(); }
19+
20+
}
21+

0 commit comments

Comments
 (0)