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 java.text.SimpleDateFormat;
18 import java.util.Date;
20 import de.dhbwloe.campusapp.CampusAppContext;
21 import de.dhbwloe.campusapp.R;
22 import de.dhbwloe.campusapp.news.NewsItem;
23 import de.dhbwloe.campusapp.vorlesungen.CourseEvent;
26 * Created by pk910 on 27.02.2016.
28 public class NewsListItem {
29 private String sNewsTitle;
30 private String sNewsDescription;
31 private String sNewsLink;
32 private long lNewsDate;
33 private boolean bIsDhbwNews;
34 private boolean bIsEvent;
36 public NewsListItem(NewsItem newsItem, boolean isDhbwNews) {
37 sNewsTitle = newsItem.getTitle();
38 sNewsDescription = newsItem.getSummary();
39 sNewsLink = newsItem.getLink();
40 lNewsDate = newsItem.getTime();
41 bIsDhbwNews = isDhbwNews;
45 public NewsListItem(CourseEvent newsEvent, boolean isDhbwEvent) {
46 sNewsTitle = newsEvent.getEventTitle();
47 sNewsDescription = newsEvent.getEventLocation();
49 lNewsDate = newsEvent.getEventFrom();
50 bIsDhbwNews = isDhbwEvent;
54 public long getTimeDifference(long now) {
55 return Math.abs(now - lNewsDate);
58 public String getTitle() {
62 public String getDescription() {
63 return sNewsDescription;
66 public boolean isDhbwNews() {
70 public String getFormatedDate() {
73 dateFormat = CampusAppContext.getInstance().getResString(R.string.timeformat_news_event);
75 dateFormat = CampusAppContext.getInstance().getResString(R.string.timeformat_news_news);
76 SimpleDateFormat format = new SimpleDateFormat(dateFormat);
77 return format.format(new Date(lNewsDate * 1000));
80 public String getLink() {