Module description
This commit is contained in:
@@ -2,6 +2,7 @@ package de.sebse.fuplanner.fragments.moddetails;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -37,6 +38,7 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
private static final int TYPE_SHOW_MORE = 3;
|
private static final int TYPE_SHOW_MORE = 3;
|
||||||
private static final int TYPE_MAIL = 4;
|
private static final int TYPE_MAIL = 4;
|
||||||
private static final int TYPE_SHORTCUTS = 5;
|
private static final int TYPE_SHORTCUTS = 5;
|
||||||
|
private static final int TYPE_NO_ITEMS = 6;
|
||||||
|
|
||||||
@Nullable private final ModDetailListener mListener;
|
@Nullable private final ModDetailListener mListener;
|
||||||
|
|
||||||
@@ -57,8 +59,10 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
|
|
||||||
private void setModule() {
|
private void setModule() {
|
||||||
mPositionalData.clear();
|
mPositionalData.clear();
|
||||||
mPositionalData.add(new Pair<>(TYPE_HEADER, ModulePart.DESCRIPTION));
|
if (!TextUtils.isEmpty(mValue.description)) {
|
||||||
mPositionalData.add(new Pair<>(TYPE_DESCRIPTION, null));
|
mPositionalData.add(new Pair<>(TYPE_HEADER, ModulePart.DESCRIPTION));
|
||||||
|
mPositionalData.add(new Pair<>(TYPE_DESCRIPTION, null));
|
||||||
|
}
|
||||||
mPositionalData.add(new Pair<>(TYPE_SHORTCUTS, null));
|
mPositionalData.add(new Pair<>(TYPE_SHORTCUTS, null));
|
||||||
mPositionalData.add(new Pair<>(TYPE_HEADER, ModulePart.LECTURERS));
|
mPositionalData.add(new Pair<>(TYPE_HEADER, ModulePart.LECTURERS));
|
||||||
for (int i = 0; i < mValue.lecturer.size(); i++) {
|
for (int i = 0; i < mValue.lecturer.size(); i++) {
|
||||||
@@ -79,6 +83,9 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
}
|
}
|
||||||
if (count > MAX_ITEMS_PER_PREVIEW)
|
if (count > MAX_ITEMS_PER_PREVIEW)
|
||||||
mPositionalData.add(new Pair<>(TYPE_SHOW_MORE, category));
|
mPositionalData.add(new Pair<>(TYPE_SHOW_MORE, category));
|
||||||
|
if (count == 0) {
|
||||||
|
mPositionalData.add(new Pair<>(TYPE_NO_ITEMS, category));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -102,6 +109,10 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
view = LayoutInflater.from(parent.getContext())
|
view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.list_all_show_more, parent, false);
|
.inflate(R.layout.list_all_show_more, parent, false);
|
||||||
return new CustomViewHolder(view);
|
return new CustomViewHolder(view);
|
||||||
|
case TYPE_NO_ITEMS:
|
||||||
|
view = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.list_all_no_items, parent, false);
|
||||||
|
return new CustomViewHolder(view);
|
||||||
case TYPE_MAIL:
|
case TYPE_MAIL:
|
||||||
view = LayoutInflater.from(parent.getContext())
|
view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.list_all_mails, parent, false);
|
.inflate(R.layout.list_all_mails, parent, false);
|
||||||
@@ -236,6 +247,7 @@ class ModDetailOverviewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case TYPE_SHOW_MORE:
|
case TYPE_SHOW_MORE:
|
||||||
|
case TYPE_NO_ITEMS:
|
||||||
CustomViewHolder c = (CustomViewHolder) holder;
|
CustomViewHolder c = (CustomViewHolder) holder;
|
||||||
c.mView.setOnClickListener(view -> {
|
c.mView.setOnClickListener(view -> {
|
||||||
if (mListener != null) mListener.gotoFragmentPart((Integer) data.second, -1);
|
if (mListener != null) mListener.gotoFragmentPart((Integer) data.second, -1);
|
||||||
|
|||||||
@@ -272,6 +272,7 @@ public class ModulesList extends HTTPService {
|
|||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject(body1);
|
JSONObject json = new JSONObject(body1);
|
||||||
String name = json.getString("name");
|
String name = json.getString("name");
|
||||||
|
String description = json.optString("description", null);
|
||||||
String type, lvNumber, semYear, semType;
|
String type, lvNumber, semYear, semType;
|
||||||
Semester semester = null;
|
Semester semester = null;
|
||||||
HashSet<String> lvNumberSet = new HashSet<>();
|
HashSet<String> lvNumberSet = new HashSet<>();
|
||||||
@@ -297,7 +298,7 @@ public class ModulesList extends HTTPService {
|
|||||||
Semester finalSemester = semester;
|
Semester finalSemester = semester;
|
||||||
String finalType = type;
|
String finalType = type;
|
||||||
lecturer().getBBLecturers(courseId, success -> {
|
lecturer().getBBLecturers(courseId, success -> {
|
||||||
modulesKVV.addModule(finalSemester, lvNumberSet, name, success, finalType, "", courseId, Modules.TYPE_BB);
|
modulesKVV.addModule(finalSemester, lvNumberSet, name, success, finalType, description, courseId, Modules.TYPE_BB);
|
||||||
if (--latch[0] == 0) callback.onResponse(modulesKVV);
|
if (--latch[0] == 0) callback.onResponse(modulesKVV);
|
||||||
}, error -> {
|
}, error -> {
|
||||||
log.e(error);
|
log.e(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user