Search in sources :

Example 1 with LecturesSearchRowSet

use of de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRowSet 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();
        }
    }
}
Also used : ChatMember(de.tum.in.tumcampusapp.component.ui.chat.model.ChatMember) TUMOnlineRequest(de.tum.in.tumcampusapp.api.tumonline.TUMOnlineRequest) LecturesSearchRowSet(de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRowSet) LecturesSearchRow(de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRow) IOException(java.io.IOException) NoPrivateKey(de.tum.in.tumcampusapp.api.app.exception.NoPrivateKey) ChatRoom(de.tum.in.tumcampusapp.component.ui.chat.model.ChatRoom) ChatRoomDbRow(de.tum.in.tumcampusapp.component.ui.chat.model.ChatRoomDbRow)

Example 2 with LecturesSearchRowSet

use of de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRowSet 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);
}
Also used : TUMOnlineRequest(de.tum.in.tumcampusapp.api.tumonline.TUMOnlineRequest) LecturesSearchRowSet(de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRowSet) LecturesSearchRow(de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRow) ChatRoomController(de.tum.in.tumcampusapp.component.ui.chat.ChatRoomController)

Aggregations

TUMOnlineRequest (de.tum.in.tumcampusapp.api.tumonline.TUMOnlineRequest)2 LecturesSearchRow (de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRow)2 LecturesSearchRowSet (de.tum.in.tumcampusapp.component.tumui.lectures.model.LecturesSearchRowSet)2 NoPrivateKey (de.tum.in.tumcampusapp.api.app.exception.NoPrivateKey)1 ChatRoomController (de.tum.in.tumcampusapp.component.ui.chat.ChatRoomController)1 ChatMember (de.tum.in.tumcampusapp.component.ui.chat.model.ChatMember)1 ChatRoom (de.tum.in.tumcampusapp.component.ui.chat.model.ChatRoom)1 ChatRoomDbRow (de.tum.in.tumcampusapp.component.ui.chat.model.ChatRoomDbRow)1 IOException (java.io.IOException)1