1 /* VorlesungsplanGroupsListAdapter.java
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package de.dhbwloe.campusapp.fragments;
17 import android.content.Context;
18 import android.view.LayoutInflater;
19 import android.view.View;
20 import android.view.ViewGroup;
21 import android.widget.ArrayAdapter;
22 import android.widget.LinearLayout;
23 import android.widget.TextView;
25 import java.util.ArrayList;
27 import de.dhbwloe.campusapp.CampusAppContext;
28 import de.dhbwloe.campusapp.R;
31 * Created by pk910 on 20.02.2016.
33 public class VorlesungsplanGroupsListAdapter extends ArrayAdapter<VorlesungsplanGroupsListItem> {
34 private Context context;
35 private int layoutResourceId;
36 private ArrayList<VorlesungsplanGroupsListItem> data = new ArrayList<VorlesungsplanGroupsListItem>();
38 public VorlesungsplanGroupsListAdapter(Context context, int layoutResourceId, ArrayList<VorlesungsplanGroupsListItem> data) {
39 super(context, layoutResourceId, data);
40 this.layoutResourceId = layoutResourceId;
41 this.context = context;
46 public View getView(int position, View convertView, ViewGroup parent) {
47 View row = convertView;
48 RecordHolder holder = null;
51 LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
52 row = inflater.inflate(layoutResourceId, parent, false);
54 holder = new RecordHolder(row);
57 holder = (RecordHolder) row.getTag();
60 final VorlesungsplanGroupsListAdapter that = this;
61 final VorlesungsplanGroupsListItem item = data.get(position);
63 holder.groupName.setText(item.getGroupName());
64 holder.nextEvent.setText(item.getNextEvent());
65 holder.lastEvent.setText(item.getLastEvent());
67 String klausurDate = item.getNextKlausurEvent();
68 if(klausurDate == null)
69 klausurDate = CampusAppContext.getInstance().getResString(R.string.vorlesungsplan_groups_noklausur);
71 holder.klausurEvent.setText(klausurDate);
76 static class RecordHolder {
80 TextView klausurEvent;
83 public RecordHolder(View view) {
84 this.groupName = (TextView) view.findViewById(R.id.courseTitle);
85 this.nextEvent = (TextView) view.findViewById(R.id.nextEvent);
86 this.lastEvent = (TextView) view.findViewById(R.id.lastEvent);
87 this.klausurEvent = (TextView) view.findViewById(R.id.klausurEvent);
88 this.klausurName = (TextView) view.findViewById(R.id.klausurName);