Search in sources :

Example 1 with ChatRoomHandler

use of ingage.ingage20.handlers.ChatRoomHandler in project iNGAGE by davis123123.

the class FragmentBase method viewRoomStatus.

public String viewRoomStatus(Context context, String type, String thread_id) {
    session = new SessionManager(getActivity().getApplicationContext());
    String result = null;
    ChatRoomHandler chatRoomHandler = new ChatRoomHandler(context);
    try {
        result = chatRoomHandler.execute(type, thread_id, side).get();
        Log.d("STATE", "view: " + result);
    // Toast.makeText(getActivity().getApplicationContext(), "view: " + store, Toast.LENGTH_LONG).show();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    return result;
}
Also used : ChatRoomHandler(ingage.ingage20.handlers.ChatRoomHandler) SessionManager(ingage.ingage20.managers.SessionManager) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with ChatRoomHandler

use of ingage.ingage20.handlers.ChatRoomHandler in project iNGAGE by davis123123.

the class FrontPageFragment method viewRoomStatus.

public String viewRoomStatus(Context context, String type, String thread_id) {
    session = new SessionManager(getActivity().getApplicationContext());
    HashMap<String, String> user = session.getUserDetails();
    String result = null;
    ChatRoomHandler chatRoomHandler = new ChatRoomHandler(context);
    try {
        result = chatRoomHandler.execute(type, thread_id, side).get();
        Log.d("STATE", "view: " + result);
    //Toast.makeText(getActivity().getApplicationContext(), "view: " + store, Toast.LENGTH_LONG).show();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    return result;
}
Also used : ChatRoomHandler(ingage.ingage20.handlers.ChatRoomHandler) SessionManager(ingage.ingage20.managers.SessionManager) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with ChatRoomHandler

use of ingage.ingage20.handlers.ChatRoomHandler in project iNGAGE by davis123123.

the class RoomUsersActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_room_users);
    String type = "check";
    String json_string = "";
    chatRoomManager = new ChatRoomManager(getApplicationContext());
    HashMap<String, String> chatroom = chatRoomManager.getUserDetails();
    String thread_id = chatroom.get(ChatRoomManager.THREAD_ID);
    chatRoomHandler = new ChatRoomHandler(getApplicationContext());
    sessionManager = new SessionManager(getApplicationContext());
    HashMap<String, String> user = sessionManager.getUserDetails();
    ownUsername = user.get(SessionManager.KEY_NAME);
    roomUserRecyclerView = (RecyclerView) findViewById(R.id.rv_posts);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    roomUserRecyclerView.setLayoutManager(layoutManager);
    roomUserAdapter = new RoomUserAdapter(this);
    roomUserRecyclerView.setAdapter(roomUserAdapter);
    try {
        json_string = chatRoomHandler.execute(type, thread_id).get();
        Log.d("CHECK", "result : " + json_string);
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    try {
        jsonObject = new JSONObject(json_string);
        jsonArray = jsonObject.getJSONArray("users");
        int count = 0;
        String username, token;
        username = "-";
        while (count < jsonArray.length()) {
            JSONObject JO = jsonArray.getJSONObject(count);
            username = JO.getString("username");
            token = JO.getString("token");
            ChatRoomUserHelper chatRoomUserHelper = new ChatRoomUserHelper(username, token);
            if (!ownUsername.equals(chatRoomUserHelper.getUsername())) {
                roomUserAdapter.add(chatRoomUserHelper);
            }
            count++;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : ChatRoomHandler(ingage.ingage20.handlers.ChatRoomHandler) SessionManager(ingage.ingage20.managers.SessionManager) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager) JSONException(org.json.JSONException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ChatRoomUserHelper(ingage.ingage20.helpers.ChatRoomUserHelper) RoomUserAdapter(ingage.ingage20.adapters.RoomUserAdapter) JSONObject(org.json.JSONObject) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with ChatRoomHandler

use of ingage.ingage20.handlers.ChatRoomHandler in project iNGAGE by davis123123.

the class FrontPageFragment method joinRoom.

public String joinRoom(Context context, String type, String thread_id, String userJSON) {
    HashMap<String, String> user = session.getUserDetails();
    String username = user.get(SessionManager.KEY_NAME);
    String token = MainActivity.appToken;
    String result = null;
    ChatRoomHandler chatRoomHandler = new ChatRoomHandler(context);
    try {
        result = chatRoomHandler.execute(type, thread_id, username, token, side).get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    chatRoomManager = new ChatRoomManager(getActivity().getApplicationContext());
    chatRoomManager.updateUserRoomSession(thread_id, side);
    return result;
}
Also used : ChatRoomHandler(ingage.ingage20.handlers.ChatRoomHandler) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager) ExecutionException(java.util.concurrent.ExecutionException)

Example 5 with ChatRoomHandler

use of ingage.ingage20.handlers.ChatRoomHandler in project iNGAGE by davis123123.

the class FragmentBase method joinRoom.

public String joinRoom(Context context, String type, String thread_id, String userJSON) {
    session = new SessionManager(getActivity().getApplicationContext());
    HashMap<String, String> user = session.getUserDetails();
    String username = user.get(SessionManager.KEY_NAME);
    String token = MainActivity.appToken;
    String result = null;
    ChatRoomHandler chatRoomHandler = new ChatRoomHandler(context);
    try {
        result = chatRoomHandler.execute(type, thread_id, username, token, side).get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    chatRoomManager = new ChatRoomManager(getActivity().getApplicationContext());
    chatRoomManager.updateUserRoomSession(thread_id, side, "false");
    return result;
}
Also used : ChatRoomHandler(ingage.ingage20.handlers.ChatRoomHandler) SessionManager(ingage.ingage20.managers.SessionManager) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ChatRoomHandler (ingage.ingage20.handlers.ChatRoomHandler)6 ExecutionException (java.util.concurrent.ExecutionException)6 SessionManager (ingage.ingage20.managers.SessionManager)4 ChatRoomManager (ingage.ingage20.managers.ChatRoomManager)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RoomUserAdapter (ingage.ingage20.adapters.RoomUserAdapter)1 SpectateRoomHandler (ingage.ingage20.handlers.SpectateRoomHandler)1 ChatRoomUserHelper (ingage.ingage20.helpers.ChatRoomUserHelper)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1