1 /* VorlesungsplanUpcomingDayListAdapter.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.ListView;
24 import android.widget.RelativeLayout;
25 import android.widget.TextView;
27 import java.util.ArrayList;
29 import de.dhbwloe.campusapp.R;
32 * Created by pk910 on 20.02.2016.
34 public class VorlesungsplanUpcomingDayListAdapter extends ArrayAdapter<VorlesungsplanUpcomingDayListItem> {
35 private Context context;
36 private int layoutResourceId;
37 private ArrayList<VorlesungsplanUpcomingDayListItem> data = new ArrayList<VorlesungsplanUpcomingDayListItem>();
39 public VorlesungsplanUpcomingDayListAdapter(Context context, int layoutResourceId, ArrayList<VorlesungsplanUpcomingDayListItem> data) {
40 super(context, layoutResourceId, data);
41 this.layoutResourceId = layoutResourceId;
42 this.context = context;
47 public View getView(int position, View convertView, ViewGroup parent) {
48 View row = convertView;
49 RecordHolder holder = null;
52 LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
53 row = inflater.inflate(layoutResourceId, parent, false);
55 holder = new RecordHolder(row);
58 holder = (RecordHolder) row.getTag();
61 final VorlesungsplanUpcomingDayListAdapter that = this;
62 final VorlesungsplanUpcomingDayListItem item = data.get(position);
64 item.addCourseEventsToContainer(holder.container);
65 holder.cardDate.setText(item.getFormatedDate());
70 static class RecordHolder {
72 LinearLayout container;
74 public RecordHolder(View view) {
75 this.cardDate = (TextView) view.findViewById(R.id.cardDate);
76 this.container = (LinearLayout) view.findViewById(R.id.cardCourses);