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