Search in sources :

Example 1 with ChatRoomManager

use of ingage.ingage20.managers.ChatRoomManager in project iNGAGE by davis123123.

the class ChatFragment method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    View v = create(inflater, container, savedInstanceState);
    // thread id for root of comments tree
    // getuser details
    chatRoomManager = new ChatRoomManager(getContext());
    HashMap<String, String> chat = chatRoomManager.getUserDetails();
    thread_id = chat.get(ChatRoomManager.THREAD_ID);
    user_side = chat.get(ChatRoomManager.SIDE);
    root = FirebaseDatabase.getInstance().getReference().child(thread_id);
    session = new SessionManager(getContext());
    HashMap<String, String> user = session.getUserDetails();
    username = user.get(SessionManager.KEY_NAME);
    username = user.get(SessionManager.KEY_NAME);
    return v;
}
Also used : SessionManager(ingage.ingage20.managers.SessionManager) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with ChatRoomManager

use of ingage.ingage20.managers.ChatRoomManager 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 3 with ChatRoomManager

use of ingage.ingage20.managers.ChatRoomManager 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 4 with ChatRoomManager

use of ingage.ingage20.managers.ChatRoomManager in project iNGAGE by davis123123.

the class ChatPageListFragment method create.

public View create(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_page_list, container, false);
    chatRoomManager = new ChatRoomManager(getContext());
    chatPageListAdapter = new ChatPageListAdapter(this, getContext());
    chat = chatRoomManager.getUserDetails();
    thread_id = chat.get(ChatRoomManager.THREAD_ID);
    root = FirebaseDatabase.getInstance().getReference().child(thread_id);
    chatPageListAdapter.setItemClickCallback(this);
    pageEventListener(root);
    return rootView;
}
Also used : ChatPageListAdapter(ingage.ingage20.adapters.ChatPageListAdapter) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager)

Example 5 with ChatRoomManager

use of ingage.ingage20.managers.ChatRoomManager in project iNGAGE by davis123123.

the class FragmentBase method spectate.

public void spectate(int p) {
    ThreadsHelper threadsHelper = (ThreadsHelper) threadListAdapter.getItem(p);
    String thread_id = threadsHelper.getThread_id();
    String type = "spectate";
    session = new SessionManager(getActivity().getApplicationContext());
    HashMap<String, String> user = session.getUserDetails();
    String username = user.get(SessionManager.KEY_NAME);
    SpectateRoomHandler spectateRoomHandler = new SpectateRoomHandler(getActivity().getApplicationContext());
    try {
        // Log.d("JOINSPECTATE", "yes");
        result = spectateRoomHandler.execute(type, thread_id, username).get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    if (result.equals("Spectate room failed")) {
        Toast.makeText(getActivity(), "spectate room failed!", Toast.LENGTH_LONG).show();
    } else {
        chatRoomManager = new ChatRoomManager(getActivity().getApplicationContext());
        chatRoomManager.updateUserRoomSession(thread_id, null, "true");
        goToChat(result);
    }
}
Also used : SpectateRoomHandler(ingage.ingage20.handlers.SpectateRoomHandler) SessionManager(ingage.ingage20.managers.SessionManager) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager) ExecutionException(java.util.concurrent.ExecutionException) ThreadsHelper(ingage.ingage20.helpers.ThreadsHelper)

Aggregations

ChatRoomManager (ingage.ingage20.managers.ChatRoomManager)7 SessionManager (ingage.ingage20.managers.SessionManager)5 ExecutionException (java.util.concurrent.ExecutionException)4 ChatRoomHandler (ingage.ingage20.handlers.ChatRoomHandler)3 View (android.view.View)2 Bundle (android.os.Bundle)1 ActionBar (android.support.v7.app.ActionBar)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TextView (android.widget.TextView)1 ChatPageListAdapter (ingage.ingage20.adapters.ChatPageListAdapter)1 RoomUserAdapter (ingage.ingage20.adapters.RoomUserAdapter)1 SpectateRoomHandler (ingage.ingage20.handlers.SpectateRoomHandler)1 ChatRoomUserHelper (ingage.ingage20.helpers.ChatRoomUserHelper)1 ThreadsHelper (ingage.ingage20.helpers.ThreadsHelper)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1