Android Open Source - Stack-Chat Room






From Project

Back to project page Stack-Chat.

License

The source code is released under:

MIT License

If you think the Android project Stack-Chat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.noahhuppert.stackchat.models;
/*from  w  w  w  .jav  a 2  s  . c  o  m*/
/**
 * Created by Noah Huppert on 11/9/2014.
 */

import java.util.ArrayList;

/**
 * A StackOverflow chat room
 */
public class Room {
    /**
     * StackOverflow room Id
     */
    private int id;

    /**
     * A list of all users in the room
     */
    private ArrayList<User> users;

    /**
     * A list of all messages in the room
     */
    private ArrayList<Message> messages;

    /**
     * Creates a new room
     * @param id {@link com.noahhuppert.stackchat.models.Room#id}
     */
    public Room(int id){
        this.id = id;
        users = new ArrayList<User>();
        messages = new ArrayList<Message>();
    }

    /* Getters */
    /**
     * Gets the {@link com.noahhuppert.stackchat.models.Room#id}
     * @return {@link com.noahhuppert.stackchat.models.Room#id}
     */
    public int getId() {
        return id;
    }

    /**
     * Gets the {@link com.noahhuppert.stackchat.models.Room#users}
     * @return {@link com.noahhuppert.stackchat.models.Room#users}
     */
    public ArrayList<User> getUsers() {
        return users;
    }

    /**
     * Gets the {@link com.noahhuppert.stackchat.models.Room#messages}
     * @return {@link com.noahhuppert.stackchat.models.Room#messages}
     */
    public ArrayList<Message> getMessages() {
        return messages;
    }

    /**
     * Get message by {@link com.noahhuppert.stackchat.models.Message#id}
     * @param messageId {@link com.noahhuppert.stackchat.models.Message#id}
     * @return The message, or null of none are found
     */
    public Message getMessageById(int messageId){
        for(Message message : getMessages()){
            if(message.getId() == messageId){
                return message;
            }
        }

        return null;
    }

    /* Setters */
    /**
     * Sets the {@link com.noahhuppert.stackchat.models.Room#id}
     * @param id Value to set the {@link com.noahhuppert.stackchat.models.Room#id} to
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * Sets the {@link com.noahhuppert.stackchat.models.Room#users}
     * @param users Value to set the {@link com.noahhuppert.stackchat.models.Room#users} to
     */
    public void setUsers(ArrayList<User> users) {
        this.users = users;
    }

    /**
     * Sets the {@link com.noahhuppert.stackchat.models.Room#messages}
     * @param messages Value to set the {@link com.noahhuppert.stackchat.models.Room#messages} to
     */
    public void setMessages(ArrayList<Message> messages) {
        this.messages = messages;
    }

    public void addMessage(Message message){
        getMessages().add(message);
    }
}




Java Source Code List

com.noahhuppert.stackchat.ApplicationTest.java
com.noahhuppert.stackchat.MainActivity.java
com.noahhuppert.stackchat.MessagesRecyclerViewAdapter.java
com.noahhuppert.stackchat.controllers.HeaderBuilder.java
com.noahhuppert.stackchat.controllers.JellyKitNotificationController.java
com.noahhuppert.stackchat.controllers.NotificationController.java
com.noahhuppert.stackchat.controllers.PopNotificationController.java
com.noahhuppert.stackchat.fragments.RoomFragment.java
com.noahhuppert.stackchat.models.KVPair.java
com.noahhuppert.stackchat.models.Message.java
com.noahhuppert.stackchat.models.Room.java
com.noahhuppert.stackchat.models.User.java
com.noahhuppert.stackchat.modules.BaseStackChatModule.java
com.noahhuppert.stackchat.modules.StackChatModule.java
com.noahhuppert.stackchat.modules.StackChatModule.java
com.noahhuppert.stackchat.tasks.GetMessagesTask.java
com.noahhuppert.stackchat.tasks.UpdateRoomMessagesTask.java