use of de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRow in project TumCampusApp by TCA-Team.
the class LecturesListAdapter method getView.
@Override
public View getView(int position, View view, ViewGroup parent) {
ViewHolder holder;
View convertView = view;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.activity_lectures_listview, parent, false);
holder = new ViewHolder();
// set UI elements
holder.tvLectureName = convertView.findViewById(R.id.tvLectureName);
holder.tvTypeSWSSemester = convertView.findViewById(R.id.tvTypeSWSSemester);
holder.tvDozent = convertView.findViewById(R.id.tvDozent);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
LecturesSearchRow lvItem = infoList.get(position);
// if we have something to display - set for each lecture element
if (lvItem != null) {
holder.tvLectureName.setText(lvItem.getTitel());
holder.tvTypeSWSSemester.setText(String.format("%s - %s - %s SWS", lvItem.getStp_lv_art_name(), lvItem.getSemester_id(), lvItem.getDauer_info()));
holder.tvDozent.setText(lvItem.getVortragende_mitwirkende());
}
return convertView;
}
use of de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRow in project TumCampusApp by TCA-Team.
the class LecturesPersonalActivity method onLoadFinished.
@Override
public void onLoadFinished(LecturesSearchRowSet response) {
if (response == null || response.getLehrveranstaltungen() == null) {
// no results found
lvMyLecturesList.setAdapter(new NoResultsAdapter(this));
} else {
// Sort lectures by semester id
List<LecturesSearchRow> lectures = response.getLehrveranstaltungen();
Collections.sort(lectures);
// set ListView to data via the LecturesListAdapter
lvMyLecturesList.setAdapter(LecturesListAdapter.newInstance(this, lectures));
}
}
use of de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRow in project TumCampusApp by TCA-Team.
the class ChatRoomController method createLectureRooms.
/**
* Saves the given lectures into database
*/
public void createLectureRooms(Iterable<LecturesSearchRow> lectures) {
// Create a Set of all existing lectures
List<Integer> roomLvIds = chatRoomDao.getLvIds();
Collection<String> set = new HashSet<>();
for (Integer id : roomLvIds) {
set.add(String.valueOf(id));
}
// Add lectures that are not yet in DB
for (LecturesSearchRow lecture : lectures) {
if (!set.contains(lecture.getStp_lv_nr())) {
chatRoomDao.replaceRoom(ChatRoomDbRow.Companion.fromLecture(lecture));
}
}
}
use of de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRow in project TumCampusApp by TCA-Team.
the class ChatRoomController method onRequestCard.
@Override
public void onRequestCard(Context context) {
// Get all of the users lectures and save them as possible chat rooms
TUMOnlineRequest<LecturesSearchRowSet> requestHandler = new TUMOnlineRequest<>(TUMOnlineConst.Companion.getLECTURES_PERSONAL(), context, true);
Optional<LecturesSearchRowSet> lecturesList = requestHandler.fetch();
if (lecturesList.isPresent()) {
List<LecturesSearchRow> lectures = lecturesList.get().getLehrveranstaltungen();
this.createLectureRooms(lectures);
}
// Join all new chat rooms
if (Utils.getSettingBool(context, Const.AUTO_JOIN_NEW_ROOMS, false)) {
List<String> newRooms = this.getNewUnjoined();
ChatMember currentChatMember = Utils.getSetting(context, Const.CHAT_MEMBER, ChatMember.class);
for (String roomId : newRooms) {
// Join chat room
try {
ChatRoom currentChatRoom = new ChatRoom(roomId);
currentChatRoom = TUMCabeClient.getInstance(context).createRoom(currentChatRoom, ChatVerification.Companion.getChatVerification(context, currentChatMember));
if (currentChatRoom != null) {
this.join(currentChatRoom);
}
} catch (IOException e) {
Utils.log(e, " - error occured while creating the room!");
} catch (NoPrivateKey noPrivateKey) {
return;
}
}
}
// Get all rooms that have unread messages
List<ChatRoomDbRow> rooms = chatRoomDao.getUnreadRooms();
if (!rooms.isEmpty()) {
for (ChatRoomDbRow room : rooms) {
ChatMessagesCard card = new ChatMessagesCard(context, room);
card.apply();
}
}
}
use of de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRow in project TumCampusApp by TCA-Team.
the class CacheManager method importLecturesFromTUMOnline.
/**
* this function allows us to import all lecture items from TUMOnline
*/
private void importLecturesFromTUMOnline() {
// get my lectures
TUMOnlineRequest<LecturesSearchRowSet> requestHandler = new TUMOnlineRequest<>(TUMOnlineConst.Companion.getLECTURES_PERSONAL(), mContext);
if (!shouldRefresh(requestHandler.getRequestURL())) {
return;
}
Optional<LecturesSearchRowSet> lecturesList = requestHandler.fetch();
if (!lecturesList.isPresent()) {
return;
}
List<LecturesSearchRow> lectures = lecturesList.get().getLehrveranstaltungen();
ChatRoomController manager = new ChatRoomController(mContext);
manager.createLectureRooms(lectures);
}
Aggregations