+/* News.java
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
package de.dhbwloe.campusapp.fragments;
-
-
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
private View view;
private NewsListAdapter listAdapter;
- private ArrayList<NewsListItem> newsListItems = new ArrayList<NewsListItem>();
+ protected ArrayList<NewsListItem> newsListItems = new ArrayList<NewsListItem>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@Override
public void onResume() {
super.onResume();
- refreshNewsItems();
+ if(view != null)
+ refreshNewsItems();
}
- private void refreshNewsItems() {
+ protected void refreshNewsItems() {
newsListItems.clear();
CheckBox showDhbwNewsChkbok = (CheckBox) view.findViewById(R.id.showDhbwNews);
Collections.sort(newsListItems, new Comparator<NewsListItem>() {
@Override
public int compare(NewsListItem item2, NewsListItem item1) {
- long now = (new Date()).getTime()/1000;
+ long now = (new Date()).getTime() / 1000;
return (int) (item2.getTimeDifference(now) - item1.getTimeDifference(now));
}
});
- listAdapter.notifyDataSetChanged();
+ if(listAdapter != null)
+ listAdapter.notifyDataSetChanged();
}
- private void loadNewsSource(String sourceName, boolean isDhbw) {
+ protected void loadNewsSource(String sourceName, boolean isDhbw) {
long now = (new Date()).getTime() / 1000;
NewsItem[] news = AppContext.getDatabaseManager().getNewsItems(sourceName, now, now - (86400 * 30 * 6)); // load 6 month
}
}
- private void loadEventsSource(String sourceName, boolean isDhbw) {
+ protected void loadEventsSource(String sourceName, boolean isDhbw) {
long now = (new Date()).getTime() / 1000;
CourseEvent[] events = AppContext.getDatabaseManager().getCourseCalendarTimetable(sourceName, now, 30 * 6); // load 6 month