use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatSharedMediaAdapter method setImageData.
private void setImageData(ImageViewHolder viewHolder, int i) {
BaseMessage message = messageArrayList.get(i);
boolean isImageNotSafe = Extensions.getImageModeration(context, message);
String smallUrl = Extensions.getThumbnailGeneration(context, message);
if (smallUrl != null) {
Glide.with(context).asBitmap().load(smallUrl).into(viewHolder.imageView);
} else {
Glide.with(context).asBitmap().load(((MediaMessage) message).getAttachment().getFileUrl()).into(viewHolder.imageView);
}
if (isImageNotSafe) {
viewHolder.imageView.setAlpha(0.3f);
viewHolder.sensitiveLayout.setVisibility(View.VISIBLE);
} else {
viewHolder.imageView.setAlpha(1f);
viewHolder.sensitiveLayout.setVisibility(View.GONE);
}
viewHolder.imageView.setOnClickListener(view -> {
if (isImageNotSafe) {
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle("Unsafe Content");
alert.setIcon(R.drawable.ic_hand);
alert.setMessage("Are you surely want to see this unsafe content");
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MediaUtils.openFile(((MediaMessage) message).getAttachment().getFileUrl(), context);
}
});
alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alert.create().show();
} else {
Intent intent = new Intent(context, CometChatMediaViewActivity.class);
intent.putExtra(UIKitConstants.IntentStrings.NAME, message.getSender().getName());
intent.putExtra(UIKitConstants.IntentStrings.UID, message.getSender().getUid());
intent.putExtra(UIKitConstants.IntentStrings.SENTAT, message.getSentAt());
intent.putExtra(UIKitConstants.IntentStrings.INTENT_MEDIA_MESSAGE, ((MediaMessage) message).getAttachment().getFileUrl());
intent.putExtra(UIKitConstants.IntentStrings.MESSAGE_TYPE, message.getType());
context.startActivity(intent);
}
});
viewHolder.itemView.setTag(R.string.baseMessage, message);
}
use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatSharedImages method setImageAdapter.
/**
* This method is used to setAdapter for Image messages.
* @param baseMessageList is object of List<BaseMessage> which contains list of messages.
* @see CometChatSharedMediaAdapter
*/
private void setImageAdapter(List<BaseMessage> baseMessageList) {
List<BaseMessage> filteredList = removeDeletedMessage(baseMessageList);
messageList.addAll(filteredList);
if (adapter == null) {
adapter = new CometChatSharedMediaAdapter(getContext(), filteredList);
rvFiles.setAdapter(adapter);
} else
adapter.updateMessageList(filteredList);
}
use of com.cometchat.pro.models.BaseMessage in project android-java-chat-push-notification-app by cometchat-pro.
the class MyFirebaseMessagingService method onMessageReceived.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
try {
count++;
json = new JSONObject(remoteMessage.getData());
Log.d(TAG, "JSONObject: " + json.toString());
JSONObject messageData = new JSONObject(json.getString("message"));
BaseMessage baseMessage = CometChatHelper.processMessage(new JSONObject(remoteMessage.getData().get("message")));
if (baseMessage instanceof Call) {
call = (Call) baseMessage;
isCall = true;
}
showNotifcation(baseMessage);
} catch (JSONException e) {
e.printStackTrace();
}
}
Aggregations