Search in sources :

Example 1 with TopicDetail

use of com.applozic.mobicomkit.feed.TopicDetail in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method updateContextBasedGroup.

public void updateContextBasedGroup() {
    if (channel != null) {
        Channel channelInfo = ChannelService.getInstance(getActivity()).getChannelInfo(channel.getKey());
        if ((Channel.GroupType.GROUPOFTWO.getValue().equals(channelInfo.getType())) && channel.isContextBasedChat()) {
            Conversation conversation = new Conversation();
            TopicDetail topic = new TopicDetail();
            topic.setTitle(channelInfo.getMetadata().get(Channel.GroupMetaDataType.TITLE.getValue()));
            topic.setSubtitle(channelInfo.getMetadata().get(Channel.GroupMetaDataType.PRICE.getValue()));
            topic.setLink(channelInfo.getMetadata().get(Channel.GroupMetaDataType.LINK.getValue()));
            conversation.setTopicDetail(topic.getJson());
            conversationList.get(0).setTopicDetail(topic.getJson());
            applozicContextSpinnerAdapter.notifyDataSetChanged();
        }
    }
}
Also used : TopicDetail(com.applozic.mobicomkit.feed.TopicDetail) Channel(com.applozic.mobicommons.people.channel.Channel) Conversation(com.applozic.mobicommons.people.channel.Conversation)

Example 2 with TopicDetail

use of com.applozic.mobicomkit.feed.TopicDetail in project Applozic-Android-SDK by AppLozic.

the class FileClientService method downloadProductImage.

// Cleanup: private
/**
 * @deprecated This method has been deprecated and will be removed soon. Conversations are being deprecated.
 */
