use of ingage.ingage.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;
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();
}
}
use of ingage.ingage.handlers.ChatRoomHandler in project iNGAGE by davis123123.
the class FragmentBase method viewRoomStatus.
public String viewRoomStatus(Context context, String type, String thread_id) {
String result = null;
Log.d("VIEW", thread_id);
ChatRoomHandler chatRoomHandler = new ChatRoomHandler(context);
try {
result = chatRoomHandler.execute(type, thread_id, side).get();
Log.d("VIEW", result);
// Toast.makeText(getActivity().getApplicationContext(), "view: " + result, Toast.LENGTH_LONG).show();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
return result;
}
use of ingage.ingage.handlers.ChatRoomHandler in project iNGAGE by davis123123.
the class FragmentBase method joinRoom.
public String joinRoom(Context context, String type, String thread_id, String userJSON) {
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();
Log.d("STATE", "view: " + result);
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
chatRoomManager.updateUserRoomSession(thread_id, side, "false");
return result;
}
use of ingage.ingage.handlers.ChatRoomHandler in project iNGAGE by davis123123.
the class ChatActivity method leaveRoom.
private void leaveRoom() {
HashMap<String, String> chat_user = chatRoomManager.getUserDetails();
String side = chat_user.get(ChatRoomManager.SIDE);
String thread_id = chat_user.get(ChatRoomManager.THREAD_ID);
String spectator = chat_user.get(ChatRoomManager.SPECTATOR);
chatRoomManager.updateTimeRemaining("0");
if (mKickTimer != null) {
mKickTimer.cancel();
mKickTimer = null;
}
if (mThreadEndTimer != null) {
mThreadEndTimer.cancel();
mThreadEndTimer = null;
}
if (spectator.equals("true")) {
String type = "leave_spectate";
String result = null;
HashMap<String, String> user = session.getUserDetails();
String username = user.get(SessionManager.KEY_NAME);
SpectateRoomHandler spectateRoomHandler = new SpectateRoomHandler(getApplicationContext());
try {
result = spectateRoomHandler.execute(type, thread_id, username, side).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
Log.d("SPECTATORSTATE", "text: " + result);
} else {
String type = "leave";
String result = null;
HashMap<String, String> user = session.getUserDetails();
String username = user.get(SessionManager.KEY_NAME);
ChatRoomHandler chatRoomHandler = new ChatRoomHandler(getApplicationContext());
try {
result = chatRoomHandler.execute(type, thread_id, username, side).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
// leave user's session on cache
chatRoomManager.updateUserRoomSession("", "", "");
}
Aggregations