Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom click listener #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.slyce.messaging.message;

import android.content.Context;
import android.view.View;

import it.slyce.messaging.message.messageItem.MessageItem;
import it.slyce.messaging.message.messageItem.externalUser.media.MessageExternalUserMediaItem;
Expand All @@ -12,6 +13,8 @@
public class MediaMessage extends Message {
private String url;

public View.OnClickListener onClickListener;

public String getUrl() {
return url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import com.bumptech.glide.Glide;

import it.slyce.messaging.ViewImageActivity;
import it.slyce.messaging.message.MediaMessage;
import it.slyce.messaging.message.MessageSource;
import it.slyce.messaging.utils.MediaUtils;
import it.slyce.messaging.utils.DateUtils;
import it.slyce.messaging.ViewImageActivity;
import it.slyce.messaging.message.messageItem.MessageItem;
import it.slyce.messaging.message.messageItem.MessageItemType;
import it.slyce.messaging.message.messageItem.MessageViewHolder;
import it.slyce.messaging.utils.DateUtils;
import it.slyce.messaging.utils.MediaUtils;

/**
* Created by matthewpage on 6/27/16.
Expand Down Expand Up @@ -60,15 +60,19 @@ public void onClick(View view) {
}
});

messageMediaViewHolder.media.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, ViewImageActivity.class);
intent.putExtra("URL", mediaUrl);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
});
if (getMediaMessage().onClickListener != null) {
messageMediaViewHolder.media.setOnClickListener(getMediaMessage().onClickListener);
} else {
messageMediaViewHolder.media.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, ViewImageActivity.class);
intent.putExtra("URL", mediaUrl);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
});
}

messageMediaViewHolder.avatar.setVisibility(isFirstConsecutiveMessageFromSource && !TextUtils.isEmpty(avatarUrl) ? View.VISIBLE : View.INVISIBLE);
messageMediaViewHolder.avatarContainer.setVisibility(isFirstConsecutiveMessageFromSource ? View.VISIBLE : View.INVISIBLE);
Expand Down