use of ingage.ingage20.helpers.ChatMessageHelper in project iNGAGE by davis123123.
the class ChatArrayAdapter method update.
public void update(ChatMessageHelper newObject, String chat_id, boolean updateBind) {
// get old chatmsg
int position = chatHash.get(chat_id);
Log.d("UPvote state: ", " upvote called");
// update oldmsg with newobject
ChatMessageHelper chatMessageHelper = (ChatMessageHelper) getItem(position);
chatMessageHelper.setMessageDownvote(newObject.getMessageDownvote());
chatMessageHelper.setMessageUpvote(newObject.getMessageUpvote());
chatMessageHelper.setMessageText(newObject.getMessageText());
chatMessageHelper.setMessageTime(newObject.getMessageTime());
voteBind = updateBind;
notifyDataSetChanged();
}
use of ingage.ingage20.helpers.ChatMessageHelper in project iNGAGE by davis123123.
the class ChatFragment method removeDownvote.
@Override
public void removeDownvote(int p) {
ChatMessageHelper chatMessageHelper = (ChatMessageHelper) chatAdapter.getItem(p);
String chat_key = chatMessageHelper.getMessageID();
DatabaseReference message_root = currPageData.child(chat_key);
// get upvote data
DatabaseReference downvote_count = message_root.child("downvotes");
downvote_count.runTransaction(new Transaction.Handler() {
@Override
public Transaction.Result doTransaction(MutableData currentData) {
Log.d("Data", String.valueOf(currentData));
if (currentData.getValue() == null) {
currentData.setValue(0);
} else {
currentData.setValue((Long) currentData.getValue() - 1);
}
// we can also abort by calling Transaction.abort()
return Transaction.success(currentData);
}
// TODO:Error handle here
@Override
public void onComplete(DatabaseError databaseError, boolean b, DataSnapshot dataSnapshot) {
}
});
}
use of ingage.ingage20.helpers.ChatMessageHelper 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);
}
use of ingage.ingage20.helpers.ChatMessageHelper in project iNGAGE by davis123123.
the class ChatFragment method onDownvoteClick.
@Override
public void onDownvoteClick(int p) {
// Log.d("vote" , "down : ");
ChatMessageHelper chatMessageHelper = (ChatMessageHelper) chatAdapter.getItem(p);
String chat_key = chatMessageHelper.getMessageID();
DatabaseReference message_root = currPageData.child(chat_key);
// get upvote data
DatabaseReference downvote_count = message_root.child("downvotes");
downvote_count.runTransaction(new Transaction.Handler() {
@Override
public Transaction.Result doTransaction(MutableData currentData) {
Log.d("Data", String.valueOf(currentData));
if (currentData.getValue() == null) {
currentData.setValue(1);
} else {
currentData.setValue((Long) currentData.getValue() + 1);
}
// we can also abort by calling Transaction.abort()
return Transaction.success(currentData);
}
// TODO:Error handle here
@Override
public void onComplete(DatabaseError databaseError, boolean b, DataSnapshot dataSnapshot) {
}
});
}
use of ingage.ingage20.helpers.ChatMessageHelper 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);
}
Aggregations