use of ingage.ingage.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);
}
use of ingage.ingage.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.ingage.helpers.ChatMessageHelper in project iNGAGE by davis123123.
the class ChatFragment method removeUpvote.
@Override
public void removeUpvote(int p) {
ChatMessageHelper chatMessageHelper = (ChatMessageHelper) chatAdapter.getItem(p);
String chat_key = chatMessageHelper.getMessageID();
DatabaseReference message_root = currPageData.child(chat_key);
// get upvote data
DatabaseReference upvote_count = message_root.child("upvotes");
upvote_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.ingage.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.ingage.helpers.ChatMessageHelper in project iNGAGE by davis123123.
the class ChatArrayAdapter method getItemViewType.
@Override
public int getItemViewType(int position) {
// final Object dataObj = list.get(position);
ChatMessageHelper chatMessageHelper = (ChatMessageHelper) getItem(position);
String name = chatMessageHelper.getMessageUser();
if (list.get(position).getSide().equals("agree")) {
if (name.equals(username))
return 0;
else
return 1;
} else if (list.get(position).getSide().equals("disagree")) {
if (name.equals(username))
return 2;
else
return 3;
}
return -1;
}
Aggregations