@@ -0,0 +1,1980 @@
+package id.sis.chat.presenter;%0A%0Aimport android.os.Bundle;%0A%0Aimport com.firebase.client.Firebase;%0A%0Aimport java.util.Date;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport id.sis.chat.data.api.SisChatApi;%0Aimport id.sis.chat.data.model.Room;%0Aimport id.zelory.benih.presenter.BenihPresenter;%0A%0A/**%0A * Created on : February 29, 2016%0A * Author     : zetbaitsu%0A * Name       : Zetra%0A * Email      : zetra@mail.ugm.ac.id%0A * GitHub     : https://github.com/zetbaitsu%0A * LinkedIn   : https://id.linkedin.com/in/zetbaitsu%0A */%0Apublic class RoomPresenter extends BenihPresenter%3CRoomPresenter.View%3E %7B%0A%0A    public RoomPresenter(View view) %7B%0A        super(view);%0A    %7D%0A%0A    public void create(String roomName) %7B%0A        view.showLoading();%0A        Firebase api = SisChatApi.getInstance().rooms().push();%0A%0A        Map%3CString, Object%3E data = new HashMap%3C%3E();%0A        data.put(%22roomId%22, api.getKey());%0A        data.put(%22name%22, roomName);%0A        data.put(%22lastMessage%22, %22-%22);%0A        data.put(%22lastSender%22, %22-%22);%0A        data.put(%22lastDate%22, new Date().getTime());%0A%0A        api.updateChildren(data, (firebaseError, firebase) -%3E %7B%0A            if (firebaseError != null) %7B%0A                view.showError(%22Failed to create room!%22);%0A            %7D else %7B%0A                Room room = new Room();%0A                room.setRoomId(api.getKey());%0A                room.setName(roomName);%0A                room.setLastMessage(%22-%22);%0A                room.setLastSender(%22-%22);%0A                room.setLastDate(new Date());%0A                view.onRoomCreated(room);%0A            %7D%0A            view.dismissLoading();%0A        %7D);%0A    %7D%0A%0A    @Override%0A    public void saveState(Bundle bundle) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void loadState(Bundle bundle) %7B%0A%0A    %7D%0A%0A    public interface View extends BenihPresenter.View %7B%0A        void onRoomCreated(Room room);%0A%0A        void showRooms(List%3CRoom%3E rooms);%0A%0A        void onRoomUpdated(Room room);%0A%0A        void onRoomDeleted(Room room);%0A    %7D%0A%7D%0A

Handle create room