Search in sources :

Example 1 with ChatRoomManager

use of ingage.ingage.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;
        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.ingage.handlers.ChatRoomHandler) SessionManager(ingage.ingage.managers.SessionManager) ChatRoomManager(ingage.ingage.managers.ChatRoomManager) JSONException(org.json.JSONException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ChatRoomUserHelper(ingage.ingage.helpers.ChatRoomUserHelper) RoomUserAdapter(ingage.ingage.adapters.RoomUserAdapter) JSONObject(org.json.JSONObject) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with ChatRoomManager

use of ingage.ingage.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());
    HashMap<String, String> chatRoomManagerUserDetails = chatRoomManager.getUserDetails();
    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) {
        long secRemaining = secondsRemaining(chatRoomManagerUserDetails.get(ChatRoomManager.TIME_REMAINING));
        endThreadTimer(secRemaining);
        // 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
    }
    HashMap<String, String> chat_user = chatRoomManager.getUserDetails();
    String spectator = chat_user.get(ChatRoomManager.SPECTATOR);
    if (spectator.equals("true")) {
        setSpectateMode();
    }
}
Also used : SessionManager(ingage.ingage.managers.SessionManager) Bundle(android.os.Bundle) ChatRoomManager(ingage.ingage.managers.ChatRoomManager) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar)

Example 3 with ChatRoomManager

use of ingage.ingage.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.ingage.adapters.ChatPageListAdapter) ChatRoomManager(ingage.ingage.managers.ChatRoomManager)

Example 4 with ChatRoomManager

use of ingage.ingage.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.ingage.managers.SessionManager) ChatRoomManager(ingage.ingage.managers.ChatRoomManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 5 with ChatRoomManager

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

the class FragmentBase method onViewCreated.

@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    session = new SessionManager(getActivity().getApplicationContext());
    user = session.getUserDetails();
    chatRoomManager = new ChatRoomManager(getActivity().getApplicationContext());
    swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    msg = (TextView) view.findViewById(R.id.tvMsg);
    icon = (ImageView) view.findViewById(R.id.ivIcon);
    int color = getContext().getResources().getColor(R.color.gray);
    icon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
    // Setup refresh listener which triggers new data loading
    swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    EventBus.getDefault().post(new RefreshEvent());
                    swipeContainer.setRefreshing(false);
                }
            }, 700);
        }
    });
    // Configure the refreshing colors
    swipeContainer.setColorSchemeResources(android.R.color.holo_red_light, android.R.color.darker_gray);
}
Also used : SessionManager(ingage.ingage.managers.SessionManager) ChatRoomManager(ingage.ingage.managers.ChatRoomManager) SpectateRoomHandler(ingage.ingage.handlers.SpectateRoomHandler) ChatRoomHandler(ingage.ingage.handlers.ChatRoomHandler) Handler(android.os.Handler) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

ChatRoomManager (ingage.ingage.managers.ChatRoomManager)5 SessionManager (ingage.ingage.managers.SessionManager)4 View (android.view.View)2 ChatRoomHandler (ingage.ingage.handlers.ChatRoomHandler)2 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)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.ingage.adapters.ChatPageListAdapter)1 RoomUserAdapter (ingage.ingage.adapters.RoomUserAdapter)1 SpectateRoomHandler (ingage.ingage.handlers.SpectateRoomHandler)1 ChatRoomUserHelper (ingage.ingage.helpers.ChatRoomUserHelper)1 ExecutionException (java.util.concurrent.ExecutionException)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1