Commit 2eefb498 authored by Lennart Bader's avatar Lennart Bader
Browse files

Added PlanText and SubstText.

Made lines disappear when empty.
parent db95499d
...@@ -12,12 +12,16 @@ import android.widget.TextView; ...@@ -12,12 +12,16 @@ import android.widget.TextView;
import de.mytfg.apps.vplan.R; import de.mytfg.apps.vplan.R;
import de.mytfg.apps.vplan.objects.VplanEntry; import de.mytfg.apps.vplan.objects.VplanEntry;
import static android.view.View.GONE;
public class PlanEntryHolder extends RecyclerView.ViewHolder { public class PlanEntryHolder extends RecyclerView.ViewHolder {
private TextView lesson; private TextView lesson;
private TextView cls; private TextView cls;
private TextView plan; private TextView plan;
private TextView subst; private TextView subst;
private TextView substHeader;
private TextView comment; private TextView comment;
private TextView commentHeader;
private Context context; private Context context;
private CardView cardView; private CardView cardView;
...@@ -31,14 +35,30 @@ public class PlanEntryHolder extends RecyclerView.ViewHolder { ...@@ -31,14 +35,30 @@ public class PlanEntryHolder extends RecyclerView.ViewHolder {
plan = (TextView) view.findViewById(R.id.plan); plan = (TextView) view.findViewById(R.id.plan);
subst = (TextView) view.findViewById(R.id.subst); subst = (TextView) view.findViewById(R.id.subst);
comment = (TextView) view.findViewById(R.id.comment); comment = (TextView) view.findViewById(R.id.comment);
substHeader = (TextView) view.findViewById(R.id.subst_header);
commentHeader = (TextView) view.findViewById(R.id.comment_header);
} }
public void update(VplanEntry planEntry) { public void update(VplanEntry planEntry) {
//titleView.setText(baseObject.getName()); //titleView.setText(baseObject.getName());
lesson.setText(planEntry.getLesson()); lesson.setText(planEntry.getLesson());
plan.setText(planEntry.getPlan()); plan.setText(planEntry.getPlan());
subst.setText(planEntry.getSubstitution()); if (planEntry.getSubstitution().isEmpty()) {
comment.setText(planEntry.getComment()); substHeader.setVisibility(GONE);
subst.setVisibility(GONE);
} else {
subst.setText(planEntry.getSubstitution());
subst.setVisibility(View.VISIBLE);
substHeader.setVisibility(View.VISIBLE);
}
if (planEntry.getComment().isEmpty()) {
comment.setVisibility(GONE);
commentHeader.setVisibility(GONE);
} else {
comment.setText(planEntry.getComment());
commentHeader.setVisibility(View.VISIBLE);
comment.setVisibility(View.VISIBLE);
}
cls.setText(planEntry.getCls()); cls.setText(planEntry.getCls());
if (planEntry.isOwn()) { if (planEntry.isOwn()) {
cardView.setCardBackgroundColor(context.getResources().getColor(R.color.colorPrimaryLight)); cardView.setCardBackgroundColor(context.getResources().getColor(R.color.colorPrimaryLight));
......
...@@ -13,10 +13,13 @@ public class VplanEntry extends MytfgObject { ...@@ -13,10 +13,13 @@ public class VplanEntry extends MytfgObject {
private String lesson; private String lesson;
private String cls; private String cls;
private String plan; private String plan;
private String plan_text;
private String substitution; private String substitution;
private String subst_text;
private String comment; private String comment;
private String teacher; private String teacher;
private boolean own; private boolean own;
private Vplan day; private Vplan day;
...@@ -51,6 +54,8 @@ public class VplanEntry extends MytfgObject { ...@@ -51,6 +54,8 @@ public class VplanEntry extends MytfgObject {
substitution = data.getString("substitution"); substitution = data.getString("substitution");
comment = data.getString("comment"); comment = data.getString("comment");
teacher = data.getString("teacher"); teacher = data.getString("teacher");
subst_text = data.getString("subst_text");
plan_text = data.getString("plan_text");
} catch (JSONException ex) { } catch (JSONException ex) {
// TODO: Remove this line: // TODO: Remove this line:
ex.printStackTrace(); ex.printStackTrace();
...@@ -83,6 +88,14 @@ public class VplanEntry extends MytfgObject { ...@@ -83,6 +88,14 @@ public class VplanEntry extends MytfgObject {
return teacher; return teacher;
} }
public String getPlanText() {
return plan_text;
}
public String getSubstText() {
return subst_text;
}
/** /**
* Checks wheter this entry contains information matching the given filter. * Checks wheter this entry contains information matching the given filter.
* @param filter The filter to apply * @param filter The filter to apply
...@@ -93,6 +106,8 @@ public class VplanEntry extends MytfgObject { ...@@ -93,6 +106,8 @@ public class VplanEntry extends MytfgObject {
|| getComment().toLowerCase().contains(filter) || getComment().toLowerCase().contains(filter)
|| getLesson().toLowerCase().contains(filter) || getLesson().toLowerCase().contains(filter)
|| getPlan().toLowerCase().contains(filter) || getPlan().toLowerCase().contains(filter)
|| getPlanText().toLowerCase().contains(filter)
|| getSubstText().toLowerCase().contains(filter)
|| getSubstitution().toLowerCase().contains(filter); || getSubstitution().toLowerCase().contains(filter);
} }
......
Markdown is supported
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