Added Lecturers to Overview and List
This commit is contained in:
@@ -41,6 +41,7 @@ import de.sebse.fuplanner.services.KVV.KVVListener;
|
||||
import de.sebse.fuplanner.services.KVV.types.LoginToken;
|
||||
import de.sebse.fuplanner.services.KVV.types.Modules;
|
||||
import de.sebse.fuplanner.tools.MainActivityListener;
|
||||
import de.sebse.fuplanner.tools.NewAsyncQueue;
|
||||
import de.sebse.fuplanner.tools.RequestPermissionsResultListener;
|
||||
import de.sebse.fuplanner.tools.logging.Logger;
|
||||
import de.sebse.fuplanner.tools.network.NetworkCallback;
|
||||
@@ -77,6 +78,7 @@ public class MainActivity extends AppCompatActivity
|
||||
private CanteenBrowser mCanteenBrowser;
|
||||
private HashMap<String, RequestPermissionsResultListener> permissionListeners = new HashMap<>();
|
||||
private boolean mOfflineBanner;
|
||||
private NewAsyncQueue mQueue = new NewAsyncQueue();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -422,7 +424,9 @@ public class MainActivity extends AppCompatActivity
|
||||
});
|
||||
}
|
||||
|
||||
private void afterAnyMenuInflate(boolean isLoggedIn) {
|
||||
private void afterAnyMenuInflate(boolean isLoggedIn, Runnable done) {
|
||||
int MAX_COUNT = 2;
|
||||
final int[] count = {0};
|
||||
if (isLoggedIn) {
|
||||
getKVV().modules().list().recv(success -> {
|
||||
int i = 0;
|
||||
@@ -435,7 +439,11 @@ public class MainActivity extends AppCompatActivity
|
||||
});
|
||||
i++;
|
||||
}
|
||||
}, log::e);
|
||||
if (++count[0] == MAX_COUNT) done.run();
|
||||
}, msg -> {
|
||||
if (++count[0] == MAX_COUNT) done.run();
|
||||
log.e(msg);
|
||||
});
|
||||
}
|
||||
getCanteenBrowser().getCanteens(success -> {
|
||||
int i = 0;
|
||||
@@ -447,19 +455,27 @@ public class MainActivity extends AppCompatActivity
|
||||
});
|
||||
i++;
|
||||
}
|
||||
}, log::e);
|
||||
if (++count[0] == MAX_COUNT) done.run();
|
||||
}, msg -> {
|
||||
if (++count[0] == MAX_COUNT) done.run();
|
||||
log.e(msg);
|
||||
});
|
||||
}
|
||||
|
||||
private void updateNavigation() {
|
||||
boolean isLoggedIn = getKVV().account().isLoggedIn();
|
||||
setNavigationHeader(isLoggedIn);
|
||||
mNavigationView.getMenu().clear();
|
||||
if (isLoggedIn)
|
||||
mNavigationView.inflateMenu(R.menu.activity_main_drawer_login);
|
||||
else
|
||||
mNavigationView.inflateMenu(R.menu.activity_main_drawer);
|
||||
afterAnyMenuInflate(isLoggedIn);
|
||||
setNavigationSelection();
|
||||
mQueue.add(() -> {
|
||||
boolean isLoggedIn = getKVV().account().isLoggedIn();
|
||||
setNavigationHeader(isLoggedIn);
|
||||
mNavigationView.getMenu().clear();
|
||||
if (isLoggedIn)
|
||||
mNavigationView.inflateMenu(R.menu.activity_main_drawer_login);
|
||||
else
|
||||
mNavigationView.inflateMenu(R.menu.activity_main_drawer);
|
||||
afterAnyMenuInflate(isLoggedIn, () -> {
|
||||
setNavigationSelection();
|
||||
mQueue.next();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class ModulesAdapter extends RecyclerView.Adapter<CustomViewHolder> {
|
||||
Modules.Module module = ((Modules.Module) pair.second);
|
||||
iHolder.mTitle.setText(module.title);
|
||||
StringBuilder lecturers = new StringBuilder();
|
||||
for (Lecturer lecturer : module.lecturer) {
|
||||
for (Lecturer lecturer: module.lecturer) {
|
||||
if (!lecturer.isResponsible())
|
||||
continue;
|
||||
if (lecturers.length() > 0)
|
||||
|
||||
@@ -16,11 +16,13 @@ import de.sebse.fuplanner.R;
|
||||
import de.sebse.fuplanner.services.KVV.types.Announcement;
|
||||
import de.sebse.fuplanner.services.KVV.types.Assignment;
|
||||
import de.sebse.fuplanner.services.KVV.types.Event;
|
||||
import de.sebse.fuplanner.services.KVV.types.Lecturer;
|
||||
import de.sebse.fuplanner.services.KVV.types.Modules;
|
||||
import de.sebse.fuplanner.tools.UtilsDate;
|
||||
import de.sebse.fuplanner.tools.logging.Logger;
|
||||
import de.sebse.fuplanner.tools.ui.CustomViewHolder;
|
||||
import de.sebse.fuplanner.tools.ui.ItemViewHolder;
|
||||
import de.sebse.fuplanner.tools.ui.MailViewHolder;
|
||||
import de.sebse.fuplanner.tools.ui.StringViewHolder;
|
||||
|
||||
class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
@@ -30,6 +32,7 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
private static final int TYPE_DESCRIPTION = 1;
|
||||
private static final int TYPE_ITEM = 2;
|
||||
private static final int TYPE_SHOW_MORE = 3;
|
||||
private static final int TYPE_MAIL = 4;
|
||||
|
||||
@Nullable private final ModDetailListener mListener;
|
||||
|
||||
@@ -52,6 +55,10 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
mPositionalData.clear();
|
||||
mPositionalData.add(new Pair<>(TYPE_HEADER, ModulePart.DESCRIPTION));
|
||||
mPositionalData.add(new Pair<>(TYPE_DESCRIPTION, null));
|
||||
mPositionalData.add(new Pair<>(TYPE_HEADER, ModulePart.LECTURERS));
|
||||
for (int i = 0; i < mValue.lecturer.size(); i++) {
|
||||
mPositionalData.add(new Pair<>(TYPE_MAIL, ModulePart.LECTURERS+1024*i));
|
||||
}
|
||||
mPositionalData.add(new Pair<>(TYPE_HEADER, ModulePart.ANNOUNCEMENT));
|
||||
addPositionalListData(getAnnounceCount(), ModulePart.ANNOUNCEMENT);
|
||||
mPositionalData.add(new Pair<>(TYPE_HEADER, ModulePart.ASSIGNMENT));
|
||||
@@ -90,6 +97,10 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_all_show_more, parent, false);
|
||||
return new CustomViewHolder(view);
|
||||
case TYPE_MAIL:
|
||||
view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_all_mails, parent, false);
|
||||
return new MailViewHolder(view);
|
||||
default:
|
||||
//noinspection ConstantConditions
|
||||
return null;
|
||||
@@ -116,6 +127,9 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
case ModulePart.DESCRIPTION:
|
||||
h.mString.setText(R.string.description);
|
||||
break;
|
||||
case ModulePart.LECTURERS:
|
||||
h.mString.setText(h.mView.getResources().getString(R.string.lecturers));
|
||||
break;
|
||||
case ModulePart.ANNOUNCEMENT:
|
||||
h.mString.setText(h.mView.getResources().getString(R.string.announcements_count, getAnnounceCount()));
|
||||
break;
|
||||
@@ -182,6 +196,21 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TYPE_MAIL:
|
||||
section = ((Integer) data.second) % 1024;
|
||||
index = ((Integer) data.second) / 1024;
|
||||
MailViewHolder m = (MailViewHolder) holder;
|
||||
switch (section) {
|
||||
case ModulePart.LECTURERS:
|
||||
Lecturer lecturer = mValue.lecturer.get(index);
|
||||
m.mTitle.setText(lecturer.getName());
|
||||
m.mSubLeft.setText(lecturer.getMail());
|
||||
//i.mSubRight.setText(UtilsDate.getModifiedDateTime(i.mView.getContext(), announce.getCreatedOn()));
|
||||
/*i.mView.setOnClickListener(view -> {
|
||||
if (mListener != null) mListener.gotoFragmentPart(section, index);
|
||||
});*/
|
||||
break;
|
||||
}
|
||||
case TYPE_SHOW_MORE:
|
||||
CustomViewHolder c = (CustomViewHolder) holder;
|
||||
c.mView.setOnClickListener(view -> {
|
||||
|
||||
@@ -8,6 +8,7 @@ class ModulePart {
|
||||
static final int EVENT = 4;
|
||||
static final int GRADEBOOK = 5;
|
||||
static final int RESOURCES = 6;
|
||||
static final int LECTURERS = 7;
|
||||
private static final int[] pages = new int[]{OVERVIEW, ANNOUNCEMENT, ASSIGNMENT, GRADEBOOK, RESOURCES, EVENT};
|
||||
|
||||
static int getPageCount() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.json.JSONObject;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.regex.MatchResult;
|
||||
|
||||
import de.sebse.fuplanner.services.KVV.types.Lecturer;
|
||||
@@ -166,7 +167,7 @@ public class ModulesList extends HTTPService {
|
||||
lvNumbers.add(matchResult.group());
|
||||
}
|
||||
String title = site.getString("entityTitle");
|
||||
HashSet<Lecturer> lecturers = new HashSet<>();
|
||||
LinkedHashSet<Lecturer> lecturers = new LinkedHashSet<>();
|
||||
String kvv_lecturers = site.getJSONObject("props").optString("kvv_lecturers", null);
|
||||
if (kvv_lecturers != null) for (String lecturer : kvv_lecturers.split("#")) {
|
||||
if (lecturer.length() > 2)
|
||||
|
||||
@@ -4,8 +4,6 @@ import java.io.Serializable;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import de.sebse.fuplanner.tools.logging.Logger;
|
||||
|
||||
public class Lecturer implements Serializable {
|
||||
private final String firstName;
|
||||
private final String surname;
|
||||
|
||||
@@ -10,10 +10,10 @@ import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.nio.channels.SeekableByteChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -33,7 +33,7 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
|
||||
this.list = new SortedListModule();
|
||||
}
|
||||
|
||||
public void addModule(@Nullable Semester semester, HashSet<String> lvNumber, String title, HashSet<Lecturer> lecturer, String type, String description, String ID) {
|
||||
public void addModule(@Nullable Semester semester, HashSet<String> lvNumber, String title, LinkedHashSet<Lecturer> lecturer, String type, String description, String ID) {
|
||||
Module m = new Module(semester, lvNumber, title, lecturer, type, description, ID);
|
||||
this.list.add(m);
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
|
||||
@NotNull final HashSet<String> lvNumber;
|
||||
@NotNull public final String title;
|
||||
@NotNull
|
||||
public final HashSet<Lecturer> lecturer;
|
||||
public final ArrayList<Lecturer> lecturer;
|
||||
@Nullable public final String type;
|
||||
@Nullable public final String description;
|
||||
@NotNull private final String ID;
|
||||
@@ -138,14 +138,14 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
|
||||
return userPoint/maxPoint;
|
||||
}
|
||||
|
||||
private Module(@Nullable Semester semester, @NotNull HashSet<String> lvNumber, @NotNull String title, @NotNull HashSet<Lecturer> lecturer, @Nullable String type, @Nullable String description, @NotNull String ID) {
|
||||
private Module(@Nullable Semester semester, @NotNull HashSet<String> lvNumber, @NotNull String title, @NotNull LinkedHashSet<Lecturer> lecturer, @Nullable String type, @Nullable String description, @NotNull String ID) {
|
||||
|
||||
title = title.replaceAll("(.*?) (S[0-9]{2}|W[0-9/]{5})", "$1");
|
||||
|
||||
this.semester = semester;
|
||||
this.lvNumber = lvNumber;
|
||||
this.title = title;
|
||||
this.lecturer = lecturer;
|
||||
this.lecturer = new ArrayList<>(lecturer);
|
||||
this.type = type;
|
||||
this.description = description;
|
||||
this.ID = ID;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.sebse.fuplanner.services.KVV.types;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import de.sebse.fuplanner.tools.Regex;
|
||||
import de.sebse.fuplanner.tools.SortedList;
|
||||
|
||||
public class SortedListModule extends SortedList<Modules.Module, String, Semester> {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package de.sebse.fuplanner.tools;
|
||||
|
||||
import com.google.android.gms.common.util.Function;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class EventListener<T> {
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.android.volley.Response;
|
||||
import com.android.volley.TimeoutError;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
import com.google.android.gms.common.util.Function;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.sebse.fuplanner.tools.ui;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.cunoraz.tagview.TagView;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package de.sebse.fuplanner.tools.ui;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import de.sebse.fuplanner.R;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.sebse.fuplanner.tools.ui;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import de.sebse.fuplanner.R;
|
||||
|
||||
public class MailViewHolder extends StringViewHolder {
|
||||
public final TextView mTitle;
|
||||
public final TextView mSubLeft;
|
||||
public final ImageView mIcon;
|
||||
|
||||
public MailViewHolder(View view) {
|
||||
super(view);
|
||||
mTitle = view.findViewById(R.id.title);
|
||||
mSubLeft = view.findViewById(R.id.sub_left);
|
||||
mIcon = view.findViewById(R.id.icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " '" + mTitle.getText() + "' '" + mSubLeft.getText() + "'";
|
||||
}
|
||||
}
|
||||
9
app/src/main/res/drawable/ic_mail.xml
Normal file
9
app/src/main/res/drawable/ic_mail.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="40dp"
|
||||
android:height="40dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#003366"
|
||||
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z"/>
|
||||
</vector>
|
||||
45
app/src/main/res/layout/list_all_mails.xml
Normal file
45
app/src/main/res/layout/list_all_mails.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dip" >
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
android:typeface="sans"
|
||||
tools:text="Test this new stuff!" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sub_left"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/title"
|
||||
android:layout_marginTop="5dip"
|
||||
android:textColor="#343434"
|
||||
android:textSize="12sp"
|
||||
tools:text="Peter Bauer" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/title"
|
||||
android:layout_alignBottom="@id/sub_left"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:contentDescription="@string/mail_icon"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_mail"
|
||||
android:layout_marginEnd="10dp" />
|
||||
</RelativeLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -78,4 +78,6 @@
|
||||
<string name="deadline">Abgabe</string>
|
||||
<string name="winter_semester">Wintersemester %1$d/%2$d</string>
|
||||
<string name="summer_semester">Sommersemester %1$d</string>
|
||||
<string name="lecturers">Dozenten</string>
|
||||
<string name="mail_icon">Mail Icon</string>
|
||||
</resources>
|
||||
@@ -86,4 +86,6 @@
|
||||
<string name="deadline">Deadline</string>
|
||||
<string name="winter_semester">Winter Semester %1$d/%2$d</string>
|
||||
<string name="summer_semester">Summer Semester %1$d</string>
|
||||
<string name="lecturers">Lecturers</string>
|
||||
<string name="mail_icon">Mail Icon</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user