@Deprecated
public Bitmap downloadProductImage(Conversation conversation) {
    TopicDetail topicDetail = (TopicDetail) GsonUtils.getObjectFromJson(conversation.getTopicDetail(), TopicDetail.class);
    if (TextUtils.isEmpty(topicDetail.getLink())) {
        return null;
    }
    HttpURLConnection connection = null;
    MarkStream inputStream = null;
    try {
        if (conversation != null) {
            connection = openHttpConnection(topicDetail.getLink());
        }
        if (connection != null) {
            if (connection.getResponseCode() == 200) {
                inputStream = new MarkStream(connection.getInputStream());
                BitmapFactory.Options optionsBitmap = new BitmapFactory.Options();
                optionsBitmap.inJustDecodeBounds = true;
                inputStream.allowMarksToExpire(false);
                long mark = inputStream.setPos(MARK);
                BitmapFactory.decodeStream(inputStream, null, optionsBitmap);
                inputStream.resetPos(mark);
                optionsBitmap.inJustDecodeBounds = false;
                optionsBitmap.inSampleSize = ImageUtils.calculateInSampleSize(optionsBitmap, 100, 50);
                Bitmap attachedImage = BitmapFactory.decodeStream(inputStream, null, optionsBitmap);
                inputStream.allowMarksToExpire(true);
                return attachedImage;
            } else {
                return null;
            }
        }
    } catch (FileNotFoundException ex) {
        Utils.printLog(context, TAG, "Image not found on server: " + ex.getMessage());
    } catch (Exception ex) {
        Utils.printLog(context, TAG, "Exception fetching file from server: " + ex.getMessage());
    } catch (Throwable t) {
    } finally {
        if (connection != null) {
            connection.disconnect();
        }
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return null;
}
Also used : Bitmap(android.graphics.Bitmap) HttpURLConnection(java.net.HttpURLConnection) TopicDetail(com.applozic.mobicomkit.feed.TopicDetail) FileNotFoundException(java.io.FileNotFoundException) BitmapFactory(android.graphics.BitmapFactory) IOException(java.io.IOException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 3 with TopicDetail

use of com.applozic.mobicomkit.feed.TopicDetail in project Applozic-Android-SDK by AppLozic.

the class MainActivity method buildConversation.

private Conversation buildConversation() {
    Conversation conversation = new Conversation();
    conversation.setUserId("usertest2");
    conversation.setTopicId("Topic#Id#Test");
    TopicDetail topic = new TopicDetail();
    topic.setTitle(getResources().getString(R.string.TestTopic2));
    topic.setSubtitle(getResources().getString(R.string.Topic_1));
    topic.setLink("https://www.applozic.com/resources/sidebox/images/applozic.png");
    topic.setKey1(getResources().getString(R.string.Qty));
    topic.setValue1("1000");
    topic.setKey2(getResources().getString(R.string.Price));
    topic.setValue2(getResources().getString(R.string.rs));
    conversation.setSenderSmsFormat(MobiComUserPreference.getInstance(this).getUserId(), "SENDER SMS  FORMAT");
    conversation.setReceiverSmsFormat("usertest2", "RECEIVER SMS FORMAT");
    conversation.setTopicDetail(topic.getJson());
    return conversation;
}
Also used : TopicDetail(com.applozic.mobicomkit.feed.TopicDetail) Conversation(com.applozic.mobicommons.people.channel.Conversation)

Example 4 with TopicDetail

use of com.applozic.mobicomkit.feed.TopicDetail in project Applozic-Android-SDK by AppLozic.

the class ApplozicContextSpinnerAdapter method getCustomView.

public View getCustomView(int position, View convertView, ViewGroup parent) {
    Conversation conversation = (Conversation) getItem(position);
    ApplozicProductViewHolder viewHolder;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.applozic_context_based_layout, parent, false);
        viewHolder = new ApplozicProductViewHolder();
        viewHolder.productImage = (ImageView) convertView.findViewById(R.id.productImage);
        viewHolder.titleTextView = (TextView) convertView.findViewById(R.id.title);
        viewHolder.subTitleTextView = (TextView) convertView.findViewById(R.id.subTitle);
        viewHolder.key1TextView = (TextView) convertView.findViewById(R.id.qtyTitleTextView);
        viewHolder.value1TextView = (TextView) convertView.findViewById(R.id.qtyValueTextView);
        viewHolder.key2TextView = (TextView) convertView.findViewById(R.id.priceTitleTextView);
        viewHolder.value2TextView = (TextView) convertView.findViewById(R.id.priceValueTextview);
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ApplozicProductViewHolder) convertView.getTag();
    }
    try {
        if (conversation != null) {
            String topicId = conversation.getTopicId();
            String topicDetailJson = conversation.getTopicDetail();
            if (!TextUtils.isEmpty(topicDetailJson)) {
                TopicDetail topicDetail = (TopicDetail) GsonUtils.getObjectFromJson(topicDetailJson, TopicDetail.class);
                if (!TextUtils.isEmpty(topicDetail.getLink())) {
                    Glide.with(context).load(topicDetail.getLink()).into(viewHolder.productImage);
                }
                if (!TextUtils.isEmpty(topicDetail.getTitle())) {
                    viewHolder.titleTextView.setText(topicDetail.getTitle());
                }
                if (!TextUtils.isEmpty(topicDetail.getSubtitle())) {
                    viewHolder.subTitleTextView.setText(topicDetail.getSubtitle());
                }
                if (!TextUtils.isEmpty(topicDetail.getKey1())) {
                    viewHolder.key1TextView.setText(topicDetail.getKey1());
                }
                if (!TextUtils.isEmpty(topicDetail.getValue1())) {
                    viewHolder.value1TextView.setText(":" + topicDetail.getValue1());
                }
                if (!TextUtils.isEmpty(topicDetail.getKey2())) {
                    viewHolder.key2TextView.setText(topicDetail.getKey2());
                }
                if (!TextUtils.isEmpty(topicDetail.getValue2())) {
                    viewHolder.value2TextView.setText(":" + topicDetail.getValue2());
                }
            } else {
                viewHolder.productImage.setVisibility(View.GONE);
                viewHolder.titleTextView.setVisibility(View.GONE);
                viewHolder.subTitleTextView.setVisibility(View.GONE);
                viewHolder.key1TextView.setVisibility(View.GONE);
                viewHolder.value1TextView.setVisibility(View.GONE);
                viewHolder.key2TextView.setVisibility(View.GONE);
                viewHolder.value2TextView.setVisibility(View.GONE);
            }
        }
    } catch (Exception e) {
    }
    return convertView;
}
Also used : TopicDetail(com.applozic.mobicomkit.feed.TopicDetail) Conversation(com.applozic.mobicommons.people.channel.Conversation)

Aggregations

TopicDetail (com.applozic.mobicomkit.feed.TopicDetail)4 Conversation (com.applozic.mobicommons.people.channel.Conversation)3 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 Channel (com.applozic.mobicommons.people.channel.Channel)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HttpURLConnection (java.net.HttpURLConnection)1