Search in sources :

Example 1 with ChatFeaturesHandler

use of ingage.ingage20.handlers.ChatFeaturesHandler in project iNGAGE by davis123123.

the class ChatFragment method insertVote.

@Override
public void insertVote(int p, String prev_voted, String vote) {
    String type = "insert_vote";
    ChatFeaturesHandler chatFeaturesHandler = new ChatFeaturesHandler(getContext());
    ChatMessageHelper chatMessageHelper = (ChatMessageHelper) chatAdapter.getItem(p);
    // sets user's vote to memory
    chatMessageHelper.setUserVote(vote);
    // username is messageBy
    String messageBy = chatMessageHelper.getMessageUser();
    Log.d("insertvote", type + vote + prev_voted);
    String chat_id = chatMessageHelper.getMessageID();
    String chat_side = chatMessageHelper.getSide();
    HashMap<String, String> chat = chatRoomManager.getUserDetails();
    String thread_id = chat.get(ChatRoomManager.THREAD_ID);
    session = new SessionManager(getContext());
    HashMap<String, String> user = session.getUserDetails();
    // chatuser is current user of app
    String chat_user = user.get(SessionManager.KEY_NAME);
    // insert vote into target user profile and own profile
    Log.d("insertvote", chat_user);
    String result = "";
    try {
        result = chatFeaturesHandler.execute(type, messageBy, thread_id, prev_voted, chat_id, vote, chat_side, chat_user).get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
// Log.d("insertvote", result);
}
Also used : ChatMessageHelper(ingage.ingage20.helpers.ChatMessageHelper) SessionManager(ingage.ingage20.managers.SessionManager) ExecutionException(java.util.concurrent.ExecutionException) ChatFeaturesHandler(ingage.ingage20.handlers.ChatFeaturesHandler)

Example 2 with ChatFeaturesHandler

use of ingage.ingage20.handlers.ChatFeaturesHandler in project iNGAGE by davis123123.

the class ChatFragment method onAvatarClick.

// inserts vote in mysql database
@Override
public void onAvatarClick(int p) {
    ChatFeaturesHandler chatFeaturesHandler = new ChatFeaturesHandler(getContext());
    ChatMessageHelper chatMessageHelper = (ChatMessageHelper) chatAdapter.getItem(p);
    String user = chatMessageHelper.getMessageUser();
    // Log.d("AvatarClick", chatMessageHelper.getMessageUser());
    chatActivity.startProfileActivity(user);
}
Also used : ChatMessageHelper(ingage.ingage20.helpers.ChatMessageHelper) ChatFeaturesHandler(ingage.ingage20.handlers.ChatFeaturesHandler)

Example 3 with ChatFeaturesHandler

use of ingage.ingage20.handlers.ChatFeaturesHandler in project iNGAGE by davis123123.

the class ChatActivity method sendCoin.

private void sendCoin() {
    String type = "send_coin";
    String result;
    ChatFeaturesHandler chatFeaturesHandler = new ChatFeaturesHandler(getApplicationContext());
    try {
        result = chatFeaturesHandler.execute(type, targetUser).get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
}
Also used : ExecutionException(java.util.concurrent.ExecutionException) ChatFeaturesHandler(ingage.ingage20.handlers.ChatFeaturesHandler)

Example 4 with ChatFeaturesHandler

use of ingage.ingage20.handlers.ChatFeaturesHandler in project iNGAGE by davis123123.

the class ChatActivity method insertVote.

@Override
public void insertVote(int p, String prev_voted, String vote) {
    String type = "insert_vote";
    ChatFeaturesHandler chatFeaturesHandler = new ChatFeaturesHandler(getApplicationContext());
    ChatMessageHelper chatMessageHelper = (ChatMessageHelper) chatAdapter.getItem(p);
    String chat_user = chatMessageHelper.getMessageUser();
    Log.d("insertvote", type + chat_user + vote + prev_voted);
    chatFeaturesHandler.execute(type, chat_user, vote, prev_voted);
}
Also used : ChatMessageHelper(ingage.ingage20.helpers.ChatMessageHelper) ChatFeaturesHandler(ingage.ingage20.handlers.ChatFeaturesHandler)

Example 5 with ChatFeaturesHandler

use of ingage.ingage20.handlers.ChatFeaturesHandler in project iNGAGE by davis123123.

the class ChatActivity method useCoin.

private void useCoin() {
    String type = "use_coin";
    String result = "";
    HashMap<String, String> chat_user = session.getUserDetails();
    String username = chat_user.get(SessionManager.KEY_NAME);
    ChatFeaturesHandler chatFeaturesHandler = new ChatFeaturesHandler(getApplicationContext());
    try {
        result = chatFeaturesHandler.execute(type, username).get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
    if (result.equals("success")) {
        if (mCountDownTimer != null)
            mCountDownTimer.cancel();
        if (currentCooldown > 30000) {
            timer(currentCooldown - 30000);
        }
    } else {
        // tell user no coins left
        new AlertDialog.Builder(this).setTitle("Sorry you are out of coins!").setMessage("Try again when you get tagged!").setIcon(android.R.drawable.ic_dialog_alert).show();
    }
}
Also used : ExecutionException(java.util.concurrent.ExecutionException) ChatFeaturesHandler(ingage.ingage20.handlers.ChatFeaturesHandler)

Aggregations

ChatFeaturesHandler (ingage.ingage20.handlers.ChatFeaturesHandler)5 ChatMessageHelper (ingage.ingage20.helpers.ChatMessageHelper)3 ExecutionException (java.util.concurrent.ExecutionException)3 SessionManager (ingage.ingage20.managers.SessionManager)1