use of ingage.ingage.managers.SessionManager in project iNGAGE by davis123123.
the class NavigationDrawer method updateUserName.
private void updateUserName(final AppCompatActivity activity) {
final SessionManager sessionManager = new SessionManager(mContext);
final TextView userNameView = (TextView) activity.findViewById(R.id.userName);
if (!sessionManager.isLoggedIn()) {
// Not signed in
userNameView.setText(activity.getString(R.string.main_nav_menu_default_user_text));
// userNameView.setBackgroundColor(activity.getResources().getColor(R.color.nav_drawer_no_user_background));
return;
}
HashMap<String, String> user = sessionManager.getUserDetails();
final String userName = user.get(SessionManager.KEY_NAME);
if (userName != null) {
userNameView.setText(userName);
}
}
use of ingage.ingage.managers.SessionManager in project iNGAGE by davis123123.
the class UserProfileActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_profile);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
SessionManager session = new SessionManager(getApplicationContext());
HashMap<String, String> info = session.getUserDetails();
// viewing other profiles
Bundle extras = getIntent().getExtras();
if (extras != null) {
username = extras.getString("USER");
// Toast.makeText(getApplicationContext(), username, Toast.LENGTH_LONG).show();
} else
// view own profile
username = info.get(SessionManager.KEY_NAME);
curr_avatar = (ImageView) findViewById(R.id.profile_img);
if (username.equals(info.get(SessionManager.KEY_NAME))) {
curr_avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), ChangeAvatarActivity.class);
finish();
startActivity(intent);
}
});
}
getSupportActionBar().setTitle(username);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
downloadAvatar();
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
use of ingage.ingage.managers.SessionManager 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.SessionManager 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.SessionManager in project iNGAGE by davis123123.
the class ChatActivity method onResume.
@Override
public void onResume() {
super.onResume();
Log.d("RESUMECHAT", "textRESUME ");
HashMap<String, String> chat_user = chatRoomManager.getUserDetails();
String spectator = chat_user.get(ChatRoomManager.SPECTATOR);
// check from cache is user is spectator
if (spectator.equals("true") && paused) {
String type = "spectate";
session = new SessionManager(getApplicationContext());
HashMap<String, String> user = session.getUserDetails();
String username = user.get(SessionManager.KEY_NAME);
SpectateRoomHandler spectateRoomHandler = new SpectateRoomHandler(getApplicationContext());
String result;
setSpectateMode();
try {
result = spectateRoomHandler.execute(type, thread_id, username).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
paused = false;
}
}
Aggregations