use of com.abewy.android.apps.klyph.core.fql.Message in project Klyph by jonathangerbaud.
the class MessageDeserializer method deserializeObject.
@Override
public GraphObject deserializeObject(JSONObject data) {
Message message = new Message();
deserializePrimitives(message, data);
message.setAttachment((Attachment) new AttachmentDeserializer().deserializeObject(getJsonObject(data, "attachment")));
return message;
}
use of com.abewy.android.apps.klyph.core.fql.Message in project Klyph by jonathangerbaud.
the class ConversationAdapter method add.
@Override
public void add(GraphObject object) {
if (object instanceof Message) {
final int size = getCount();
Log.d("ConversationAdapter", "add: " + size + " " + lastAdPosition);
if (size - lastAdPosition >= AD_INTERVAL) {
Log.d("ConversationAdapter", "add: add ad");
lastAdPosition = size;
super.add(new AdItem());
}
}
super.add(object);
}
use of com.abewy.android.apps.klyph.core.fql.Message in project Klyph by jonathangerbaud.
the class MessageAdapter method bindData.
@Override
public void bindData(View view, GraphObject data) {
MessageHolder holder = (MessageHolder) getHolder(view);
Message message = (Message) data;
holder.getMessageTextView().setText(EmojiUtil.getSpannableForText(holder.getMessageTextView().getContext(), message.getBody()));
holder.getDateTextView().setText(DateUtil.getShortDateTime(message.getCreated_time()));
// TextViewUtil.setElementClickable(getContext(view), holder.getAuthorName(), message.getAuthor_name(), message.getAuthor_id(), "user");
ImageLoader.display(holder.getAuthorPicture(), message.getAuthor_pic(), KlyphUtil.getPlaceHolder(holder.getAuthorPicture().getContext()));
}
use of com.abewy.android.apps.klyph.core.fql.Message in project Klyph by jonathangerbaud.
the class ConversationAdapter method insert.
@Override
public void insert(GraphObject object, int index) {
if (object instanceof Message) {
final int size = getCount();
Log.d("ConversationAdapter", "insert: " + size + " " + lastAdPosition);
if (size - lastAdPosition >= AD_INTERVAL) {
lastAdPosition = size - 1;
super.insert(new AdItem(), 0);
}
}
super.insert(object, index);
}
use of com.abewy.android.apps.klyph.core.fql.Message in project Klyph by jonathangerbaud.
the class ConversationFragment method onListItemClick.
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
GraphObject object = (GraphObject) getAdapter().getItem(position);
if (object instanceof Message) {
final Message message = (Message) object;
List<String> list = new ArrayList<String>();
int copyText = -1;
int downloadImage = -1;
String body = message.getBody();
if (body.length() > 0) {
list.add(getString(R.string.copy_text));
copyText = list.size() - 1;
Spannable spannable = new SpannableString(body);
Linkify.addLinks(spannable, Linkify.WEB_URLS);
URLSpan[] urls = spannable.getSpans(0, spannable.length(), URLSpan.class);
if (urls.length > 0) {
for (URLSpan urlSpan : urls) {
list.add(urlSpan.getURL());
}
}
}
/*
* if (message.getAttachment() != null)
* {
* list.add(getString(R.string.download_image));
* downloadImage = list.size() - 1;
* }
*/
final int fcopyText = copyText;
final int fdownloadImage = downloadImage;
final String[] items = list.toArray(new String[0]);
// For Api 8 to 10
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (which == fcopyText) {
handleCopyTextAction(message);
} else if (which == fdownloadImage) {
handleDownloadAction(message);
} else {
handleUrlAction(items[which]);
}
}
});
builder.create().show();
}
}
Aggregations