Search in sources :

Example 1 with SessionManager

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);
    }
}
Also used : SessionManager(ingage.ingage.managers.SessionManager) TextView(android.widget.TextView)

Example 2 with SessionManager

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);
}
Also used : SessionManager(ingage.ingage.managers.SessionManager) Bundle(android.os.Bundle) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 3 with SessionManager

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();
    }
}
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 4 with SessionManager

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();
    }
}
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 5 with SessionManager

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;
    }
}
Also used : SpectateRoomHandler(ingage.ingage.handlers.SpectateRoomHandler) SessionManager(ingage.ingage.managers.SessionManager) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

SessionManager (ingage.ingage.managers.SessionManager)24 View (android.view.View)7 ExecutionException (java.util.concurrent.ExecutionException)6 TextView (android.widget.TextView)5 ImageView (android.widget.ImageView)4 ChatRoomManager (ingage.ingage.managers.ChatRoomManager)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 Bundle (android.os.Bundle)2 ActionBar (android.support.v7.app.ActionBar)2 ThreadListAdapter (ingage.ingage.adapters.ThreadListAdapter)2 ChatRoomHandler (ingage.ingage.handlers.ChatRoomHandler)2 QueryThreadsHandler (ingage.ingage.handlers.QueryThreadsHandler)2 SpectateRoomHandler (ingage.ingage.handlers.SpectateRoomHandler)2 HashMap (java.util.HashMap)2 FragmentManager (android.app.FragmentManager)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1