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;
}
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();
}
}
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;
}
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;
}
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);
}
}
Aggregations