Added Upcoming Events to ModDetailsOverviewAdapter
This commit is contained in:
@@ -15,6 +15,7 @@ import java.util.ArrayList;
|
|||||||
import de.sebse.fuplanner.R;
|
import de.sebse.fuplanner.R;
|
||||||
import de.sebse.fuplanner.services.KVV.Announcement;
|
import de.sebse.fuplanner.services.KVV.Announcement;
|
||||||
import de.sebse.fuplanner.services.KVV.Assignment;
|
import de.sebse.fuplanner.services.KVV.Assignment;
|
||||||
|
import de.sebse.fuplanner.services.KVV.Event;
|
||||||
import de.sebse.fuplanner.services.KVV.Modules;
|
import de.sebse.fuplanner.services.KVV.Modules;
|
||||||
import de.sebse.fuplanner.tools.Conversion;
|
import de.sebse.fuplanner.tools.Conversion;
|
||||||
import de.sebse.fuplanner.tools.logging.Logger;
|
import de.sebse.fuplanner.tools.logging.Logger;
|
||||||
@@ -31,6 +32,7 @@ public class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||||||
private static final int SECTION_DESCRIPTION = 0;
|
private static final int SECTION_DESCRIPTION = 0;
|
||||||
private static final int SECTION_ANNOUNCEMENT = 1;
|
private static final int SECTION_ANNOUNCEMENT = 1;
|
||||||
private static final int SECTION_ASSIGNMENT = 2;
|
private static final int SECTION_ASSIGNMENT = 2;
|
||||||
|
private static final int SECTION_EVENTS = 3;
|
||||||
|
|
||||||
private Modules.Module mValue;
|
private Modules.Module mValue;
|
||||||
private final ArrayList<Pair<Integer, Object>> mPositionalData;
|
private final ArrayList<Pair<Integer, Object>> mPositionalData;
|
||||||
@@ -56,6 +58,8 @@ public class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||||||
addPositionalListData(getAnnounceCount(), SECTION_ANNOUNCEMENT);
|
addPositionalListData(getAnnounceCount(), SECTION_ANNOUNCEMENT);
|
||||||
mPositionalData.add(new Pair<>(TYPE_HEADER, SECTION_ASSIGNMENT));
|
mPositionalData.add(new Pair<>(TYPE_HEADER, SECTION_ASSIGNMENT));
|
||||||
addPositionalListData(getAssignmentCount(), SECTION_ASSIGNMENT);
|
addPositionalListData(getAssignmentCount(), SECTION_ASSIGNMENT);
|
||||||
|
mPositionalData.add(new Pair<>(TYPE_HEADER, SECTION_EVENTS));
|
||||||
|
addPositionalListData(getAssignmentCount(), SECTION_EVENTS);
|
||||||
this.notifyDataSetChanged();
|
this.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +124,9 @@ public class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||||||
case SECTION_ASSIGNMENT:
|
case SECTION_ASSIGNMENT:
|
||||||
h.mCaption.setText(h.mView.getResources().getString(R.string.assignments_count, getAssignmentCount()));
|
h.mCaption.setText(h.mView.getResources().getString(R.string.assignments_count, getAssignmentCount()));
|
||||||
break;
|
break;
|
||||||
|
case SECTION_EVENTS:
|
||||||
|
h.mCaption.setText(h.mView.getResources().getString(R.string.upcoming_events_count, getEventsCount()));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TYPE_DESCRIPTION:
|
case TYPE_DESCRIPTION:
|
||||||
@@ -144,6 +151,16 @@ public class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||||||
i.mSubLeft.setText(assignment.getStatus());
|
i.mSubLeft.setText(assignment.getStatus());
|
||||||
i.mSubRight.setText(Conversion.getModifiedDate(assignment.getDueDate()));
|
i.mSubRight.setText(Conversion.getModifiedDate(assignment.getDueDate()));
|
||||||
i.mView.setOnClickListener(view -> log.d("Refeerence to:", SECTION_ASSIGNMENT, index));
|
i.mView.setOnClickListener(view -> log.d("Refeerence to:", SECTION_ASSIGNMENT, index));
|
||||||
|
break;
|
||||||
|
case SECTION_EVENTS:
|
||||||
|
Event event = mValue.events.get(index);
|
||||||
|
i.mTitle.setText(event.getTitle());
|
||||||
|
i.mSubLeft.setText(event.getType());
|
||||||
|
i.mSubRight.setText(i.mView.getResources().getString(R.string.date_scale,
|
||||||
|
Conversion.getModifiedDate(event.getStartDate()),
|
||||||
|
Conversion.getModifiedDate(event.getEndDate())
|
||||||
|
));
|
||||||
|
i.mView.setOnClickListener(view -> log.d("Refeerence to:", SECTION_ASSIGNMENT, index));
|
||||||
}
|
}
|
||||||
case TYPE_SHOW_MORE:
|
case TYPE_SHOW_MORE:
|
||||||
CustomViewHolder c = (CustomViewHolder) holder;
|
CustomViewHolder c = (CustomViewHolder) holder;
|
||||||
@@ -168,6 +185,12 @@ public class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getEventsCount() {
|
||||||
|
if (mValue.events != null)
|
||||||
|
return mValue.events.size();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
36
app/src/main/java/de/sebse/fuplanner/services/KVV/Event.java
Normal file
36
app/src/main/java/de/sebse/fuplanner/services/KVV/Event.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package de.sebse.fuplanner.services.KVV;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class Event {
|
||||||
|
private final String id;
|
||||||
|
|
||||||
|
Event(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ID: "+getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return "Event Title";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return "Event Type";
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStartDate() {
|
||||||
|
return (new Date()).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getEndDate() {
|
||||||
|
return (new Date()).getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -189,6 +189,7 @@ public class Modules /*extends EventEmitter<Triplet<Integer, Modules.UpgradeModu
|
|||||||
private final String ID;
|
private final String ID;
|
||||||
public ArrayList<Announcement> announcements;
|
public ArrayList<Announcement> announcements;
|
||||||
public ArrayList<Assignment> assignments;
|
public ArrayList<Assignment> assignments;
|
||||||
|
public ArrayList<Event> events;
|
||||||
|
|
||||||
/*private Module() {
|
/*private Module() {
|
||||||
this(null, null, null, null, null);
|
this(null, null, null, null, null);
|
||||||
|
|||||||
@@ -26,4 +26,7 @@
|
|||||||
<string name="show_all">Show All</string>
|
<string name="show_all">Show All</string>
|
||||||
<string name="assignments_count">Assignments (%1$d)</string>
|
<string name="assignments_count">Assignments (%1$d)</string>
|
||||||
<string name="assignments">Assignments</string>
|
<string name="assignments">Assignments</string>
|
||||||
|
<string name="upcoming_events_count">Upcoming Events (%1$d)</string>
|
||||||
|
<string name="upcoming_events">Upcoming Events</string>
|
||||||
|
<string name="date_scale">%1$s - %2$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user