Search in sources :

Example 1 with Message

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;
}
Also used : Message(com.abewy.android.apps.klyph.core.fql.Message)

Example 2 with 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);
}
Also used : Message(com.abewy.android.apps.klyph.core.fql.Message) AdItem(com.abewy.klyph.items.AdItem)

Example 3 with Message

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()));
}
Also used : MessageHolder(com.abewy.android.apps.klyph.adapter.holder.MessageHolder) Message(com.abewy.android.apps.klyph.core.fql.Message)

Example 4 with Message

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);
}
Also used : Message(com.abewy.android.apps.klyph.core.fql.Message) AdItem(com.abewy.klyph.items.AdItem)

Example 5 with Message

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();
    }
}
Also used : AlertDialog(android.app.AlertDialog) Message(com.abewy.android.apps.klyph.core.fql.Message) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) URLSpan(android.text.style.URLSpan) SpannableString(android.text.SpannableString) Spannable(android.text.Spannable)

Aggregations

Message (com.abewy.android.apps.klyph.core.fql.Message)5 AdItem (com.abewy.klyph.items.AdItem)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 Spannable (android.text.Spannable)1 SpannableString (android.text.SpannableString)1 URLSpan (android.text.style.URLSpan)1 MessageHolder (com.abewy.android.apps.klyph.adapter.holder.MessageHolder)1 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)1 ArrayList (java.util.ArrayList)1