use of com.applozic.mobicomkit.api.attachment.AttachmentView in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationFragment method updateDownloadStatus.
public void updateDownloadStatus(final Message message) {
if (this.getActivity() == null) {
return;
}
this.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
int index = messageList.indexOf(message);
if (index != -1) {
Message smListItem = messageList.get(index);
smListItem.setKeyString(message.getKeyString());
smListItem.setFileMetaKeyStrings(message.getFileMetaKeyStrings());
if (messageList.get(index) != null) {
messageList.get(index).setKeyString(message.getKeyString());
messageList.get(index).setFileMetaKeyStrings(message.getFileMetaKeyStrings());
}
View view = recyclerView.getChildAt(index - linearLayoutManager.findFirstVisibleItemPosition());
if (view != null) {
final RelativeLayout attachmentDownloadProgressLayout = (RelativeLayout) view.findViewById(R.id.attachment_download_progress_layout);
final AttachmentView attachmentView = (AttachmentView) view.findViewById(R.id.main_attachment_view);
final ImageView preview = (ImageView) view.findViewById(R.id.preview);
TextView audioDurationTextView = (TextView) view.findViewById(R.id.audio_duration_textView);
final ImageView videoIcon = (ImageView) view.findViewById(R.id.video_icon);
String audioDuration;
if (message.getFileMetas() != null && message.getFileMetas().getContentType().contains("image")) {
attachmentView.setVisibility(VISIBLE);
preview.setVisibility(View.GONE);
attachmentView.setMessage(smListItem);
attachmentDownloadProgressLayout.setVisibility(View.GONE);
} else if (message.getFileMetas() != null && message.getFileMetas().getContentType().contains("video")) {
FileClientService fileClientService = new FileClientService(getContext());
attachedFile.setVisibility(View.GONE);
preview.setVisibility(VISIBLE);
videoIcon.setVisibility(VISIBLE);
preview.setImageBitmap(fileClientService.getOrCreateVideoThumbnail(message.getFilePaths().get(0)));
} else if (message.getFileMetas() != null) {
// Hide Attachment View...
RelativeLayout applozicDocRelativeLayout = (RelativeLayout) view.findViewById(R.id.applozic_doc_downloaded);
ImageView imageViewDoc = (ImageView) applozicDocRelativeLayout.findViewById(R.id.doc_icon);
if (message.getFileMetas() != null && message.getFilePaths() == null) {
if (message.getFileMetas().getContentType().contains("audio")) {
imageViewDoc.setImageResource(R.drawable.ic_play_circle_outline);
} else {
imageViewDoc.setImageResource(R.drawable.ic_documentreceive);
}
applozicDocRelativeLayout.setVisibility(VISIBLE);
} else if (message.getFilePaths() != null) {
String filePath = message.getFilePaths().get(0);
final String mimeType = FileUtils.getMimeType(filePath);
if (mimeType.contains("audio")) {
if (message.isAttachmentDownloaded()) {
audioDuration = ApplozicAudioManager.getInstance(getContext()).refreshAudioDuration(filePath);
audioDurationTextView.setVisibility(View.VISIBLE);
audioDurationTextView.setText(audioDuration);
} else {
audioDurationTextView.setVisibility(View.VISIBLE);
audioDurationTextView.setText("00:00");
}
imageViewDoc.setImageResource(R.drawable.ic_play_circle_outline);
} else {
imageViewDoc.setImageResource(R.drawable.ic_documentreceive);
}
applozicDocRelativeLayout.setVisibility(VISIBLE);
}
view.findViewById(R.id.applozic_doc_download_progress_rl).setVisibility(View.GONE);
}
}
}
} catch (Exception ex) {
Utils.printLog(getContext(), TAG, "Exception while updating download status: " + ex.getMessage());
}
}
});
}
use of com.applozic.mobicomkit.api.attachment.AttachmentView in project Applozic-Android-SDK by AppLozic.
the class MessageInfoFragment method onCreateView.
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.applozic_message_info, container, false);
Bundle bundle = getArguments();
String messageJson = bundle.getString(MESSAGE_ARGUMENT_KEY);
message = (Message) GsonUtils.getObjectFromJson(messageJson, Message.class);
attachmentView = (AttachmentView) view.findViewById(R.id.applozic_message_info_attachmentview);
ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.applozic_message_info_progress_bar);
attachmentView.setProressBar(progressBar);
attachmentView.setVisibility(message.hasAttachment() ? View.VISIBLE : View.GONE);
RelativeLayout defaultRelativeLayout = (RelativeLayout) view.findViewById(R.id.applozic_message_info_default_layout);
TextView textView = (TextView) view.findViewById(R.id.applozic_message_info_message_text);
readListView = (RecyclerView) view.findViewById(R.id.applozic_message_info_read_list);
deliveredListView = (RecyclerView) view.findViewById(R.id.applozic_message_info_delivered_list_view);
readListView.setHasFixedSize(true);
deliveredListView.setHasFixedSize(true);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
RecyclerView.LayoutManager mLayoutManagerForDev = new LinearLayoutManager(getActivity());
readListView.setLayoutManager(mLayoutManager);
readListView.setClickable(true);
deliveredListView.setLayoutManager(mLayoutManagerForDev);
deliveredListView.setClickable(true);
init();
ImageView locationImageView = (ImageView) view.findViewById(R.id.static_mapview);
final LinearLayout mainContactShareLayout = (LinearLayout) view.findViewById(R.id.contact_share_layout);
RelativeLayout chatLocation = (RelativeLayout) view.findViewById(R.id.chat_location);
if (message.hasAttachment() && !message.isContactMessage() && !message.isLocationMessage()) {
textView.setVisibility(View.GONE);
attachmentView.setMessage(message);
chatLocation.setVisibility(View.GONE);
defaultRelativeLayout.setVisibility(View.GONE);
defaultRelativeLayout.setVisibility(View.VISIBLE);
setupAttachmentView(message, defaultRelativeLayout);
} else {
defaultRelativeLayout.setVisibility(View.GONE);
textView.setVisibility(View.VISIBLE);
textView.setText(message.getMessage());
}
if (message.isLocationMessage()) {
defaultRelativeLayout.setVisibility(View.GONE);
chatLocation.setVisibility(View.VISIBLE);
locationImageLoader.setImageFadeIn(false);
locationImageLoader.setLoadingImage(R.drawable.applozic_map_offline_thumbnail);
locationImageLoader.loadImage(LocationUtils.loadStaticMap(message.getMessage(), geoApiKey), locationImageView);
textView.setVisibility(View.GONE);
} else {
chatLocation.setVisibility(View.GONE);
}
if (message.isContactMessage()) {
chatLocation.setVisibility(View.GONE);
defaultRelativeLayout.setVisibility(View.GONE);
setupContactShareView(message, mainContactShareLayout);
textView.setVisibility(View.GONE);
} else {
mainContactShareLayout.setVisibility(View.GONE);
}
messageInfoAsyncTask = new MessageInfoAsyncTask(message.getKeyString(), getActivity());
AlTask.execute(messageInfoAsyncTask);
return view;
}
Aggregations