Search in sources :

Example 6 with ChatRoomManager

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

Example 7 with ChatRoomManager

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

the class ChatActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    session = new SessionManager(getApplicationContext());
    HashMap<String, String> user = session.getUserDetails();
    username = user.get(SessionManager.KEY_NAME);
    chatRoomManager = new ChatRoomManager(getApplicationContext());
    timerTv = (TextView) findViewById(R.id.timertv);
    useCoinBt = (Button) findViewById(R.id.cooldownButton);
    textArea = (LinearLayout) findViewById(R.id.text_area);
    textButtons = (LinearLayout) findViewById(R.id.text_right);
    timerTv.setVisibility(View.GONE);
    useCoinBt.setVisibility(View.GONE);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        String title = extras.getString("title");
        Log.i("clicked title: ", title);
        ActionBar mActionBarToolbar = getSupportActionBar();
        mActionBarToolbar.setTitle(title);
    }
    useCoinBt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.d("Click", "clicked");
            useCoin();
        }
    });
    // click to use token
    // getuser details
    HashMap<String, String> chat = chatRoomManager.getUserDetails();
    thread_id = chat.get(ChatRoomManager.THREAD_ID);
    user_side = chat.get(ChatRoomManager.SIDE);
    if (user_side != null) {
        // fifteen minutes of inactivity will kick user out
        kickTimer(900000);
        Log.d("STATE", "side: " + user_side);
    }
    // Does not kick out spectator with timer
    // ENTER MESSAGES WITH @TAGS
    textField = (EditText) findViewById(R.id.msgField);
    textChangeListener();
    setKeyBoardListener();
    // thread id for root of comments tree
    root = FirebaseDatabase.getInstance().getReference().child(thread_id);
    // TAKES TIME TO TRANSACT
    pageCount(root);
    // add messages to recycler view by clicking send
    addButton = (Button) findViewById(R.id.sendMessageButton);
    if (addButton != null) {
        addButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                sendMsg();
            }
        });
    // click to send message
    // calls event listener to update message in realtime
    // eventListener(root);
    }
    HashMap<String, String> chat_user = chatRoomManager.getUserDetails();
    String spectator = chat_user.get(ChatRoomManager.SPECTATOR);
    if (spectator.equals("true")) {
        setSpectateMode();
    }
}
Also used : SessionManager(ingage.ingage20.managers.SessionManager) Bundle(android.os.Bundle) ChatRoomManager(ingage.ingage20.managers.ChatRoomManager) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar)

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