use of com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService in project Applozic-Android-SDK by AppLozic.
the class NotificationIntentService method onCreate.
@Override
public void onCreate() {
super.onCreate();
appContactService = new AppContactService(NotificationIntentService.this);
messageDatabaseService = new MessageDatabaseService(NotificationIntentService.this);
}
use of com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService in project Applozic-Android-SDK by AppLozic.
the class AlMessageMetadataUpdateTask method onPostExecute.
@Override
protected void onPostExecute(ApiResponse apiResponse) {
super.onPostExecute(apiResponse);
if (apiResponse == null) {
listener.onFailure(context.get(), "Some error occurred");
} else if (!"success".equals(apiResponse.getStatus()) && apiResponse.getErrorResponse() != null) {
listener.onFailure(context.get(), apiResponse.getErrorResponse().toString());
} else if ("success".equals(apiResponse.getStatus())) {
new MessageDatabaseService(context.get()).updateMessageMetadata(key, metadata);
listener.onSuccess(context.get(), "Metadata updated successfully for messsage key : " + key);
}
}
use of com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService in project Applozic-Android-SDK by AppLozic.
the class FileClientService method loadContactsvCard.
/**
* Downloads and saves the contact attachment card for the given message object (if it has one i.e {@link Message#hasAttachment()} returns true).
*
* <p>Note: Multiple calls to this method <i>DO NOT</i> download the contact multiple times.</p>
*
* <p>To, in the future, get the local path of the contact card use:
* <code>
* Message updatedMessage = new MessageDatabaseService(context).getMessage(messageKeyString); //message.getKeyString();
* updatedMessage.getFilePaths();
* </code></p>
*
* @param message the message object to download the contact card for
*/
public void loadContactsvCard(Message message) {
File file = null;
HttpURLConnection connection = null;
try {
InputStream inputStream = null;
FileMeta fileMeta = message.getFileMetas();
String contentType = fileMeta.getContentType();
String fileName = fileMeta.getName();
file = FileClientService.getFilePath(fileName, context.getApplicationContext(), contentType);
if (!file.exists()) {
connection = new URLServiceProvider(context).getDownloadConnection(message);
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
inputStream = connection.getInputStream();
} else {
// TODO: Error Handling...
Utils.printLog(context, TAG, "Got Error response while uploading file : " + connection.getResponseCode());
return;
}
OutputStream output = new FileOutputStream(file);
byte[] data = new byte[1024];
int count = 0;
while ((count = inputStream.read(data)) != -1) {
output.write(data, 0, count);
}
output.flush();
output.close();
inputStream.close();
}
// Todo: Fix this, so that attach package can be moved to mobicom mobicom.
new MessageDatabaseService(context).updateInternalFilePath(message.getKeyString(), file.getAbsolutePath());
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add(file.getAbsolutePath());
message.setFilePaths(arrayList);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
Utils.printLog(context, TAG, "File not found on server");
} catch (Exception ex) {
// If partial file got created delete it, we try to download it again
if (file != null && file.exists()) {
Utils.printLog(context, TAG, " Exception occured while downloading :" + file.getAbsolutePath());
file.delete();
}
ex.printStackTrace();
Utils.printLog(context, TAG, "Exception fetching file from server");
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
use of com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService in project Applozic-Android-SDK by AppLozic.
the class ApplozicConversation method markAsRead.
/**
* Mark a conversation as read. Either one of the <i>userId</i> or the <i>groupId</i> can be null.
*
* @param pairedMessageKey not used. pass null
* @param userId for one-to-one conversation
* @param groupId for group conversation
*/
public static void markAsRead(@NonNull Context context, @Nullable String pairedMessageKey, @Nullable String userId, @Nullable Integer groupId) {
try {
int unreadCount = 0;
Contact contact = null;
Channel channel = null;
if (userId != null) {
contact = new AppContactService(context).getContactById(userId);
unreadCount = contact.getUnreadCount();
new MessageDatabaseService(context).updateReadStatusForContact(userId);
} else if (groupId != null && groupId != 0) {
channel = ChannelService.getInstance(context).getChannelByChannelKey(groupId);
unreadCount = channel.getUnreadCount();
new MessageDatabaseService(context).updateReadStatusForChannel(String.valueOf(groupId));
}
UserWorker.enqueueWork(context, null, contact, channel, pairedMessageKey, unreadCount, false);
} catch (Exception exception) {
exception.printStackTrace();
}
}
use of com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
geoApiKey = Applozic.getInstance(getContext()).getGeoApiKey();
String jsonString = FileUtils.loadSettingsJsonFile(ApplozicService.getContext(getContext()));
if (!TextUtils.isEmpty(jsonString)) {
alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
} else {
alCustomizationSettings = new AlCustomizationSettings();
}
richMessageActionProcessor = new RichMessageActionProcessor(this);
restrictedWords = FileUtils.loadRestrictedWordsFile(getContext());
conversationUIService = new ConversationUIService(getActivity());
syncCallService = SyncCallService.getInstance(getActivity());
appContactService = new AppContactService(getActivity());
messageDatabaseService = new MessageDatabaseService(getActivity());
fileClientService = new FileClientService(getActivity());
setHasOptionsMenu(true);
imageThumbnailLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) {
@Override
protected Bitmap processBitmap(Object data) {
return fileClientService.downloadAndSaveThumbnailImage(getContext(), (Message) data, getImageLayoutParam(false).width, getImageLayoutParam(false).height);
}
};
imageCache = ImageCache.getInstance((getActivity()).getSupportFragmentManager(), 0.1f);
imageThumbnailLoader.setImageFadeIn(false);
imageThumbnailLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f);
messageImageLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) {
@Override
protected Bitmap processBitmap(Object data) {
return fileClientService.loadMessageImage(getContext(), (String) data);
}
};
messageImageLoader.setImageFadeIn(false);
messageImageLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f);
applozicAudioRecordManager = new ApplozicAudioRecordManager(getActivity());
mDetector = new GestureDetectorCompat(getContext(), this);
}
Aggregations